equal
deleted
inserted
replaced
34 import java.util.jar.JarEntry; |
34 import java.util.jar.JarEntry; |
35 import java.util.jar.JarInputStream; |
35 import java.util.jar.JarInputStream; |
36 import java.util.jar.Manifest; |
36 import java.util.jar.Manifest; |
37 import java.util.regex.Pattern; |
37 import java.util.regex.Pattern; |
38 import java.util.stream.Stream; |
38 import java.util.stream.Stream; |
39 import javax.tools.JavaCompiler; |
|
40 import javax.tools.JavaFileObject; |
|
41 import javax.tools.StandardJavaFileManager; |
|
42 import javax.tools.StandardLocation; |
|
43 import javax.tools.ToolProvider; |
|
44 |
39 |
45 import jdk.testlibrary.FileUtils; |
40 import jdk.testlibrary.FileUtils; |
46 import jdk.testlibrary.JDKToolFinder; |
41 import jdk.testlibrary.JDKToolFinder; |
47 import org.testng.annotations.BeforeTest; |
42 import org.testng.annotations.BeforeTest; |
48 import org.testng.annotations.Test; |
43 import org.testng.annotations.Test; |
64 public class Basic { |
59 public class Basic { |
65 static final Path TEST_SRC = Paths.get(System.getProperty("test.src", ".")); |
60 static final Path TEST_SRC = Paths.get(System.getProperty("test.src", ".")); |
66 static final Path TEST_CLASSES = Paths.get(System.getProperty("test.classes", ".")); |
61 static final Path TEST_CLASSES = Paths.get(System.getProperty("test.classes", ".")); |
67 static final Path MODULE_CLASSES = TEST_CLASSES.resolve("build"); |
62 static final Path MODULE_CLASSES = TEST_CLASSES.resolve("build"); |
68 static final Path MRJAR_DIR = MODULE_CLASSES.resolve("mrjar"); |
63 static final Path MRJAR_DIR = MODULE_CLASSES.resolve("mrjar"); |
|
64 |
|
65 static final String VM_OPTIONS = System.getProperty("test.vm.opts", ""); |
|
66 static final String TOOL_VM_OPTIONS = System.getProperty("test.tool.vm.opts", ""); |
|
67 static final String JAVA_OPTIONS = System.getProperty("test.java.opts", ""); |
69 |
68 |
70 // Details based on the checked in module source |
69 // Details based on the checked in module source |
71 static TestModuleData FOO = new TestModuleData("foo", |
70 static TestModuleData FOO = new TestModuleData("foo", |
72 "1.123", |
71 "1.123", |
73 "jdk.test.foo.Foo", |
72 "jdk.test.foo.Foo", |
728 |
727 |
729 static Result jarWithStdin(File stdinSource, String... args) { |
728 static Result jarWithStdin(File stdinSource, String... args) { |
730 String jar = getJDKTool("jar"); |
729 String jar = getJDKTool("jar"); |
731 List<String> commands = new ArrayList<>(); |
730 List<String> commands = new ArrayList<>(); |
732 commands.add(jar); |
731 commands.add(jar); |
733 Stream.of(args).forEach(x -> commands.add(x)); |
732 if (!TOOL_VM_OPTIONS.isEmpty()) { |
|
733 commands.addAll(Arrays.asList(TOOL_VM_OPTIONS.split("\\s+", -1))); |
|
734 } |
|
735 Stream.of(args).forEach(commands::add); |
734 ProcessBuilder p = new ProcessBuilder(commands); |
736 ProcessBuilder p = new ProcessBuilder(commands); |
735 if (stdinSource != null) |
737 if (stdinSource != null) |
736 p.redirectInput(stdinSource); |
738 p.redirectInput(stdinSource); |
737 return run(p); |
739 return run(p); |
738 } |
740 } |
806 { |
808 { |
807 String javac = getJDKTool("javac"); |
809 String javac = getJDKTool("javac"); |
808 |
810 |
809 List<String> commands = new ArrayList<>(); |
811 List<String> commands = new ArrayList<>(); |
810 commands.add(javac); |
812 commands.add(javac); |
|
813 if (!TOOL_VM_OPTIONS.isEmpty()) { |
|
814 commands.addAll(Arrays.asList(TOOL_VM_OPTIONS.split("\\s+", -1))); |
|
815 } |
811 commands.add("-d"); |
816 commands.add("-d"); |
812 commands.add(dest.toString()); |
817 commands.add(dest.toString()); |
813 if (dest.toString().contains("bar")) |
818 if (dest.toString().contains("bar")) |
814 commands.add("-XaddExports:java.base/jdk.internal.module=bar"); |
819 commands.add("-XaddExports:java.base/jdk.internal.module=bar"); |
815 if (modulePath != null) { |
820 if (modulePath != null) { |
824 static Result java(Path modulePath, String entryPoint, String... args) { |
829 static Result java(Path modulePath, String entryPoint, String... args) { |
825 String java = getJDKTool("java"); |
830 String java = getJDKTool("java"); |
826 |
831 |
827 List<String> commands = new ArrayList<>(); |
832 List<String> commands = new ArrayList<>(); |
828 commands.add(java); |
833 commands.add(java); |
|
834 if (!VM_OPTIONS.isEmpty()) { |
|
835 commands.addAll(Arrays.asList(VM_OPTIONS.split("\\s+", -1))); |
|
836 } |
|
837 if (!JAVA_OPTIONS.isEmpty()) { |
|
838 commands.addAll(Arrays.asList(JAVA_OPTIONS.split("\\s+", -1))); |
|
839 } |
829 Stream.of(args).forEach(x -> commands.add(x)); |
840 Stream.of(args).forEach(x -> commands.add(x)); |
830 commands.add("-mp"); |
841 commands.add("-mp"); |
831 commands.add(modulePath.toString()); |
842 commands.add(modulePath.toString()); |
832 commands.add("-m"); |
843 commands.add("-m"); |
833 commands.add(entryPoint); |
844 commands.add(entryPoint); |