26 * @test |
26 * @test |
27 * @summary When dumping the CDS archive, try to cause garbage collection while classes are being loaded. |
27 * @summary When dumping the CDS archive, try to cause garbage collection while classes are being loaded. |
28 * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes |
28 * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds /test/hotspot/jtreg/runtime/cds/appcds/test-classes |
29 * @requires vm.cds |
29 * @requires vm.cds |
30 * @requires vm.flavor != "minimal" |
30 * @requires vm.flavor != "minimal" |
31 * @build GCDuringDumpTransformer Hello |
31 * @run driver GCDuringDump |
32 * @run main/othervm GCDuringDump |
|
33 */ |
32 */ |
34 |
33 |
35 import jdk.test.lib.cds.CDSOptions; |
34 import jdk.test.lib.cds.CDSOptions; |
36 import jdk.test.lib.process.OutputAnalyzer; |
35 import jdk.test.lib.process.OutputAnalyzer; |
37 import jdk.test.lib.process.ProcessTools; |
36 import jdk.test.lib.process.ProcessTools; |
38 |
37 |
39 public class GCDuringDump { |
38 public class GCDuringDump { |
40 public static String appClasses[] = { |
39 public static String appClasses[] = { |
41 "Hello", |
40 Hello.class.getName(), |
42 }; |
41 }; |
43 public static String agentClasses[] = { |
42 public static String agentClasses[] = { |
44 "GCDuringDumpTransformer", |
43 GCDuringDumpTransformer.class.getName(), |
45 }; |
44 }; |
46 |
45 |
47 public static void main(String[] args) throws Throwable { |
46 public static void main(String[] args) throws Throwable { |
48 String agentJar = |
47 String agentJar = |
49 ClassFileInstaller.writeJar("GCDuringDumpTransformer.jar", |
48 ClassFileInstaller.writeJar("GCDuringDumpTransformer.jar", |
61 // i = 1 -- run with agent = cause extra GCs |
60 // i = 1 -- run with agent = cause extra GCs |
62 |
61 |
63 String extraArg = (i == 0) ? "-showversion" : "-javaagent:" + agentJar; |
62 String extraArg = (i == 0) ? "-showversion" : "-javaagent:" + agentJar; |
64 String extraOption = (i == 0) ? "-showversion" : "-XX:+AllowArchivingWithJavaAgent"; |
63 String extraOption = (i == 0) ? "-showversion" : "-XX:+AllowArchivingWithJavaAgent"; |
65 |
64 |
66 TestCommon.testDump(appJar, TestCommon.list("Hello"), |
65 TestCommon.testDump(appJar, TestCommon.list(Hello.class.getName()), |
67 "-XX:+UnlockDiagnosticVMOptions", extraOption, |
66 "-XX:+UnlockDiagnosticVMOptions", extraOption, |
68 extraArg, "-Xmx32m", gcLog); |
67 extraArg, "-Xmx32m", gcLog); |
69 |
68 |
70 TestCommon.run( |
69 TestCommon.run( |
71 "-cp", appJar, |
70 "-cp", appJar, |
72 "-Xmx32m", |
71 "-Xmx32m", |
73 "-XX:+PrintSharedSpaces", |
72 "-XX:+PrintSharedSpaces", |
74 "-XX:+UnlockDiagnosticVMOptions", extraOption, |
73 "-XX:+UnlockDiagnosticVMOptions", extraOption, |
75 gcLog, |
74 gcLog, |
76 "Hello") |
75 Hello.class.getName()) |
77 .assertNormalExit(); |
76 .assertNormalExit(); |
78 } |
77 } |
79 } |
78 } |
80 } |
79 } |
81 |
80 |