24
25 /*
26 * @test
27 * @summary Test options that are incompatible with use of shared strings
28 * Also test mismatch in oops encoding between dump time and run time
29 * @requires vm.cds.archived.java.heap
30 * @requires (vm.gc=="null")
31 * @library /test/lib /test/hotspot/jtreg/runtime/appcds
32 * @modules jdk.jartool/sun.tools.jar
33 * @build sun.hotspot.WhiteBox
34 * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
35 * @build HelloString
36 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions
37 */
38
39 import jdk.test.lib.Asserts;
40 import jdk.test.lib.Platform;
41 import jdk.test.lib.process.OutputAnalyzer;
42
43 import sun.hotspot.code.Compiler;
44
45 public class IncompatibleOptions {
46 static final String COOPS_DUMP_WARNING =
47 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off";
48 static final String COOPS_EXEC_WARNING =
49 "UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces";
50 static final String GC_WARNING =
51 "Archived java heap is not supported";
52 static final String OBJ_ALIGNMENT_MISMATCH =
53 "The shared archive file's ObjectAlignmentInBytes of .* does not equal the current ObjectAlignmentInBytes of";
54 static final String COMPACT_STRING_MISMATCH =
55 "The shared archive file's CompactStrings setting .* does not equal the current CompactStrings setting";
56
57 static String appJar;
58 static String[] globalVmOptions;
59
60 public static void main(String[] args) throws Exception {
61 globalVmOptions = args; // specified by "@run main" in IncompatibleOptions_*.java
62 appJar = JarBuilder.build("IncompatibleOptions", "HelloString");
63
64 // Uncompressed OOPs
65 testDump(1, "-XX:+UseG1GC", "-XX:-UseCompressedOops", COOPS_DUMP_WARNING, true);
66 if (Platform.isLinux() && Platform.isX64()) {
67 testDump(1, "-XX:+UnlockExperimentalVMOptions", "-XX:+UseZGC", COOPS_DUMP_WARNING, true);
68 }
69
70 // incompatible GCs
71 testDump(2, "-XX:+UseParallelGC", "", GC_WARNING, false);
72 testDump(3, "-XX:+UseSerialGC", "", GC_WARNING, false);
73 if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
74 testDump(4, "-XX:+UseConcMarkSweepGC", "", GC_WARNING, false);
75 }
76
77 // ======= archive with compressed oops, run w/o
78 testDump(5, "-XX:+UseG1GC", "-XX:+UseCompressedOops", null, false);
79 testExec(5, "-XX:+UseG1GC", "-XX:-UseCompressedOops",
80 COOPS_EXEC_WARNING, true);
81
82 // NOTE: No warning is displayed, by design
83 // Still run, to ensure no crash or exception
84 testExec(6, "-XX:+UseParallelGC", "", "", false);
85 testExec(7, "-XX:+UseSerialGC", "", "", false);
86 if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
|
24
25 /*
26 * @test
27 * @summary Test options that are incompatible with use of shared strings
28 * Also test mismatch in oops encoding between dump time and run time
29 * @requires vm.cds.archived.java.heap
30 * @requires (vm.gc=="null")
31 * @library /test/lib /test/hotspot/jtreg/runtime/appcds
32 * @modules jdk.jartool/sun.tools.jar
33 * @build sun.hotspot.WhiteBox
34 * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
35 * @build HelloString
36 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions
37 */
38
39 import jdk.test.lib.Asserts;
40 import jdk.test.lib.Platform;
41 import jdk.test.lib.process.OutputAnalyzer;
42
43 import sun.hotspot.code.Compiler;
44 import sun.hotspot.gc.GC;
45
46 public class IncompatibleOptions {
47 static final String COOPS_DUMP_WARNING =
48 "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off";
49 static final String COOPS_EXEC_WARNING =
50 "UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces";
51 static final String GC_WARNING =
52 "Archived java heap is not supported";
53 static final String OBJ_ALIGNMENT_MISMATCH =
54 "The shared archive file's ObjectAlignmentInBytes of .* does not equal the current ObjectAlignmentInBytes of";
55 static final String COMPACT_STRING_MISMATCH =
56 "The shared archive file's CompactStrings setting .* does not equal the current CompactStrings setting";
57
58 static String appJar;
59 static String[] globalVmOptions;
60
61 public static void main(String[] args) throws Exception {
62 globalVmOptions = args; // specified by "@run main" in IncompatibleOptions_*.java
63 appJar = JarBuilder.build("IncompatibleOptions", "HelloString");
64
65 // Uncompressed OOPs
66 testDump(1, "-XX:+UseG1GC", "-XX:-UseCompressedOops", COOPS_DUMP_WARNING, true);
67 if (GC.Z.isSupported()) { // ZGC is included in build.
68 testDump(1, "-XX:+UnlockExperimentalVMOptions", "-XX:+UseZGC", COOPS_DUMP_WARNING, true);
69 }
70
71 // incompatible GCs
72 testDump(2, "-XX:+UseParallelGC", "", GC_WARNING, false);
73 testDump(3, "-XX:+UseSerialGC", "", GC_WARNING, false);
74 if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
75 testDump(4, "-XX:+UseConcMarkSweepGC", "", GC_WARNING, false);
76 }
77
78 // ======= archive with compressed oops, run w/o
79 testDump(5, "-XX:+UseG1GC", "-XX:+UseCompressedOops", null, false);
80 testExec(5, "-XX:+UseG1GC", "-XX:-UseCompressedOops",
81 COOPS_EXEC_WARNING, true);
82
83 // NOTE: No warning is displayed, by design
84 // Still run, to ensure no crash or exception
85 testExec(6, "-XX:+UseParallelGC", "", "", false);
86 testExec(7, "-XX:+UseSerialGC", "", "", false);
87 if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
|