27 * @summary Similar to GCDuringDumping.java, this test adds the -XX:SharedArchiveConfigFile |
27 * @summary Similar to GCDuringDumping.java, this test adds the -XX:SharedArchiveConfigFile |
28 * option for testing the interaction with GC and shared strings. |
28 * option for testing the interaction with GC and shared strings. |
29 * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes |
29 * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes |
30 * @requires vm.cds.archived.java.heap |
30 * @requires vm.cds.archived.java.heap |
31 * @modules jdk.jartool/sun.tools.jar |
31 * @modules jdk.jartool/sun.tools.jar |
32 * @build sun.hotspot.WhiteBox GCDuringDumpTransformer GCSharedStringsDuringDumpWb |
32 * @build sun.hotspot.WhiteBox |
33 * @run driver ClassFileInstaller sun.hotspot.WhiteBox |
33 * @run driver ClassFileInstaller sun.hotspot.WhiteBox |
34 * @run main/othervm/timeout=480 GCSharedStringsDuringDump |
34 * @run driver/timeout=480 GCSharedStringsDuringDump |
35 */ |
35 */ |
36 |
36 |
37 import java.io.File; |
37 import java.io.File; |
38 import java.io.FileOutputStream; |
38 import java.io.FileOutputStream; |
39 import java.io.OutputStreamWriter; |
39 import java.io.OutputStreamWriter; |
40 import java.io.PrintWriter; |
40 import java.io.PrintWriter; |
41 import jdk.test.lib.cds.CDSOptions; |
41 import jdk.test.lib.cds.CDSOptions; |
42 import jdk.test.lib.process.OutputAnalyzer; |
42 import jdk.test.lib.process.OutputAnalyzer; |
43 import jdk.test.lib.process.ProcessTools; |
43 import jdk.test.lib.process.ProcessTools; |
44 import sun.hotspot.WhiteBox; |
|
45 |
44 |
46 public class GCSharedStringsDuringDump { |
45 public class GCSharedStringsDuringDump { |
47 public static String appClasses[] = { |
46 public static String appClasses[] = { |
48 "GCSharedStringsDuringDumpWb", |
47 GCSharedStringsDuringDumpWb.class.getName(), |
49 }; |
48 }; |
50 public static String agentClasses[] = { |
49 public static String agentClasses[] = { |
51 "GCDuringDumpTransformer", |
50 GCDuringDumpTransformer.class.getName(), |
52 }; |
51 }; |
53 |
52 |
54 public static void main(String[] args) throws Throwable { |
53 public static void main(String[] args) throws Throwable { |
55 String agentJar = |
54 String agentJar = |
56 ClassFileInstaller.writeJar("GCDuringDumpTransformer.jar", |
55 ClassFileInstaller.writeJar("GCDuringDumpTransformer.jar", |
86 // i = 1 -- run with agent = cause extra GCs |
85 // i = 1 -- run with agent = cause extra GCs |
87 |
86 |
88 String extraArg = (i == 0) ? "-showversion" : "-javaagent:" + agentJar; |
87 String extraArg = (i == 0) ? "-showversion" : "-javaagent:" + agentJar; |
89 String extraOption = (i == 0) ? "-showversion" : "-XX:+AllowArchivingWithJavaAgent"; |
88 String extraOption = (i == 0) ? "-showversion" : "-XX:+AllowArchivingWithJavaAgent"; |
90 OutputAnalyzer output = TestCommon.dump( |
89 OutputAnalyzer output = TestCommon.dump( |
91 appJar, TestCommon.list("GCSharedStringsDuringDumpWb"), |
90 appJar, TestCommon.list(GCSharedStringsDuringDumpWb.class.getName()), |
92 bootClassPath, extraArg, "-Xmx32m", gcLog, |
91 bootClassPath, extraArg, "-Xmx32m", gcLog, |
93 "-XX:SharedArchiveConfigFile=" + sharedArchiveCfgFile, |
92 "-XX:SharedArchiveConfigFile=" + sharedArchiveCfgFile, |
94 "-XX:+UnlockDiagnosticVMOptions", extraOption); |
93 "-XX:+UnlockDiagnosticVMOptions", extraOption); |
95 |
94 |
96 if (output.getStdout().contains("Too many string space regions") || |
95 if (output.getStdout().contains("Too many string space regions") || |
99 !output.getStdout().contains("oa0 space:") || |
98 !output.getStdout().contains("oa0 space:") || |
100 output.getExitValue() != 0) { |
99 output.getExitValue() != 0) { |
101 // Try again with larger heap and NewSize, this should increase the |
100 // Try again with larger heap and NewSize, this should increase the |
102 // G1 heap region size to 2M |
101 // G1 heap region size to 2M |
103 TestCommon.testDump( |
102 TestCommon.testDump( |
104 appJar, TestCommon.list("GCSharedStringsDuringDumpWb"), |
103 appJar, TestCommon.list(GCSharedStringsDuringDumpWb.class.getName()), |
105 bootClassPath, extraArg, "-Xmx8g", "-XX:NewSize=8m", gcLog, |
104 bootClassPath, extraArg, "-Xmx8g", "-XX:NewSize=8m", gcLog, |
106 "-XX:SharedArchiveConfigFile=" + sharedArchiveCfgFile, |
105 "-XX:SharedArchiveConfigFile=" + sharedArchiveCfgFile, |
107 "-XX:+UnlockDiagnosticVMOptions", extraOption); |
106 "-XX:+UnlockDiagnosticVMOptions", extraOption); |
108 } |
107 } |
109 |
108 |