--- a/test/hotspot/jtreg/runtime/appcds/TestCommon.java Fri Jun 28 18:01:36 2019 +0200
+++ b/test/hotspot/jtreg/runtime/appcds/TestCommon.java Fri Jun 28 09:49:10 2019 -0700
@@ -128,6 +128,10 @@
return createArchive(appJar, classList, suffix);
}
+ public static OutputAnalyzer dump(String appJarDir, String appJar, String classList[],
+ String... suffix) throws Exception {
+ return createArchive(appJarDir, appJar, classList, suffix);
+ }
// Create AppCDS archive using most common args - convenience method
public static OutputAnalyzer createArchive(String appJar, String classList[],
@@ -138,6 +142,15 @@
return createArchive(opts);
}
+ public static OutputAnalyzer createArchive(String appJarDir, String appJar, String classList[],
+ String... suffix) throws Exception {
+ AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar);
+ opts.setAppJarDir(appJarDir);
+ opts.setClassList(classList);
+ opts.addSuffix(suffix);
+ return createArchive(opts);
+ }
+
// Simulate -Xshare:dump with -XX:ArchiveClassesAtExit. See comments around patchJarForDynamicDump()
private static final Class tmp = DynamicDumpHelper.class;
@@ -222,6 +235,9 @@
String[] cmdLine = cmd.toArray(new String[cmd.size()]);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
+ if (opts.appJarDir != null) {
+ pb.directory(new File(opts.appJarDir));
+ }
return executeAndLog(pb, "dump");
}
@@ -360,6 +376,9 @@
String[] cmdLine = cmd.toArray(new String[cmd.size()]);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
+ if (opts.appJarDir != null) {
+ pb.directory(new File(opts.appJarDir));
+ }
return executeAndLog(pb, "exec");
}
@@ -378,6 +397,13 @@
return new Result(opts, runWithArchive(opts));
}
+ public static Result runWithRelativePath(String jarDir, String... suffix) throws Exception {
+ AppCDSOptions opts = (new AppCDSOptions());
+ 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);
opts.addSuffix(suffix);
@@ -443,6 +469,20 @@
return output;
}
+ public static OutputAnalyzer testDump(String appJarDir, String appJar, String classList[],
+ String... suffix) throws Exception {
+ OutputAnalyzer output = dump(appJarDir, appJar, classList, suffix);
+ if (DYNAMIC_DUMP) {
+ if (isUnableToMap(output)) {
+ throw new SkippedException(UnableToMapMsg);
+ }
+ output.shouldContain("Written dynamic archive");
+ } else {
+ output.shouldContain("Loading classes to share");
+ }
+ output.shouldHaveExitValue(0);
+ return output;
+ }
/**
* Simple test -- dump and execute appJar with the given classList in classlist.
@@ -590,4 +630,32 @@
}
}
}
+
+ public static String composeRelPath(String appJar) {
+ int idx = appJar.lastIndexOf(File.separator);
+ String jarName = appJar.substring(idx + 1);
+ String jarDir = appJar.substring(0, idx);
+ String lastDir = jarDir.substring(jarDir.lastIndexOf(File.separator));
+ String relPath = jarDir + File.separator + ".." + File.separator + lastDir;
+ String newJar = relPath + File.separator + jarName;
+ return newJar;
+ }
+
+
+ public static File createSymLink(String appJar) throws Exception {
+ int idx = appJar.lastIndexOf(File.separator);
+ String jarName = appJar.substring(idx + 1);
+ String jarDir = appJar.substring(0, idx);
+ File origJar = new File(jarDir, jarName);
+ String linkedJarName = "linked_" + jarName;
+ File linkedJar = null;
+ if (!Platform.isWindows()) {
+ linkedJar = new File(jarDir, linkedJarName);
+ if (linkedJar.exists()) {
+ linkedJar.delete();
+ }
+ Files.createSymbolicLink(linkedJar.toPath(), origJar.toPath());
+ }
+ return linkedJar;
+ }
}