Skip to content

Commit f888aa9

Browse files
matias9927coleenp
authored andcommittedOct 6, 2022
8293061: Combine CDSOptions and AppCDSOptions test utility classes
Reviewed-by: dholmes, iklam, ccheung
1 parent 73f0646 commit f888aa9

File tree

3 files changed

+29
-58
lines changed

3 files changed

+29
-58
lines changed
 

‎test/hotspot/jtreg/runtime/cds/appcds/AppCDSOptions.java

-42
This file was deleted.

‎test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,15 @@ public static OutputAnalyzer dumpBaseArchive(String baseArchiveName, String clas
169169
// Create AppCDS archive using most common args - convenience method
170170
public static OutputAnalyzer createArchive(String appJar, String classList[],
171171
String... suffix) throws Exception {
172-
AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar);
172+
CDSOptions opts = (new CDSOptions()).setAppJar(appJar);
173173
opts.setClassList(classList);
174174
opts.addSuffix(suffix);
175175
return createArchive(opts);
176176
}
177177

178178
public static OutputAnalyzer createArchive(String appJarDir, String appJar, String classList[],
179179
String... suffix) throws Exception {
180-
AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar);
180+
CDSOptions opts = (new CDSOptions()).setAppJar(appJar);
181181
opts.setAppJarDir(appJarDir);
182182
opts.setClassList(classList);
183183
opts.addSuffix(suffix);
@@ -207,7 +207,7 @@ private static void captureVerifyOpts(ArrayList<String> opts, ArrayList<String>
207207
}
208208

209209
// Create AppCDS archive using appcds options
210-
public static OutputAnalyzer createArchive(AppCDSOptions opts)
210+
public static OutputAnalyzer createArchive(CDSOptions opts)
211211
throws Exception {
212212
ArrayList<String> cmd = new ArrayList<String>();
213213
ArrayList<String> verifyOpts = new ArrayList<String>();
@@ -407,8 +407,8 @@ private static void patchJarForDynamicDump(String cp) throws Exception {
407407
}
408408
}
409409

410-
// Execute JVM using AppCDS archive with specified AppCDSOptions
411-
public static OutputAnalyzer runWithArchive(AppCDSOptions opts)
410+
// Execute JVM using AppCDS archive with specified CDSOptions
411+
public static OutputAnalyzer runWithArchive(CDSOptions opts)
412412
throws Exception {
413413

414414
ArrayList<String> cmd = opts.getRuntimePrefix();
@@ -451,61 +451,61 @@ public static OutputAnalyzer runWithArchive(AppCDSOptions opts)
451451

452452

453453
public static OutputAnalyzer execCommon(String... suffix) throws Exception {
454-
AppCDSOptions opts = (new AppCDSOptions());
454+
CDSOptions opts = (new CDSOptions());
455455
opts.addSuffix(suffix);
456456
return runWithArchive(opts);
457457
}
458458

459459
// This is the new API for running a Java process with CDS enabled.
460460
// See comments in the CDSTestUtils.Result class for how to use this method.
461461
public static Result run(String... suffix) throws Exception {
462-
AppCDSOptions opts = (new AppCDSOptions());
462+
CDSOptions opts = (new CDSOptions());
463463
opts.addSuffix(suffix);
464464
return new Result(opts, runWithArchive(opts));
465465
}
466466

467467
public static Result runWithoutCDS(String... suffix) throws Exception {
468-
AppCDSOptions opts = (new AppCDSOptions());
468+
CDSOptions opts = (new CDSOptions());
469469
opts.addSuffix(suffix).setXShareMode("off");
470470
return new Result(opts, runWithArchive(opts));
471471
}
472472

473473
public static Result runWithRelativePath(String jarDir, String... suffix) throws Exception {
474-
AppCDSOptions opts = (new AppCDSOptions());
474+
CDSOptions opts = (new CDSOptions());
475475
opts.setAppJarDir(jarDir);
476476
opts.addSuffix(suffix);
477477
return new Result(opts, runWithArchive(opts));
478478
}
479479

480480
public static OutputAnalyzer exec(String appJar, String... suffix) throws Exception {
481-
AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar);
481+
CDSOptions opts = (new CDSOptions()).setAppJar(appJar);
482482
opts.addSuffix(suffix);
483483
return runWithArchive(opts);
484484
}
485485

486486
public static Result runWithModules(String prefix[], String upgrademodulepath, String modulepath,
487487
String mid, String... testClassArgs) throws Exception {
488-
AppCDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath,
488+
CDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath,
489489
mid, testClassArgs);
490490
return new Result(opts, runWithArchive(opts));
491491
}
492492

493493
public static OutputAnalyzer execAuto(String... suffix) throws Exception {
494-
AppCDSOptions opts = (new AppCDSOptions());
494+
CDSOptions opts = (new CDSOptions());
495495
opts.addSuffix(suffix).setXShareMode("auto");
496496
return runWithArchive(opts);
497497
}
498498

499499
public static OutputAnalyzer execOff(String... suffix) throws Exception {
500-
AppCDSOptions opts = (new AppCDSOptions());
500+
CDSOptions opts = (new CDSOptions());
501501
opts.addSuffix(suffix).setXShareMode("off");
502502
return runWithArchive(opts);
503503
}
504504

505505

506-
private static AppCDSOptions makeModuleOptions(String prefix[], String upgrademodulepath, String modulepath,
506+
private static CDSOptions makeModuleOptions(String prefix[], String upgrademodulepath, String modulepath,
507507
String mid, String testClassArgs[]) {
508-
AppCDSOptions opts = (new AppCDSOptions());
508+
CDSOptions opts = (new CDSOptions());
509509

510510
opts.addPrefix(prefix);
511511
if (upgrademodulepath == null) {
@@ -521,7 +521,7 @@ private static AppCDSOptions makeModuleOptions(String prefix[], String upgrademo
521521
public static OutputAnalyzer execModule(String prefix[], String upgrademodulepath, String modulepath,
522522
String mid, String... testClassArgs)
523523
throws Exception {
524-
AppCDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath,
524+
CDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath,
525525
mid, testClassArgs);
526526
return runWithArchive(opts);
527527
}

‎test/lib/jdk/test/lib/cds/CDSOptions.java

+13
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class CDSOptions {
3232
public ArrayList<String> prefix = new ArrayList<String>();
3333
public ArrayList<String> suffix = new ArrayList<String>();
3434
public boolean useSystemArchive = false;
35+
public String appJar;
36+
public String appJarDir;
3537

3638
// classes to be archived
3739
public String[] classList;
@@ -105,6 +107,17 @@ public CDSOptions setClassList(ArrayList<String> list) {
105107
return this;
106108
}
107109

110+
// AppCDS methods
111+
public CDSOptions setAppJar(String appJar) {
112+
this.appJar = appJar;
113+
return this;
114+
}
115+
116+
public CDSOptions setAppJarDir(String appJarDir) {
117+
this.appJarDir = appJarDir;
118+
return this;
119+
}
120+
108121
// Call by CDSTestUtils.runWithArchive() and TestCommon.runWithArchive().
109122
//
110123
// Example:

0 commit comments

Comments
 (0)
Please sign in to comment.