60
61 public static void main(String[] args) throws Exception {
62 if (!Platform.shouldSAAttach()) {
63 System.out.println("SA attach not expected to work - test skipped.");
64 return;
65 }
66
67 CDSTestUtils.createArchiveAndCheck();
68 run(true);
69 run(false);
70 }
71
72
73 private static void run(boolean useArchive) throws Exception {
74 String flag = useArchive ? "auto" : "off";
75
76 try {
77 // (1) Launch the attachee process
78 System.out.println("Starting LingeredApp");
79 List<String> vmOpts = Arrays.asList(
80 "-XX:+UnlockDiagnosticVMOptions",
81 "-XX:SharedArchiveFile=" + jsaName,
82 "-Xshare:" + flag,
83 "-showversion"); // so we can see "sharing" in the output
84
85 theApp = LingeredApp.startApp(vmOpts);
86
87 // (2) Launch the agent process
88 long pid = theApp.getPid();
89 System.out.println("Attaching agent to " + pid );
90 ProcessBuilder tool = ProcessTools.createJavaProcessBuilder(
91 "--add-modules=jdk.hotspot.agent",
92 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
93 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED",
94 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED",
95 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED",
96 "SASymbolTableTestAgent",
97 Long.toString(pid));
98 OutputAnalyzer output = CDSTestUtils.executeAndLog(tool, "tool");
99 if (output.getStdout().contains("connected too early")) {
100 System.out.println("SymbolTable not created by VM - test skipped");
|
60
61 public static void main(String[] args) throws Exception {
62 if (!Platform.shouldSAAttach()) {
63 System.out.println("SA attach not expected to work - test skipped.");
64 return;
65 }
66
67 CDSTestUtils.createArchiveAndCheck();
68 run(true);
69 run(false);
70 }
71
72
73 private static void run(boolean useArchive) throws Exception {
74 String flag = useArchive ? "auto" : "off";
75
76 try {
77 // (1) Launch the attachee process
78 System.out.println("Starting LingeredApp");
79 List<String> vmOpts = Arrays.asList(
80 "-XX:SharedArchiveFile=" + jsaName,
81 "-Xshare:" + flag,
82 "-showversion"); // so we can see "sharing" in the output
83
84 theApp = LingeredApp.startApp(vmOpts);
85
86 // (2) Launch the agent process
87 long pid = theApp.getPid();
88 System.out.println("Attaching agent to " + pid );
89 ProcessBuilder tool = ProcessTools.createJavaProcessBuilder(
90 "--add-modules=jdk.hotspot.agent",
91 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED",
92 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED",
93 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED",
94 "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED",
95 "SASymbolTableTestAgent",
96 Long.toString(pid));
97 OutputAnalyzer output = CDSTestUtils.executeAndLog(tool, "tool");
98 if (output.getStdout().contains("connected too early")) {
99 System.out.println("SymbolTable not created by VM - test skipped");
|