< prev index next >
test/hotspot/jtreg/runtime/appcds/SharedArchiveFile.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 21,31 ****
* questions.
*
*/
/*
* @test
! * @summary The diagnostic option, -XX:SharedArchiveFile can be unlocked using -XX:+UseAppCDS
* @requires vm.cds
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* jdk.jartool/sun.tools.jar
--- 21,31 ----
* questions.
*
*/
/*
* @test
! * @summary Dumping -XX:SharedArchiveFile should succeed without extra flag to unlock
* @requires vm.cds
* @library /test/lib
* @modules java.base/jdk.internal.misc
* java.management
* jdk.jartool/sun.tools.jar
*** 39,82 ****
import jdk.test.lib.process.ProcessTools;
import java.util.Properties;
public class SharedArchiveFile {
public static void main(String[] args) throws Exception {
- boolean isProduct = !Platform.isDebugBuild();
String appJar = JarBuilder.getOrCreateHelloJar();
! // 1) Using -XX:SharedArchiveFile without -XX:+UseAppCDS should fail
! // on product binary without -XX:+UnlockDiagnosticVMOptions.
! if (isProduct) {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
! "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", "-Xshare:dump");
OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "dump");
! out.shouldContain("Error: VM option 'SharedArchiveFile' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.");
! }
!
! // 2) Dumping with -XX:+UnlockDiagnosticVMOptions -XX:SharedArchiveFile
! // should always succeed.
! CDSTestUtils.createArchive("-XX:+UnlockDiagnosticVMOptions")
! .shouldContain("Dumping");
!
! // 3) Using -XX:SharedArchiveFile with -XX:+UseAppCDS should work
! // on product binary by default.
! OutputAnalyzer output3 = TestCommon.dump(appJar, TestCommon.list("Hello"));
! output3.shouldContain("Dumping");
! output3 = TestCommon.exec(appJar, "Hello");
! TestCommon.checkExec(output3, "Hello World");
!
! // 4) Using -XX:+UseAppCDS should not affect other diagnostic flags,
! // such as LogEvents
! OutputAnalyzer output4 = TestCommon.exec(appJar, "-XX:+LogEvents", "Hello");
! if (isProduct) {
! output4.shouldContain("Error: VM option 'LogEvents' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.");
! } else {
! TestCommon.checkExec(output4, "Hello World");
! }
!
! // 5) 8066921 - Extra -XX:+UseAppCDS
! TestCommon.testDump(appJar, TestCommon.list("Hello"), "-XX:+UseAppCDS");
! OutputAnalyzer output5 = TestCommon.exec(appJar, "-XX:+UseAppCDS", "Hello");
! TestCommon.checkExec(output5);
}
}
--- 39,52 ----
import jdk.test.lib.process.ProcessTools;
import java.util.Properties;
public class SharedArchiveFile {
public static void main(String[] args) throws Exception {
String appJar = JarBuilder.getOrCreateHelloJar();
! // Dumping -XX:SharedArchiveFile should succeed with all binary.
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
! "-cp", appJar, "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", "-Xshare:dump");
OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "dump");
! out.shouldContain("Dumping");
}
}
< prev index next >