162 int idx = cp.replace('\\', '/').indexOf("/" + jfxrt);
163 if (idx >= 0) {
164 cp = cp.substring(0, idx);
165 idx = cp.lastIndexOf(File.pathSeparator);
166 if (idx >= 0) {
167 cp = cp.substring(idx, cp.length());
168 }
169 return cp;
170 }
171 return null;
172 }
173
174 public static ArrayList<String> createApplicationLaunchCommand(
175 String testAppName,
176 String testPldrName,
177 String testPolicy) throws IOException {
178
179 final String classpath = System.getProperty("java.class.path");
180 final String libraryPath = System.getProperty("java.library.path");
181
182 final String workerJavaCmd = System.getProperty("worker.java.cmd");
183 final Boolean workerDebug = Boolean.getBoolean("worker.debug");
184
185 final ArrayList<String> cmd = new ArrayList<>(30);
186
187 if (workerJavaCmd != null) {
188 cmd.add(workerJavaCmd);
189 } else {
190 cmd.add("java");
191 }
192
193 String jfxdir = getJfxrtDir(classpath);
194 Assert.assertNotNull("failed to find jfxdir",jfxdir);
195 cmd.add("-Xbootclasspath/a:" + jfxdir + "/" + "jfxrt.jar");
196
197 cmd.add("-cp");
198 cmd.add(classpath);
199
200 if (testPldrName != null) {
201 cmd.add("-Djavafx.preloader=" + testPldrName);
202 }
203
204 if (testPolicy != null) {
205 cmd.add("-Djava.security.manager");
206 cmd.add("-Djava.security.policy=" + testPolicy);
207 }
208
209 cmd.add(testAppName);
210
211 if (workerDebug) {
212 System.err.println("Child cmd is");
213 cmd.stream().forEach((s) -> {
214 System.err.println(" " + s);
215 });
216 System.err.println("Child cmd: end");
217 }
218
219 return cmd;
220 }
221 }
|
162 int idx = cp.replace('\\', '/').indexOf("/" + jfxrt);
163 if (idx >= 0) {
164 cp = cp.substring(0, idx);
165 idx = cp.lastIndexOf(File.pathSeparator);
166 if (idx >= 0) {
167 cp = cp.substring(idx, cp.length());
168 }
169 return cp;
170 }
171 return null;
172 }
173
174 public static ArrayList<String> createApplicationLaunchCommand(
175 String testAppName,
176 String testPldrName,
177 String testPolicy) throws IOException {
178
179 final String classpath = System.getProperty("java.class.path");
180 final String libraryPath = System.getProperty("java.library.path");
181
182 /*
183 * note: the "worker" properties are tied into build.gradle and a
184 * the related GradleJUnitWorker as a workaround until the build
185 * is fully converted to a modular build
186 */
187 final Boolean isJDK9 = Boolean.getBoolean("worker.isJDK9");
188 final String workerJavaCmd = System.getProperty("worker.java.cmd");
189 final String workerPatch = System.getProperty("worker.xpatch.dir");
190 final String workerPatchPolicy = System.getProperty("worker.patch.policy");
191 final String workerClassPath = System.getProperty("worker.classpath.file");
192 final Boolean workerDebug = Boolean.getBoolean("worker.debug");
193
194 final ArrayList<String> cmd = new ArrayList<>(30);
195
196 if (workerJavaCmd != null) {
197 cmd.add(workerJavaCmd);
198 } else {
199 cmd.add("java");
200 }
201
202 if (isJDK9 && workerPatch != null) {
203 cmd.add("-Xpatch:" + workerPatch);
204 } else {
205 String jfxdir = getJfxrtDir(classpath);
206 Assert.assertNotNull("failed to find jfxdir",jfxdir);
207 cmd.add("-Djava.ext.dirs=" + jfxdir);
208 }
209
210 // This is a "minimum" set, rather than the full @addExports
211 if (isJDK9) {
212 cmd.add("-XaddExports:javafx.graphics/com.sun.javafx.application=ALL-UNNAMED");
213 }
214
215 if (isJDK9 && libraryPath != null) {
216 // needed for use with Xpatch but not otherwise
217 cmd.add("-Djava.library.path=" + libraryPath);
218 }
219
220 if (isJDK9 && workerClassPath != null) {
221 cmd.add("@" + workerClassPath);
222 } else {
223 cmd.add("-cp");
224 cmd.add(classpath);
225 }
226
227 if (testPldrName != null) {
228 cmd.add("-Djavafx.preloader=" + testPldrName);
229 }
230
231 if (testPolicy != null) {
232
233 cmd.add("-Djava.security.manager");
234
235 try {
236 if (workerPatchPolicy != null) {
237 // with Jake, we need to create a merged java.policy
238 // file that contains the permissions for the Xpatch classes
239 // as well as the permissions needed for this test
240
241 File tempFile = File.createTempFile("java", "policy");
242 tempFile.deleteOnExit();
243
244 File wpp = new File(workerPatchPolicy);
245 if (!wpp.exists()) {
246 throw new RuntimeException("Missing workerPatchPolicy");
247 }
248 BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile));
249
250 BufferedReader reader1 = new BufferedReader(new FileReader(wpp));
251 URL url = new URL(testPolicy);
252 BufferedReader reader2 = new BufferedReader(new FileReader(url.getFile()));
253
254 String line = null;
255 while ((line = reader1.readLine()) != null) {
256 writer.write(line);
257 writer.newLine();
258 }
259 while ((line = reader2.readLine()) != null) {
260 writer.write(line);
261 writer.newLine();
262 }
263 writer.close();
264 cmd.add("-Djava.security.policy=" +
265 tempFile.getAbsolutePath().replaceAll("\\\\","/"));
266 } else {
267 cmd.add("-Djava.security.policy=" + testPolicy);
268 }
269 } catch (IOException e) {
270 throw e;
271 }
272
273 }
274
275 cmd.add(testAppName);
276
277 if (workerDebug) {
278 System.err.println("Child cmd is");
279 cmd.stream().forEach((s) -> {
280 System.err.println(" " + s);
281 });
282 System.err.println("Child cmd: end");
283 }
284
285 return cmd;
286 }
287 }
|