--- old/test/hotspot/jtreg/runtime/appcds/TestCommon.java 2018-01-10 20:36:18.856119087 -0800 +++ new/test/hotspot/jtreg/runtime/appcds/TestCommon.java 2018-01-10 20:36:18.440103260 -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"); }