< prev index next > test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java
Print this page
public final static String HELLO = "Hello World";
public final static String UNABLE_TO_USE_ARCHIVE = "Unable to use shared archive.";
public final static String ERR_MSG = "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled.";
public static void main(String... args) throws Exception {
String zGenerational = args[0];
+ String compactHeaders = "-XX:" + (zGenerational.equals("-XX:+ZGenerational") ? "+" : "-") + "UseCompactObjectHeaders";
String helloJar = JarBuilder.build("hello", "Hello");
System.out.println("0. Dump with ZGC");
OutputAnalyzer out = TestCommon
.dump(helloJar,
new String[] {"Hello"},
"-XX:+UseZGC",
zGenerational,
+ "-XX:+UnlockExperimentalVMOptions",
+ compactHeaders,
"-Xlog:cds");
out.shouldContain("Dumping shared data to file:");
out.shouldHaveExitValue(0);
System.out.println("1. Run with same args of dump");
out = TestCommon
.exec(helloJar,
"-XX:+UseZGC",
zGenerational,
+ "-XX:+UnlockExperimentalVMOptions",
+ compactHeaders,
"-Xlog:cds",
"Hello");
out.shouldContain(HELLO);
out.shouldHaveExitValue(0);
out = TestCommon
.exec(helloJar,
"-XX:-UseZGC",
"-XX:+UseCompressedOops", // in case turned off by vmoptions
"-XX:+UseCompressedClassPointers", // by jtreg
+ "-XX:+UnlockExperimentalVMOptions",
+ compactHeaders,
"-Xlog:cds",
"Hello");
out.shouldContain(UNABLE_TO_USE_ARCHIVE);
out.shouldContain(ERR_MSG);
out.shouldHaveExitValue(1);
out = TestCommon
.exec(helloJar,
"-XX:+UseSerialGC",
"-XX:-UseCompressedOops",
"-XX:+UseCompressedClassPointers",
+ "-XX:+UnlockExperimentalVMOptions",
+ compactHeaders,
"-Xlog:cds",
"Hello");
out.shouldContain(HELLO);
out.shouldHaveExitValue(0);
out = TestCommon
.exec(helloJar,
"-XX:+UseSerialGC",
"-XX:+UseCompressedOops",
"-XX:+UseCompressedClassPointers",
+ "-XX:+UnlockExperimentalVMOptions",
+ compactHeaders,
"-Xlog:cds",
"Hello");
out.shouldContain(UNABLE_TO_USE_ARCHIVE);
out.shouldContain(ERR_MSG);
out.shouldHaveExitValue(1);
.dump(helloJar,
new String[] {"Hello"},
"-XX:+UseSerialGC",
"-XX:-UseCompressedOops",
"-XX:+UseCompressedClassPointers",
+ "-XX:+UnlockExperimentalVMOptions",
+ compactHeaders,
"-Xlog:cds");
out.shouldContain("Dumping shared data to file:");
out.shouldHaveExitValue(0);
System.out.println("8. Run with ZGC");
out = TestCommon
.exec(helloJar,
"-XX:+UseZGC",
zGenerational,
+ "-XX:+UnlockExperimentalVMOptions",
+ compactHeaders,
"-Xlog:cds",
"Hello");
out.shouldContain(HELLO);
out.shouldHaveExitValue(0);
}
< prev index next >