1 /*
2 * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
410 System.out.println("firstJar = " + firstJar);
411 }
412 }
413
414 // Execute JVM using AppCDS archive with specified CDSOptions
415 public static OutputAnalyzer runWithArchive(CDSOptions opts)
416 throws Exception {
417
418 ArrayList<String> cmd = new ArrayList<String>();
419 cmd.addAll(opts.prefix);
420 cmd.add("-Xshare:" + opts.xShareMode);
421 cmd.add("-showversion");
422 cmd.add("-XX:SharedArchiveFile=" + getCurrentArchiveName());
423 cmd.add("-Dtest.timeout.factor=" + timeoutFactor);
424
425 if (opts.appJar != null) {
426 cmd.add("-cp");
427 cmd.add(opts.appJar);
428 }
429
430 CDSTestUtils.addVerifyArchivedFields(cmd);
431
432 for (String s : opts.suffix) cmd.add(s);
433
434 if (RUN_WITH_JFR) {
435 boolean usesJFR = false;
436 for (String s : cmd) {
437 if (s.startsWith("-XX:StartFlightRecording") || s.startsWith("-XX:FlightRecorderOptions")) {
438 System.out.println("JFR option might have been specified. Don't interfere: " + s);
439 usesJFR = true;
440 break;
441 }
442 }
443 if (!usesJFR) {
444 System.out.println("JFR option not specified. Enabling JFR ...");
445 cmd.add(0, "-XX:StartFlightRecording:dumponexit=true");
446 System.out.println(cmd);
447 }
448 }
449
450 ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(cmd);
451 if (opts.appJarDir != null) {
|
1 /*
2 * Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
410 System.out.println("firstJar = " + firstJar);
411 }
412 }
413
414 // Execute JVM using AppCDS archive with specified CDSOptions
415 public static OutputAnalyzer runWithArchive(CDSOptions opts)
416 throws Exception {
417
418 ArrayList<String> cmd = new ArrayList<String>();
419 cmd.addAll(opts.prefix);
420 cmd.add("-Xshare:" + opts.xShareMode);
421 cmd.add("-showversion");
422 cmd.add("-XX:SharedArchiveFile=" + getCurrentArchiveName());
423 cmd.add("-Dtest.timeout.factor=" + timeoutFactor);
424
425 if (opts.appJar != null) {
426 cmd.add("-cp");
427 cmd.add(opts.appJar);
428 }
429
430 for (String s : opts.suffix) cmd.add(s);
431
432 if (RUN_WITH_JFR) {
433 boolean usesJFR = false;
434 for (String s : cmd) {
435 if (s.startsWith("-XX:StartFlightRecording") || s.startsWith("-XX:FlightRecorderOptions")) {
436 System.out.println("JFR option might have been specified. Don't interfere: " + s);
437 usesJFR = true;
438 break;
439 }
440 }
441 if (!usesJFR) {
442 System.out.println("JFR option not specified. Enabling JFR ...");
443 cmd.add(0, "-XX:StartFlightRecording:dumponexit=true");
444 System.out.println(cmd);
445 }
446 }
447
448 ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(cmd);
449 if (opts.appJarDir != null) {
|