8157850: Jar tests should pass through VM options
authoranazarov
Tue, 31 May 2016 16:42:32 -0700
changeset 38762 2956ccc7cb77
parent 38761 e31b47204f64
child 38763 280093905c75
8157850: Jar tests should pass through VM options Reviewed-by: martin
jdk/test/tools/jar/compat/CLICompatibility.java
jdk/test/tools/jar/modularJar/Basic.java
--- a/jdk/test/tools/jar/compat/CLICompatibility.java	Tue May 31 22:41:56 2016 +0000
+++ b/jdk/test/tools/jar/compat/CLICompatibility.java	Tue May 31 16:42:32 2016 -0700
@@ -57,6 +57,8 @@
     static final Path TEST_CLASSES = Paths.get(System.getProperty("test.classes", "."));
     static final Path USER_DIR = Paths.get(System.getProperty("user.dir"));
 
+    static final String TOOL_VM_OPTIONS = System.getProperty("test.tool.vm.opts", "");
+
     final boolean legacyOnly;  // for running on older JDK's ( test validation )
 
     // Resources we know to exist, that can be used for creating jar files.
@@ -501,6 +503,9 @@
         String jar = getJDKTool("jar");
         List<String> commands = new ArrayList<>();
         commands.add(jar);
+        if (!TOOL_VM_OPTIONS.isEmpty()) {
+            commands.addAll(Arrays.asList(TOOL_VM_OPTIONS.split("\\s+", -1)));
+        }
         Stream.of(args).map(s -> s.split(" "))
                        .flatMap(Arrays::stream)
                        .forEach(x -> commands.add(x));
--- a/jdk/test/tools/jar/modularJar/Basic.java	Tue May 31 22:41:56 2016 +0000
+++ b/jdk/test/tools/jar/modularJar/Basic.java	Tue May 31 16:42:32 2016 -0700
@@ -36,11 +36,6 @@
 import java.util.jar.Manifest;
 import java.util.regex.Pattern;
 import java.util.stream.Stream;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import javax.tools.ToolProvider;
 
 import jdk.testlibrary.FileUtils;
 import jdk.testlibrary.JDKToolFinder;
@@ -67,6 +62,10 @@
     static final Path MODULE_CLASSES = TEST_CLASSES.resolve("build");
     static final Path MRJAR_DIR = MODULE_CLASSES.resolve("mrjar");
 
+    static final String VM_OPTIONS = System.getProperty("test.vm.opts", "");
+    static final String TOOL_VM_OPTIONS = System.getProperty("test.tool.vm.opts", "");
+    static final String JAVA_OPTIONS = System.getProperty("test.java.opts", "");
+
     // Details based on the checked in module source
     static TestModuleData FOO = new TestModuleData("foo",
                                                    "1.123",
@@ -730,7 +729,10 @@
         String jar = getJDKTool("jar");
         List<String> commands = new ArrayList<>();
         commands.add(jar);
-        Stream.of(args).forEach(x -> commands.add(x));
+        if (!TOOL_VM_OPTIONS.isEmpty()) {
+            commands.addAll(Arrays.asList(TOOL_VM_OPTIONS.split("\\s+", -1)));
+        }
+        Stream.of(args).forEach(commands::add);
         ProcessBuilder p = new ProcessBuilder(commands);
         if (stdinSource != null)
             p.redirectInput(stdinSource);
@@ -808,6 +810,9 @@
 
         List<String> commands = new ArrayList<>();
         commands.add(javac);
+        if (!TOOL_VM_OPTIONS.isEmpty()) {
+            commands.addAll(Arrays.asList(TOOL_VM_OPTIONS.split("\\s+", -1)));
+        }
         commands.add("-d");
         commands.add(dest.toString());
         if (dest.toString().contains("bar"))
@@ -826,6 +831,12 @@
 
         List<String> commands = new ArrayList<>();
         commands.add(java);
+        if (!VM_OPTIONS.isEmpty()) {
+            commands.addAll(Arrays.asList(VM_OPTIONS.split("\\s+", -1)));
+        }
+        if (!JAVA_OPTIONS.isEmpty()) {
+            commands.addAll(Arrays.asList(JAVA_OPTIONS.split("\\s+", -1)));
+        }
         Stream.of(args).forEach(x -> commands.add(x));
         commands.add("-mp");
         commands.add(modulePath.toString());