8193664: AppCDS tests should use -XX:+UnlockCommercialFeatures when running with commercial JDK
Reviewed-by: jiangli, mseledtsov, dholmes
--- a/test/hotspot/jtreg/runtime/appcds/TestCommon.java Thu Jan 11 15:38:57 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/TestCommon.java Thu Jan 11 16:40:10 2018 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
*/
import jdk.test.lib.Utils;
+import jdk.test.lib.BuildHelper;
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.Platform;
import jdk.test.lib.cds.CDSOptions;
@@ -107,6 +108,19 @@
return createArchive(opts);
}
+ // If you use -XX:+UseAppCDS or -XX:-UseAppCDS in your JVM command-line, call this method
+ // to wrap the arguments. On commercial builds, -XX:+UnlockCommercialFeatures will be
+ // prepended to the command-line. See JDK-8193664.
+ public static String[] makeCommandLineForAppCDS(String... args) throws Exception {
+ if (BuildHelper.isCommercialBuild()) {
+ String[] newArgs = new String[args.length + 1];
+ newArgs[0] = "-XX:+UnlockCommercialFeatures";
+ System.arraycopy(args, 0, newArgs, 1, args.length);
+ return newArgs;
+ } else {
+ return args;
+ }
+ }
// Create AppCDS archive using appcds options
public static OutputAnalyzer createArchive(AppCDSOptions opts)
@@ -139,7 +153,7 @@
for (String s : opts.suffix) cmd.add(s);
String[] cmdLine = cmd.toArray(new String[cmd.size()]);
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine));
return executeAndLog(pb, "dump");
}
@@ -166,7 +180,7 @@
for (String s : opts.suffix) cmd.add(s);
String[] cmdLine = cmd.toArray(new String[cmd.size()]);
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine));
return executeAndLog(pb, "exec");
}
--- a/test/hotspot/jtreg/runtime/appcds/UseAppCDS.java Thu Jan 11 15:38:57 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/UseAppCDS.java Thu Jan 11 16:40:10 2018 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -122,14 +122,14 @@
static void dumpLoadedClasses(boolean useAppCDS, String[] expectedClasses,
String[] unexpectedClasses) throws Exception {
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
- true,
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
+ TestCommon.makeCommandLineForAppCDS(
"-XX:DumpLoadedClassList=" + CLASSLIST_FILE,
"-cp",
TESTJAR,
useAppCDS ? "-XX:+UseAppCDS" : "-XX:-UseAppCDS",
TESTNAME,
- TEST_OUT);
+ TEST_OUT));
OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-loaded-classes")
.shouldHaveExitValue(0).shouldContain(TEST_OUT);
@@ -152,8 +152,8 @@
static void dumpArchive(boolean useAppCDS, String[] expectedClasses,
String[] unexpectedClasses) throws Exception {
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
- true,
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
+ TestCommon.makeCommandLineForAppCDS(
useAppCDS ? "-XX:-UnlockDiagnosticVMOptions" :
"-XX:+UnlockDiagnosticVMOptions",
"-cp",
@@ -162,7 +162,7 @@
"-XX:SharedClassListFile=" + CLASSLIST_FILE,
"-XX:SharedArchiveFile=" + ARCHIVE_FILE,
"-Xlog:cds",
- "-Xshare:dump");
+ "-Xshare:dump"));
OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-archive")
.shouldHaveExitValue(0);
@@ -179,8 +179,8 @@
static void useArchive(boolean useAppCDS, String[] expectedClasses,
String[] unexpectedClasses) throws Exception {
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
- true,
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
+ TestCommon.makeCommandLineForAppCDS(
useAppCDS ? "-XX:-UnlockDiagnosticVMOptions" :
"-XX:+UnlockDiagnosticVMOptions",
"-cp",
@@ -190,7 +190,7 @@
"-verbose:class",
"-Xshare:on",
TESTNAME,
- TEST_OUT );
+ TEST_OUT));
OutputAnalyzer output = TestCommon.executeAndLog(pb, "use-archive");
if (CDSTestUtils.isUnableToMap(output))
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/SharedStringsBasic.java Thu Jan 11 15:38:57 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/SharedStringsBasic.java Thu Jan 11 16:40:10 2018 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -50,6 +50,7 @@
TestCommon.getSourceFile("SharedStringsBasic.txt").toString();
ProcessBuilder dumpPb = ProcessTools.createJavaProcessBuilder(true,
+ TestCommon.makeCommandLineForAppCDS(
"-XX:+UseAppCDS",
"-XX:+UseCompressedOops",
"-XX:+UseG1GC",
@@ -57,13 +58,14 @@
"-XX:SharedArchiveConfigFile=" + sharedArchiveConfigFile,
"-XX:SharedArchiveFile=./SharedStringsBasic.jsa",
"-Xshare:dump",
- "-Xlog:cds,cds+hashtables");
+ "-Xlog:cds,cds+hashtables"));
TestCommon.executeAndLog(dumpPb, "dump")
.shouldContain("Shared string table stats")
.shouldHaveExitValue(0);
ProcessBuilder runPb = ProcessTools.createJavaProcessBuilder(true,
+ TestCommon.makeCommandLineForAppCDS(
"-XX:+UseAppCDS",
"-XX:+UseCompressedOops",
"-XX:+UseG1GC",
@@ -71,7 +73,7 @@
"-XX:SharedArchiveFile=./SharedStringsBasic.jsa",
"-Xshare:auto",
"-showversion",
- "HelloString");
+ "HelloString"));
TestCommon.executeAndLog(runPb, "run").shouldHaveExitValue(0);
}
--- a/test/hotspot/jtreg/runtime/appcds/sharedStrings/SysDictCrash.java Thu Jan 11 15:38:57 2018 -0800
+++ b/test/hotspot/jtreg/runtime/appcds/sharedStrings/SysDictCrash.java Thu Jan 11 16:40:10 2018 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -42,21 +42,23 @@
// SharedBaseAddress=0 puts the archive at a very high address on solaris,
// which provokes the crash.
ProcessBuilder dumpPb = ProcessTools.createJavaProcessBuilder(true,
+ TestCommon.makeCommandLineForAppCDS(
"-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5",
"-XX:+UseAppCDS",
"-cp", ".",
"-XX:SharedBaseAddress=0", "-XX:SharedArchiveFile=./SysDictCrash.jsa",
"-Xshare:dump",
- "-showversion", "-Xlog:cds,cds+hashtables");
+ "-showversion", "-Xlog:cds,cds+hashtables"));
TestCommon.checkDump(TestCommon.executeAndLog(dumpPb, "dump"));
ProcessBuilder runPb = ProcessTools.createJavaProcessBuilder(true,
+ TestCommon.makeCommandLineForAppCDS(
"-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5",
"-XX:+UseAppCDS",
"-XX:SharedArchiveFile=./SysDictCrash.jsa",
"-Xshare:on",
- "-version");
+ "-version"));
TestCommon.checkExec(TestCommon.executeAndLog(runPb, "exec"));
}