equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
21 * questions. |
21 * questions. |
22 * |
22 * |
23 */ |
23 */ |
24 |
24 |
25 import jdk.test.lib.Utils; |
25 import jdk.test.lib.Utils; |
|
26 import jdk.test.lib.BuildHelper; |
26 import jdk.test.lib.JDKToolFinder; |
27 import jdk.test.lib.JDKToolFinder; |
27 import jdk.test.lib.Platform; |
28 import jdk.test.lib.Platform; |
28 import jdk.test.lib.cds.CDSOptions; |
29 import jdk.test.lib.cds.CDSOptions; |
29 import jdk.test.lib.cds.CDSTestUtils; |
30 import jdk.test.lib.cds.CDSTestUtils; |
30 import jdk.test.lib.process.ProcessTools; |
31 import jdk.test.lib.process.ProcessTools; |
105 .setAppClasses(appClasses); |
106 .setAppClasses(appClasses); |
106 opts.addSuffix(suffix); |
107 opts.addSuffix(suffix); |
107 return createArchive(opts); |
108 return createArchive(opts); |
108 } |
109 } |
109 |
110 |
|
111 // If you use -XX:+UseAppCDS or -XX:-UseAppCDS in your JVM command-line, call this method |
|
112 // to wrap the arguments. On commercial builds, -XX:+UnlockCommercialFeatures will be |
|
113 // prepended to the command-line. See JDK-8193664. |
|
114 public static String[] makeCommandLineForAppCDS(String... args) throws Exception { |
|
115 if (BuildHelper.isCommercialBuild()) { |
|
116 String[] newArgs = new String[args.length + 1]; |
|
117 newArgs[0] = "-XX:+UnlockCommercialFeatures"; |
|
118 System.arraycopy(args, 0, newArgs, 1, args.length); |
|
119 return newArgs; |
|
120 } else { |
|
121 return args; |
|
122 } |
|
123 } |
110 |
124 |
111 // Create AppCDS archive using appcds options |
125 // Create AppCDS archive using appcds options |
112 public static OutputAnalyzer createArchive(AppCDSOptions opts) |
126 public static OutputAnalyzer createArchive(AppCDSOptions opts) |
113 throws Exception { |
127 throws Exception { |
114 |
128 |
137 cmd.add("-XX:SharedArchiveFile=" + opts.archiveName); |
151 cmd.add("-XX:SharedArchiveFile=" + opts.archiveName); |
138 |
152 |
139 for (String s : opts.suffix) cmd.add(s); |
153 for (String s : opts.suffix) cmd.add(s); |
140 |
154 |
141 String[] cmdLine = cmd.toArray(new String[cmd.size()]); |
155 String[] cmdLine = cmd.toArray(new String[cmd.size()]); |
142 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine); |
156 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine)); |
143 return executeAndLog(pb, "dump"); |
157 return executeAndLog(pb, "dump"); |
144 } |
158 } |
145 |
159 |
146 |
160 |
147 // Execute JVM using AppCDS archive with specified AppCDSOptions |
161 // Execute JVM using AppCDS archive with specified AppCDSOptions |
164 } |
178 } |
165 |
179 |
166 for (String s : opts.suffix) cmd.add(s); |
180 for (String s : opts.suffix) cmd.add(s); |
167 |
181 |
168 String[] cmdLine = cmd.toArray(new String[cmd.size()]); |
182 String[] cmdLine = cmd.toArray(new String[cmd.size()]); |
169 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine); |
183 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine)); |
170 return executeAndLog(pb, "exec"); |
184 return executeAndLog(pb, "exec"); |
171 } |
185 } |
172 |
186 |
173 |
187 |
174 public static OutputAnalyzer execCommon(String... suffix) throws Exception { |
188 public static OutputAnalyzer execCommon(String... suffix) throws Exception { |