< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/javaldr/LockDuringDump.java

Print this page

40 public class LockDuringDump {
41     public static String appClasses[] = {
42         LockDuringDumpApp.class.getName(),
43     };
44     public static String agentClasses[] = {
45         LockDuringDumpAgent.class.getName(),
46     };
47 
48     private static final String MANIFEST =
49         "Manifest-Version: 1.0\nPremain-Class: LockDuringDumpAgent\n";
50 
51     public static void main(String[] args) throws Throwable {
52         String agentJar =
53             ClassFileInstaller.writeJar("LockDuringDumpAgent.jar",
54                                         ClassFileInstaller.Manifest.fromString(MANIFEST),
55                                         agentClasses);
56 
57         String appJar =
58             ClassFileInstaller.writeJar("LockDuringDumpApp.jar", appClasses);
59 
60         for (int i = 0; i < 3; i++) {
61             // i = 0 -- dump without agent
62             // i = 1 -- dump with agent
63 
64             String agentArg   = (i == 0) ? "-showversion" : "-javaagent:" + agentJar;
65             String agentArg2  = (i == 0) ? "-showversion" : "-XX:+AllowArchivingWithJavaAgent";
66 
67             OutputAnalyzer out =
68                 TestCommon.testDump(appJar, TestCommon.list(LockDuringDumpApp.class.getName()),
69                                     "-XX:+UnlockDiagnosticVMOptions",
70                                     agentArg, agentArg2);
71             if (i != 0 && !out.getStdout().contains("LockDuringDumpAgent timeout")) {
72                 out.shouldContain("Let's hold the lock on the literal string");
73             }
74 
75             TestCommon.run(
76                 "-cp", appJar,
77                 "-XX:+UnlockDiagnosticVMOptions", agentArg2,
78                 LockDuringDumpApp.class.getName())
79               .assertNormalExit("I am able to lock the literal string");
80         }

40 public class LockDuringDump {
41     public static String appClasses[] = {
42         LockDuringDumpApp.class.getName(),
43     };
44     public static String agentClasses[] = {
45         LockDuringDumpAgent.class.getName(),
46     };
47 
48     private static final String MANIFEST =
49         "Manifest-Version: 1.0\nPremain-Class: LockDuringDumpAgent\n";
50 
51     public static void main(String[] args) throws Throwable {
52         String agentJar =
53             ClassFileInstaller.writeJar("LockDuringDumpAgent.jar",
54                                         ClassFileInstaller.Manifest.fromString(MANIFEST),
55                                         agentClasses);
56 
57         String appJar =
58             ClassFileInstaller.writeJar("LockDuringDumpApp.jar", appClasses);
59 
60         for (int i = 0; i < 2; i++) {
61             // i = 0 -- dump without agent
62             // i = 1 -- dump with agent
63 
64             String agentArg   = (i == 0) ? "-showversion" : "-javaagent:" + agentJar;
65             String agentArg2  = (i == 0) ? "-showversion" : "-XX:+AllowArchivingWithJavaAgent";
66 
67             OutputAnalyzer out =
68                 TestCommon.testDump(appJar, TestCommon.list(LockDuringDumpApp.class.getName()),
69                                     "-XX:+UnlockDiagnosticVMOptions",
70                                     agentArg, agentArg2);
71             if (i != 0 && !out.getStdout().contains("LockDuringDumpAgent timeout")) {
72                 out.shouldContain("Let's hold the lock on the literal string");
73             }
74 
75             TestCommon.run(
76                 "-cp", appJar,
77                 "-XX:+UnlockDiagnosticVMOptions", agentArg2,
78                 LockDuringDumpApp.class.getName())
79               .assertNormalExit("I am able to lock the literal string");
80         }
< prev index next >