< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.test/src/org/graalvm/compiler/test/SubprocessUtil.java

Print this page
rev 52509 : [mq]: graal


  97         }
  98         return result;
  99     }
 100 
 101     /**
 102      * Gets the command line used to start the current Java VM, including all VM arguments, but not
 103      * including the main class or any Java arguments. This can be used to spawn an identical VM,
 104      * but running different Java code.
 105      */
 106     public static List<String> getVMCommandLine() {
 107         List<String> args = getProcessCommandLine();
 108         if (args == null) {
 109             return null;
 110         } else {
 111             int index = findMainClassIndex(args);
 112             return args.subList(0, index);
 113         }
 114     }
 115 
 116     /**







 117      * The details of a subprocess execution.
 118      */
 119     public static class Subprocess {
 120 
 121         /**
 122          * The command line of the subprocess.
 123          */
 124         public final List<String> command;
 125 
 126         /**
 127          * Exit code of the subprocess.
 128          */
 129         public final int exitCode;
 130 
 131         /**
 132          * Output from the subprocess broken into lines.
 133          */
 134         public final List<String> output;
 135 
 136         public Subprocess(List<String> command, int exitCode, List<String> output) {




  97         }
  98         return result;
  99     }
 100 
 101     /**
 102      * Gets the command line used to start the current Java VM, including all VM arguments, but not
 103      * including the main class or any Java arguments. This can be used to spawn an identical VM,
 104      * but running different Java code.
 105      */
 106     public static List<String> getVMCommandLine() {
 107         List<String> args = getProcessCommandLine();
 108         if (args == null) {
 109             return null;
 110         } else {
 111             int index = findMainClassIndex(args);
 112             return args.subList(0, index);
 113         }
 114     }
 115 
 116     /**
 117      * Detects whether a java agent is attached.
 118      */
 119     public static boolean isJavaAgentAttached() {
 120         return SubprocessUtil.getVMCommandLine().stream().anyMatch(args -> args.startsWith("-javaagent"));
 121     }
 122 
 123     /**
 124      * The details of a subprocess execution.
 125      */
 126     public static class Subprocess {
 127 
 128         /**
 129          * The command line of the subprocess.
 130          */
 131         public final List<String> command;
 132 
 133         /**
 134          * Exit code of the subprocess.
 135          */
 136         public final int exitCode;
 137 
 138         /**
 139          * Output from the subprocess broken into lines.
 140          */
 141         public final List<String> output;
 142 
 143         public Subprocess(List<String> command, int exitCode, List<String> output) {


< prev index next >