< 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 56282 : [mq]: graal
*** 1,7 ****
/*
! * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 32,41 ****
--- 32,42 ----
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Formatter;
import java.util.List;
import java.util.Map;
+ import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.graalvm.compiler.serviceprovider.JavaVersionUtil;
import org.graalvm.util.CollectionsUtil;
*** 100,109 ****
--- 101,130 ----
}
return result;
}
/**
+ * Gets the command line options to do the same package opening and exporting specified by the
+ * {@code --open-packages} option to the {@code mx unittest} command.
+ *
+ * Properties defined in {@code com.oracle.mxtool.junit.MxJUnitWrapper}.
+ */
+ public static List<String> getPackageOpeningOptions() {
+ List<String> result = new ArrayList<>();
+ String[] actions = {"opens", "exports"};
+ for (String action : actions) {
+ String opens = System.getProperty("com.oracle.mxtool.junit." + action);
+ if (opens != null && !opens.isEmpty()) {
+ for (String value : opens.split(System.lineSeparator())) {
+ result.add("--add-" + action + "=" + value);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
* Gets the command line used to start the current Java VM, including all VM arguments, but not
* including the main class or any Java arguments. This can be used to spawn an identical VM,
* but running different Java code.
*/
public static List<String> getVMCommandLine() {
*** 115,128 ****
return args.subList(0, index);
}
}
/**
! * Detects whether a java agent is attached.
*/
public static boolean isJavaAgentAttached() {
! return SubprocessUtil.getVMCommandLine().stream().anyMatch(args -> args.startsWith("-javaagent"));
}
/**
* The details of a subprocess execution.
*/
--- 136,169 ----
return args.subList(0, index);
}
}
/**
! * Detects whether a Java agent matching {@code agentPredicate} is specified in the VM
! * arguments.
! *
! * @param agentPredicate a predicate that is given the value of a {@code -javaagent} VM argument
! */
! public static boolean isJavaAgentAttached(Predicate<String> agentPredicate) {
! return SubprocessUtil.getVMCommandLine().stream().//
! filter(args -> args.startsWith("-javaagent:")).//
! map(s -> s.substring("-javaagent:".length())).//
! anyMatch(agentPredicate);
! }
!
! /**
! * Detects whether a Java agent is specified in the VM arguments.
*/
public static boolean isJavaAgentAttached() {
! return isJavaAgentAttached(javaAgentValue -> true);
! }
!
! /**
! * Detects whether the JaCoCo Java agent is specified in the VM arguments.
! */
! public static boolean isJaCoCoAttached() {
! return isJavaAgentAttached(s -> s.toLowerCase().contains("jacoco"));
}
/**
* The details of a subprocess execution.
*/
*** 276,286 ****
--- 317,331 ----
int i = 1; // Skip the java executable
while (i < commandLine.size()) {
String s = commandLine.get(i);
if (s.charAt(0) != '-') {
+ // https://bugs.openjdk.java.net/browse/JDK-8027634
+ if (isJava8OrEarlier || s.charAt(0) != '@') {
return i;
+ }
+ i++;
} else if (hasArg(s)) {
i += 2;
} else {
i++;
}
< prev index next >