Skip to content

Commit

Permalink
8293061: Combine CDSOptions and AppCDSOptions test utility classes
Browse files Browse the repository at this point in the history
Reviewed-by: dholmes, iklam, ccheung
  • Loading branch information
matias9927 authored and coleenp committed Oct 6, 2022
1 parent 73f0646 commit f888aa9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 58 deletions.
42 changes: 0 additions & 42 deletions test/hotspot/jtreg/runtime/cds/appcds/AppCDSOptions.java

This file was deleted.

32 changes: 16 additions & 16 deletions test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ public static OutputAnalyzer dumpBaseArchive(String baseArchiveName, String clas
// Create AppCDS archive using most common args - convenience method
public static OutputAnalyzer createArchive(String appJar, String classList[],
String... suffix) throws Exception {
AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar);
CDSOptions opts = (new CDSOptions()).setAppJar(appJar);
opts.setClassList(classList);
opts.addSuffix(suffix);
return createArchive(opts);
}

public static OutputAnalyzer createArchive(String appJarDir, String appJar, String classList[],
String... suffix) throws Exception {
AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar);
CDSOptions opts = (new CDSOptions()).setAppJar(appJar);
opts.setAppJarDir(appJarDir);
opts.setClassList(classList);
opts.addSuffix(suffix);
Expand Down Expand Up @@ -207,7 +207,7 @@ private static void captureVerifyOpts(ArrayList<String> opts, ArrayList<String>
}

// Create AppCDS archive using appcds options
public static OutputAnalyzer createArchive(AppCDSOptions opts)
public static OutputAnalyzer createArchive(CDSOptions opts)
throws Exception {
ArrayList<String> cmd = new ArrayList<String>();
ArrayList<String> verifyOpts = new ArrayList<String>();
Expand Down Expand Up @@ -407,8 +407,8 @@ private static void patchJarForDynamicDump(String cp) throws Exception {
}
}

// Execute JVM using AppCDS archive with specified AppCDSOptions
public static OutputAnalyzer runWithArchive(AppCDSOptions opts)
// Execute JVM using AppCDS archive with specified CDSOptions
public static OutputAnalyzer runWithArchive(CDSOptions opts)
throws Exception {

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


public static OutputAnalyzer execCommon(String... suffix) throws Exception {
AppCDSOptions opts = (new AppCDSOptions());
CDSOptions opts = (new CDSOptions());
opts.addSuffix(suffix);
return runWithArchive(opts);
}

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

public static Result runWithoutCDS(String... suffix) throws Exception {
AppCDSOptions opts = (new AppCDSOptions());
CDSOptions opts = (new CDSOptions());
opts.addSuffix(suffix).setXShareMode("off");
return new Result(opts, runWithArchive(opts));
}

public static Result runWithRelativePath(String jarDir, String... suffix) throws Exception {
AppCDSOptions opts = (new AppCDSOptions());
CDSOptions opts = (new CDSOptions());
opts.setAppJarDir(jarDir);
opts.addSuffix(suffix);
return new Result(opts, runWithArchive(opts));
}

public static OutputAnalyzer exec(String appJar, String... suffix) throws Exception {
AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar);
CDSOptions opts = (new CDSOptions()).setAppJar(appJar);
opts.addSuffix(suffix);
return runWithArchive(opts);
}

public static Result runWithModules(String prefix[], String upgrademodulepath, String modulepath,
String mid, String... testClassArgs) throws Exception {
AppCDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath,
CDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath,
mid, testClassArgs);
return new Result(opts, runWithArchive(opts));
}

public static OutputAnalyzer execAuto(String... suffix) throws Exception {
AppCDSOptions opts = (new AppCDSOptions());
CDSOptions opts = (new CDSOptions());
opts.addSuffix(suffix).setXShareMode("auto");
return runWithArchive(opts);
}

public static OutputAnalyzer execOff(String... suffix) throws Exception {
AppCDSOptions opts = (new AppCDSOptions());
CDSOptions opts = (new CDSOptions());
opts.addSuffix(suffix).setXShareMode("off");
return runWithArchive(opts);
}


private static AppCDSOptions makeModuleOptions(String prefix[], String upgrademodulepath, String modulepath,
private static CDSOptions makeModuleOptions(String prefix[], String upgrademodulepath, String modulepath,
String mid, String testClassArgs[]) {
AppCDSOptions opts = (new AppCDSOptions());
CDSOptions opts = (new CDSOptions());

opts.addPrefix(prefix);
if (upgrademodulepath == null) {
Expand All @@ -521,7 +521,7 @@ private static AppCDSOptions makeModuleOptions(String prefix[], String upgrademo
public static OutputAnalyzer execModule(String prefix[], String upgrademodulepath, String modulepath,
String mid, String... testClassArgs)
throws Exception {
AppCDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath,
CDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath,
mid, testClassArgs);
return runWithArchive(opts);
}
Expand Down
13 changes: 13 additions & 0 deletions test/lib/jdk/test/lib/cds/CDSOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class CDSOptions {
public ArrayList<String> prefix = new ArrayList<String>();
public ArrayList<String> suffix = new ArrayList<String>();
public boolean useSystemArchive = false;
public String appJar;
public String appJarDir;

// classes to be archived
public String[] classList;
Expand Down Expand Up @@ -105,6 +107,17 @@ public CDSOptions setClassList(ArrayList<String> list) {
return this;
}

// AppCDS methods
public CDSOptions setAppJar(String appJar) {
this.appJar = appJar;
return this;
}

public CDSOptions setAppJarDir(String appJarDir) {
this.appJarDir = appJarDir;
return this;
}

// Call by CDSTestUtils.runWithArchive() and TestCommon.runWithArchive().
//
// Example:
Expand Down

1 comment on commit f888aa9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.