34 */
35
36 import java.io.File;
37 import jdk.test.lib.cds.CDSTestUtils;
38 import jdk.test.lib.helpers.ClassFileInstaller;
39 import jdk.test.lib.process.OutputAnalyzer;
40 import jdk.test.lib.process.ProcessTools;
41
42 public class AOTFlags {
43 static String appJar = ClassFileInstaller.getJarPath("hello.jar");
44 static String aotConfigFile = "hello.aotconfig";
45 static String aotCacheFile = "hello.aot";
46 static String helloClass = "Hello";
47
48 public static void main(String[] args) throws Exception {
49 positiveTests();
50 negativeTests();
51 }
52
53 static void positiveTests() throws Exception {
54 //----------------------------------------------------------------------
55 printTestCase("Training Run");
56 ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
57 "-XX:AOTMode=record",
58 "-XX:AOTConfiguration=" + aotConfigFile,
59 "-Xlog:cds=debug",
60 "-cp", appJar, helloClass);
61
62 OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "train");
63 out.shouldContain("Hello World");
64 out.shouldContain("AOTConfiguration recorded: " + aotConfigFile);
65 out.shouldHaveExitValue(0);
66
67 //----------------------------------------------------------------------
68 printTestCase("Assembly Phase (AOTClassLinking unspecified -> should be enabled by default)");
69 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
70 "-XX:AOTMode=create",
71 "-XX:AOTConfiguration=" + aotConfigFile,
72 "-XX:AOTCache=" + aotCacheFile,
73 "-Xlog:cds",
74 "-cp", appJar);
75 out = CDSTestUtils.executeAndLog(pb, "asm");
76 out.shouldContain("Dumping shared data to file:");
77 out.shouldMatch("cds.*hello[.]aot");
78 out.shouldHaveExitValue(0);
79
80 //----------------------------------------------------------------------
81 printTestCase("Production Run with AOTCache");
82 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
83 "-XX:AOTCache=" + aotCacheFile,
84 "-Xlog:cds",
85 "-cp", appJar, helloClass);
86 out = CDSTestUtils.executeAndLog(pb, "prod");
87 out.shouldContain("Using AOT-linked classes: true (static archive: has aot-linked classes)");
88 out.shouldContain("Opened AOT cache hello.aot.");
89 out.shouldContain("Hello World");
90 out.shouldHaveExitValue(0);
91
92 //----------------------------------------------------------------------
93 printTestCase("AOTMode=off");
94 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
95 "-XX:AOTCache=" + aotCacheFile,
96 "--show-version",
97 "-Xlog:cds",
98 "-XX:AOTMode=off",
99 "-cp", appJar, helloClass);
100 out = CDSTestUtils.executeAndLog(pb, "prod");
101 out.shouldNotContain(", sharing");
102 out.shouldNotContain("Opened AOT cache hello.aot.");
103 out.shouldContain("Hello World");
104 out.shouldHaveExitValue(0);
105
106 //----------------------------------------------------------------------
107 printTestCase("AOTMode=auto");
108 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
109 "-XX:AOTCache=" + aotCacheFile,
121 printTestCase("AOTMode=on");
122 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
123 "-XX:AOTCache=" + aotCacheFile,
124 "--show-version",
125 "-Xlog:cds",
126 "-XX:AOTMode=on",
127 "-cp", appJar, helloClass);
128 out = CDSTestUtils.executeAndLog(pb, "prod");
129 out.shouldContain(", sharing");
130 out.shouldContain("Opened AOT cache hello.aot.");
131 out.shouldContain("Hello World");
132 out.shouldHaveExitValue(0);
133
134 //----------------------------------------------------------------------
135 printTestCase("Assembly Phase with -XX:-AOTClassLinking");
136 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
137 "-XX:AOTMode=create",
138 "-XX:-AOTClassLinking",
139 "-XX:AOTConfiguration=" + aotConfigFile,
140 "-XX:AOTCache=" + aotCacheFile,
141 "-Xlog:cds",
142 "-cp", appJar);
143 out = CDSTestUtils.executeAndLog(pb, "asm");
144 out.shouldContain("Dumping shared data to file:");
145 out.shouldMatch("cds.*hello[.]aot");
146 out.shouldHaveExitValue(0);
147
148 //----------------------------------------------------------------------
149 printTestCase("Production Run with AOTCache, which was created with -XX:-AOTClassLinking");
150 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
151 "-XX:AOTCache=" + aotCacheFile,
152 "-Xlog:cds",
153 "-cp", appJar, helloClass);
154 out = CDSTestUtils.executeAndLog(pb, "prod");
155 out.shouldContain("Using AOT-linked classes: false (static archive: no aot-linked classes)");
156 out.shouldContain("Opened AOT cache hello.aot.");
157 out.shouldContain("Hello World");
158 out.shouldHaveExitValue(0);
159 }
160
161 static void negativeTests() throws Exception {
162 //----------------------------------------------------------------------
163 printTestCase("Mixing old and new options");
164 String mixOldNewErrSuffix = " cannot be used at the same time with -Xshare:on, -Xshare:auto, "
165 + "-Xshare:off, -Xshare:dump, DumpLoadedClassList, SharedClassListFile, "
166 + "or SharedArchiveFile";
167
168 ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
169 "-Xshare:off",
170 "-XX:AOTConfiguration=" + aotConfigFile,
171 "-cp", appJar, helloClass);
172
173 OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "neg");
174 out.shouldContain("Option AOTConfiguration" + mixOldNewErrSuffix);
175 out.shouldNotHaveExitValue(0);
176
177 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
178 "-XX:SharedArchiveFile=" + aotCacheFile,
179 "-XX:AOTCache=" + aotCacheFile,
180 "-cp", appJar, helloClass);
181 out = CDSTestUtils.executeAndLog(pb, "neg");
182 out.shouldContain("Option AOTCache" + mixOldNewErrSuffix);
183 out.shouldNotHaveExitValue(0);
184
185 //----------------------------------------------------------------------
186 printTestCase("Use AOTConfiguration without AOTMode");
187 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
188 "-XX:AOTConfiguration=" + aotConfigFile,
189 "-cp", appJar, helloClass);
190
191 out = CDSTestUtils.executeAndLog(pb, "neg");
192 out.shouldContain("AOTConfiguration can only be used with -XX:AOTMode=record or -XX:AOTMode=create");
193 out.shouldNotHaveExitValue(0);
194
195 //----------------------------------------------------------------------
196 printTestCase("Use AOTMode without AOTConfiguration");
197 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
198 "-XX:AOTMode=record",
199 "-cp", appJar, helloClass);
200
201 out = CDSTestUtils.executeAndLog(pb, "neg");
202 out.shouldContain("-XX:AOTMode=record cannot be used without setting AOTConfiguration");
203
204 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
205 "-XX:AOTMode=create",
206 "-cp", appJar, helloClass);
207
208 out = CDSTestUtils.executeAndLog(pb, "neg");
209 out.shouldContain("-XX:AOTMode=create cannot be used without setting AOTConfiguration");
210 out.shouldNotHaveExitValue(0);
211
212 //----------------------------------------------------------------------
213 printTestCase("Bad AOTMode");
214 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
215 "-XX:AOTMode=foo",
216 "-cp", appJar, helloClass);
217
218 out = CDSTestUtils.executeAndLog(pb, "neg");
219 out.shouldContain("Unrecognized value foo for AOTMode. Must be one of the following: off, record, create, auto, on");
220 out.shouldNotHaveExitValue(0);
221
222 //----------------------------------------------------------------------
223 printTestCase("AOTCache specified with -XX:AOTMode=record");
224 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
225 "-XX:AOTMode=record",
226 "-XX:AOTConfiguration=" + aotConfigFile,
227 "-XX:AOTCache=" + aotCacheFile,
228 "-cp", appJar, helloClass);
229
230 out = CDSTestUtils.executeAndLog(pb, "neg");
231 out.shouldContain("AOTCache must not be specified when using -XX:AOTMode=record");
232 out.shouldNotHaveExitValue(0);
233
234 //----------------------------------------------------------------------
235 printTestCase("AOTCache not specified with -XX:AOTMode=create");
236 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
237 "-XX:AOTMode=create",
238 "-XX:AOTConfiguration=" + aotConfigFile,
239 "-cp", appJar, helloClass);
240
241 out = CDSTestUtils.executeAndLog(pb, "neg");
242 out.shouldContain("AOTCache must be specified when using -XX:AOTMode=create");
243 out.shouldNotHaveExitValue(0);
244
245 //----------------------------------------------------------------------
246 printTestCase("No such config file");
247 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
248 "-XX:AOTMode=create",
249 "-XX:AOTConfiguration=no-such-file",
250 "-XX:AOTCache=" + aotCacheFile,
251 "-cp", appJar, helloClass);
252
253 out = CDSTestUtils.executeAndLog(pb, "neg");
254 out.shouldContain("Must be a valid AOT configuration generated by the current JVM: no-such-file");
255 out.shouldNotHaveExitValue(0);
256
257 //----------------------------------------------------------------------
258 printTestCase("AOTConfiguration file cannot be used as a CDS archive");
259
260 // first make sure we have a valid aotConfigFile
261 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
262 "-XX:AOTMode=record",
341 "-XX:SharedArchiveFile=" + staticArchive,
342 "-XX:ArchiveClassesAtExit=" + dynamicArchive,
343 "--version");
344 out = CDSTestUtils.executeAndLog(pb, "dynamic");
345 out.shouldHaveExitValue(0);
346
347 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
348 "-Xlog:cds",
349 "-XX:AOTMode=on",
350 "-XX:AOTCache=" + dynamicArchive,
351 "--version");
352
353 out = CDSTestUtils.executeAndLog(pb, "neg");
354 out.shouldContain("Unable to use AOT cache.");
355 out.shouldContain("Not a valid AOT cache (dynamic.jsa)");
356 out.shouldHaveExitValue(1);
357 }
358
359 static int testNum = 0;
360 static void printTestCase(String s) {
361 System.out.println("vvvvvvv TEST CASE " + testNum + ": " + s + " starts here vvvvvvv");
362 testNum++;
363 }
364 }
|
34 */
35
36 import java.io.File;
37 import jdk.test.lib.cds.CDSTestUtils;
38 import jdk.test.lib.helpers.ClassFileInstaller;
39 import jdk.test.lib.process.OutputAnalyzer;
40 import jdk.test.lib.process.ProcessTools;
41
42 public class AOTFlags {
43 static String appJar = ClassFileInstaller.getJarPath("hello.jar");
44 static String aotConfigFile = "hello.aotconfig";
45 static String aotCacheFile = "hello.aot";
46 static String helloClass = "Hello";
47
48 public static void main(String[] args) throws Exception {
49 positiveTests();
50 negativeTests();
51 }
52
53 static void positiveTests() throws Exception {
54 String hasTrainingDataPattern = "MethodTrainingData *= *[1-9]";
55 String noTrainingDataPattern = "MethodTrainingData *= *0";
56 String hasAOTCodePattern = "Shared file region .ac. .: *[1-9]";
57 String noAOTCodePattern = "Shared file region .ac. .: *0";
58 String hasMappedAOTCodePattern = "Mapped [0-9]+ bytes at address 0x[0-9a-f]+ from AOT Code Cache";
59
60 //----------------------------------------------------------------------
61 printTestCase("Training Run");
62 ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
63 "-XX:AOTMode=record",
64 "-XX:AOTConfiguration=" + aotConfigFile,
65 "-Xlog:cds=debug",
66 "-cp", appJar, helloClass);
67
68 OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "train");
69 out.shouldContain("Hello World");
70 out.shouldContain("AOTConfiguration recorded: " + aotConfigFile);
71 out.shouldMatch(hasTrainingDataPattern);
72 out.shouldMatch(noAOTCodePattern);
73 out.shouldHaveExitValue(0);
74
75 //----------------------------------------------------------------------
76 printTestCase("Assembly Phase (AOTClassLinking unspecified -> should be enabled by default)");
77 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
78 "-XX:AOTMode=create",
79 "-XX:AOTConfiguration=" + aotConfigFile,
80 "-XX:AOTCache=" + aotCacheFile,
81 "-Xlog:cds",
82 "-cp", appJar);
83 out = CDSTestUtils.executeAndLog(pb, "asm");
84 out.shouldContain("Dumping shared data to file:");
85 out.shouldMatch("cds.*hello[.]aot");
86 out.shouldMatch(hasTrainingDataPattern);
87 out.shouldMatch(hasAOTCodePattern);
88 out.shouldHaveExitValue(0);
89
90 //----------------------------------------------------------------------
91 printTestCase("Production Run with AOTCache");
92 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
93 "-XX:AOTCache=" + aotCacheFile,
94 "-Xlog:cds",
95 "-Xlog:aot+codecache*",
96 "-cp", appJar, helloClass);
97 out = CDSTestUtils.executeAndLog(pb, "prod");
98 out.shouldContain("Using AOT-linked classes: true (static archive: has aot-linked classes)");
99 out.shouldContain("Opened AOT cache hello.aot.");
100 out.shouldContain("Hello World");
101 out.shouldMatch(hasMappedAOTCodePattern);
102 out.shouldHaveExitValue(0);
103
104 //----------------------------------------------------------------------
105 printTestCase("AOTMode=off");
106 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
107 "-XX:AOTCache=" + aotCacheFile,
108 "--show-version",
109 "-Xlog:cds",
110 "-XX:AOTMode=off",
111 "-cp", appJar, helloClass);
112 out = CDSTestUtils.executeAndLog(pb, "prod");
113 out.shouldNotContain(", sharing");
114 out.shouldNotContain("Opened AOT cache hello.aot.");
115 out.shouldContain("Hello World");
116 out.shouldHaveExitValue(0);
117
118 //----------------------------------------------------------------------
119 printTestCase("AOTMode=auto");
120 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
121 "-XX:AOTCache=" + aotCacheFile,
133 printTestCase("AOTMode=on");
134 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
135 "-XX:AOTCache=" + aotCacheFile,
136 "--show-version",
137 "-Xlog:cds",
138 "-XX:AOTMode=on",
139 "-cp", appJar, helloClass);
140 out = CDSTestUtils.executeAndLog(pb, "prod");
141 out.shouldContain(", sharing");
142 out.shouldContain("Opened AOT cache hello.aot.");
143 out.shouldContain("Hello World");
144 out.shouldHaveExitValue(0);
145
146 //----------------------------------------------------------------------
147 printTestCase("Assembly Phase with -XX:-AOTClassLinking");
148 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
149 "-XX:AOTMode=create",
150 "-XX:-AOTClassLinking",
151 "-XX:AOTConfiguration=" + aotConfigFile,
152 "-XX:AOTCache=" + aotCacheFile,
153 "-Xlog:cds=debug",
154 "-cp", appJar);
155 out = CDSTestUtils.executeAndLog(pb, "asm");
156 out.shouldContain("Dumping shared data to file:");
157 out.shouldMatch("cds.*hello[.]aot");
158 out.shouldMatch(noTrainingDataPattern);
159 out.shouldMatch(noAOTCodePattern);
160 out.shouldHaveExitValue(0);
161
162 //----------------------------------------------------------------------
163 printTestCase("Production Run with AOTCache, which was created with -XX:-AOTClassLinking");
164 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
165 "-XX:AOTCache=" + aotCacheFile,
166 "-Xlog:cds",
167 "-Xlog:aot+codecache*",
168 "-cp", appJar, helloClass);
169 out = CDSTestUtils.executeAndLog(pb, "prod");
170 out.shouldContain("Using AOT-linked classes: false (static archive: no aot-linked classes)");
171 out.shouldContain("Opened AOT cache hello.aot.");
172 out.shouldContain("Hello World");
173 out.shouldNotMatch(hasMappedAOTCodePattern);
174 out.shouldHaveExitValue(0);
175
176 //----------------------------------------------------------------------
177 printTestCase("Training run with -XX:-AOTClassLinking, but assembly run with -XX:+AOTClassLinking");
178 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
179 "-XX:AOTMode=record",
180 "-XX:-AOTClassLinking",
181 "-XX:AOTConfiguration=" + aotConfigFile,
182 "-Xlog:cds=debug",
183 "-cp", appJar, helloClass);
184 out = CDSTestUtils.executeAndLog(pb, "train");
185 out.shouldContain("Hello World");
186 out.shouldContain("AOTConfiguration recorded: " + aotConfigFile);
187 out.shouldHaveExitValue(0);
188
189 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
190 "-XX:AOTMode=create",
191 "-XX:+AOTClassLinking",
192 "-XX:AOTConfiguration=" + aotConfigFile,
193 "-XX:AOTCache=" + aotCacheFile,
194 "-Xlog:cds=debug",
195 "-cp", appJar);
196 out = CDSTestUtils.executeAndLog(pb, "asm");
197 out.shouldContain("Dumping shared data to file:");
198 out.shouldMatch("cds.*hello[.]aot");
199 out.shouldHaveExitValue(0);
200
201 //----------------------------------------------------------------------
202 printTestCase("One step training run (JEP-JDK-8354330");
203
204 // Set all AOTMode/AOTCacheOutput/AOTConfiguration
205 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
206 "-XX:AOTMode=record",
207 "-XX:AOTCacheOutput=" + aotCacheFile,
208 "-XX:AOTConfiguration=" + aotConfigFile,
209 "-Xlog:cds=debug",
210 "-cp", appJar, helloClass);
211 out = CDSTestUtils.executeAndLog(pb, "ontstep-train");
212 out.shouldContain("Hello World");
213 out.shouldContain("AOTConfiguration recorded: " + aotConfigFile);
214 out.shouldContain("AOTCache creation is complete: hello.aot");
215 out.shouldHaveExitValue(0);
216
217 // Set AOTCacheOutput/AOTConfiguration only; Ergo for: AOTMode=record
218 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
219 "-XX:AOTCacheOutput=" + aotCacheFile,
220 "-XX:AOTConfiguration=" + aotConfigFile,
221 "-Xlog:cds=debug",
222 "-cp", appJar, helloClass);
223 out = CDSTestUtils.executeAndLog(pb, "ontstep-train");
224 out.shouldContain("Hello World");
225 out.shouldContain("AOTConfiguration recorded: " + aotConfigFile);
226 out.shouldContain("AOTCache creation is complete: hello.aot");
227 out.shouldHaveExitValue(0);
228
229 // Set AOTCacheOutput only; Ergo for: AOTMode=record, AOTConfiguration=<temp>
230 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
231 "-XX:AOTCacheOutput=" + aotCacheFile,
232 "-Xlog:cds=debug",
233 "-cp", appJar, helloClass);
234 out = CDSTestUtils.executeAndLog(pb, "ontstep-train");
235 out.shouldContain("Hello World");
236 out.shouldContain("Temporary AOTConfiguration recorded: " + aotCacheFile + ".config");
237 out.shouldContain("AOTCache creation is complete: hello.aot");
238 out.shouldHaveExitValue(0);
239
240 // Quoating of space characters in child JVM process
241 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
242 "-XX:AOTCacheOutput=" + aotCacheFile,
243 "-Dmy.prop=My string -Xshare:off here", // -Xshare:off should not be treated as a single VM opt for the child JVM
244 "-Xlog:cds=debug",
245 "-cp", appJar, helloClass);
246 out = CDSTestUtils.executeAndLog(pb, "ontstep-train");
247 out.shouldContain("Hello World");
248 out.shouldContain("AOTCache creation is complete: hello.aot");
249 out.shouldMatch("Picked up JAVA_TOOL_OPTIONS:.* -Dmy.prop=My' 'string' '-Xshare:off' 'here");
250 out.shouldHaveExitValue(0);
251 }
252
253 static void negativeTests() throws Exception {
254 //----------------------------------------------------------------------
255 printTestCase("Mixing old and new options");
256 String mixOldNewErrSuffix = " cannot be used at the same time with -Xshare:on, -Xshare:auto, "
257 + "-Xshare:off, -Xshare:dump, DumpLoadedClassList, SharedClassListFile, "
258 + "or SharedArchiveFile";
259
260 ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
261 "-Xshare:off",
262 "-XX:AOTConfiguration=" + aotConfigFile,
263 "-cp", appJar, helloClass);
264
265 OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "neg");
266 out.shouldContain("Option AOTConfiguration" + mixOldNewErrSuffix);
267 out.shouldNotHaveExitValue(0);
268
269 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
270 "-XX:SharedArchiveFile=" + aotCacheFile,
271 "-XX:AOTCache=" + aotCacheFile,
272 "-cp", appJar, helloClass);
273 out = CDSTestUtils.executeAndLog(pb, "neg");
274 out.shouldContain("Option AOTCache" + mixOldNewErrSuffix);
275 out.shouldNotHaveExitValue(0);
276
277 //----------------------------------------------------------------------
278 printTestCase("Use AOTConfiguration without AOTMode");
279 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
280 "-XX:AOTConfiguration=" + aotConfigFile,
281 "-cp", appJar, helloClass);
282
283 out = CDSTestUtils.executeAndLog(pb, "neg");
284 out.shouldContain("AOTConfiguration can only be used with -XX:AOTMode=record or -XX:AOTMode=create");
285 out.shouldNotHaveExitValue(0);
286
287 //----------------------------------------------------------------------
288 printTestCase("Use AOTMode without AOTCacheOutput or AOTConfiguration");
289 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
290 "-XX:AOTMode=record",
291 "-cp", appJar, helloClass);
292
293 out = CDSTestUtils.executeAndLog(pb, "neg");
294 out.shouldContain("-XX:AOTMode=record cannot be used without setting AOTCacheOutput or AOTConfiguration");
295
296 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
297 "-XX:AOTMode=create",
298 "-cp", appJar, helloClass);
299
300 out = CDSTestUtils.executeAndLog(pb, "neg");
301 out.shouldContain("-XX:AOTMode=create cannot be used without setting AOTConfiguration");
302 out.shouldNotHaveExitValue(0);
303
304 //----------------------------------------------------------------------
305 printTestCase("Bad AOTMode");
306 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
307 "-XX:AOTMode=foo",
308 "-cp", appJar, helloClass);
309
310 out = CDSTestUtils.executeAndLog(pb, "neg");
311 out.shouldContain("Unrecognized value foo for AOTMode. Must be one of the following: off, record, create, auto, on");
312 out.shouldNotHaveExitValue(0);
313
314 //----------------------------------------------------------------------
315 printTestCase("AOTCache specified with -XX:AOTMode=record");
316 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
317 "-XX:AOTMode=record",
318 "-XX:AOTConfiguration=" + aotConfigFile,
319 "-XX:AOTCache=" + aotCacheFile,
320 "-cp", appJar, helloClass);
321
322 out = CDSTestUtils.executeAndLog(pb, "neg");
323 out.shouldContain("AOTCache must not be specified when using -XX:AOTMode=record");
324 out.shouldNotHaveExitValue(0);
325
326 //----------------------------------------------------------------------
327 printTestCase("AOTCache/AOTCacheOutput not specified with -XX:AOTMode=create");
328 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
329 "-XX:AOTMode=create",
330 "-XX:AOTConfiguration=" + aotConfigFile,
331 "-cp", appJar, helloClass);
332
333 out = CDSTestUtils.executeAndLog(pb, "neg");
334 out.shouldContain("AOTCache or AOTCacheOutput must be specified when using -XX:AOTMode=create");
335 out.shouldNotHaveExitValue(0);
336
337 //----------------------------------------------------------------------
338 printTestCase("AOTCache and AOTCacheOutput have different values");
339 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
340 "-XX:AOTMode=create",
341 "-XX:AOTConfiguration=" + aotConfigFile,
342 "-XX:AOTCache=aaa",
343 "-XX:AOTCacheOutput=bbb",
344 "-cp", appJar, helloClass);
345
346 out = CDSTestUtils.executeAndLog(pb, "neg");
347 out.shouldContain("AOTCache and AOTCacheOutput have different values");
348 out.shouldNotHaveExitValue(0);
349
350 //----------------------------------------------------------------------
351 printTestCase("No such config file");
352 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
353 "-XX:AOTMode=create",
354 "-XX:AOTConfiguration=no-such-file",
355 "-XX:AOTCache=" + aotCacheFile,
356 "-cp", appJar, helloClass);
357
358 out = CDSTestUtils.executeAndLog(pb, "neg");
359 out.shouldContain("Must be a valid AOT configuration generated by the current JVM: no-such-file");
360 out.shouldNotHaveExitValue(0);
361
362 //----------------------------------------------------------------------
363 printTestCase("AOTConfiguration file cannot be used as a CDS archive");
364
365 // first make sure we have a valid aotConfigFile
366 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
367 "-XX:AOTMode=record",
446 "-XX:SharedArchiveFile=" + staticArchive,
447 "-XX:ArchiveClassesAtExit=" + dynamicArchive,
448 "--version");
449 out = CDSTestUtils.executeAndLog(pb, "dynamic");
450 out.shouldHaveExitValue(0);
451
452 pb = ProcessTools.createLimitedTestJavaProcessBuilder(
453 "-Xlog:cds",
454 "-XX:AOTMode=on",
455 "-XX:AOTCache=" + dynamicArchive,
456 "--version");
457
458 out = CDSTestUtils.executeAndLog(pb, "neg");
459 out.shouldContain("Unable to use AOT cache.");
460 out.shouldContain("Not a valid AOT cache (dynamic.jsa)");
461 out.shouldHaveExitValue(1);
462 }
463
464 static int testNum = 0;
465 static void printTestCase(String s) {
466 System.out.println("vvvvvvv TEST CASE " + testNum + ": " + s + ": starts here vvvvvvv");
467 testNum++;
468 }
469 }
|