--- old/test/testlibrary/jdk/test/lib/ProcessTools.java 2015-10-21 17:06:45.698830783 +0300 +++ new/test/testlibrary/jdk/test/lib/ProcessTools.java 2015-10-21 17:06:45.634830782 +0300 @@ -39,7 +39,7 @@ /** * Pumps stdout and stderr from running the process into a String. * - * @param processHandler ProcessHandler to run. + * @param processBuilder ProcessBuilder to run. * @return Output from process. * @throws IOException If an I/O error occurs. */ @@ -109,6 +109,17 @@ } /** + * Gets the array of strings containing input arguments passed to the VM + * + * @return arguments + */ + public static String[] getVmInputArgs() { + RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); + List args = runtime.getInputArguments(); + return args.toArray(new String[args.size()]); + } + + /** * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris) * * @return String[] with platform specific arguments, empty if there are none @@ -172,6 +183,26 @@ return executeProcess(pb); } + /** + * Executes a test jvm process, waits for it to finish and returns the process output. + * The default jvm options from the test's run command, jtreg, test.vm.opts and test.java.opts, are added. + * The java from the test.jdk is used to execute the command. + * + * The command line will be like: + * {test.jdk}/bin/java {test.fromRun.opts} {test.vm.opts} {test.java.opts} cmds + * + * @param cmds User specifed arguments. + * @return The output from the process. + */ + public static OutputAnalyzer executeTestJvmAllArgs(String... cmds) throws Throwable { + List argsList = new ArrayList<>(); + String[] testArgs = getVmInputArgs(); + Collections.addAll(argsList, testArgs); + Collections.addAll(argsList, Utils.addTestJavaOpts(cmds)); + ProcessBuilder pb = createJavaProcessBuilder(argsList.toArray(new String[argsList.size()])); + return executeProcess(pb); + } + /** * Executes a process, waits for it to finish and returns the process output. * The process will have exited before this method returns.