76
77 // the classes overridden or added with --patch-module
78 private static final String[] CLASSES = {
79
80 // java.base = boot loader
81 "java.base/java.text.Annotation", // override class
82 "java.base/java.text.AnnotationBuddy", // add class to package
83 "java.base/java.lang2.Object", // new package
84
85 };
86
87
88 @BeforeTest
89 public void setup() throws Exception {
90
91 // javac -d mods/test src/test/**
92 boolean compiled= CompilerUtils.compile(SRC_DIR.resolve("test"),
93 MODS_DIR.resolve("test"));
94 assertTrue(compiled, "classes did not compile");
95
96 // javac -Xmodule:$MODULE -d patches1/$MODULE patches1/$MODULE/**
97 Path src = SRC1_DIR.resolve("java.base");
98 Path output = PATCHES1_DIR.resolve(src.getFileName());
99 Files.createDirectories(output);
100 String mn = src.getFileName().toString();
101 compiled = CompilerUtils.compile(src, output, "-Xmodule:" + mn);
102 assertTrue(compiled, "classes did not compile");
103
104 // javac -Xmodule:$MODULE -d patches2/$MODULE patches2/$MODULE/**
105 src = SRC2_DIR.resolve("java.base");
106 output = PATCHES2_DIR.resolve(src.getFileName());
107 Files.createDirectories(output);
108 mn = src.getFileName().toString();
109 compiled = CompilerUtils.compile(src, output, "-Xmodule:" + mn);
110 assertTrue(compiled, "classes did not compile");
111
112 }
113
114 /**
115 * Test with --patch-module options patching the same module
116 */
117 public void testDuplicateModule() throws Exception {
118 int exitValue =
119 executeTestJava("--patch-module", "java.base=" + PATCHES1_DIR.resolve("java.base"),
120 "--patch-module", "java.base=" + PATCHES2_DIR.resolve("java.base"),
121 "--module-path", MODS_DIR.toString(),
122 "-m", "test/jdk.test.Main")
123 .outputTo(System.out)
124 .errorTo(System.out)
125 // error output by VM
126 .shouldContain("Cannot specify java.base more than once to --patch-module")
127 .getExitValue();
128
129 assertTrue(exitValue != 0);
|
76
77 // the classes overridden or added with --patch-module
78 private static final String[] CLASSES = {
79
80 // java.base = boot loader
81 "java.base/java.text.Annotation", // override class
82 "java.base/java.text.AnnotationBuddy", // add class to package
83 "java.base/java.lang2.Object", // new package
84
85 };
86
87
88 @BeforeTest
89 public void setup() throws Exception {
90
91 // javac -d mods/test src/test/**
92 boolean compiled= CompilerUtils.compile(SRC_DIR.resolve("test"),
93 MODS_DIR.resolve("test"));
94 assertTrue(compiled, "classes did not compile");
95
96 // javac --patch-module $MODULE=patches1/$MODULE -d patches1/$MODULE patches1/$MODULE/**
97 Path src = SRC1_DIR.resolve("java.base");
98 Path output = PATCHES1_DIR.resolve(src.getFileName());
99 Files.createDirectories(output);
100 String mn = src.getFileName().toString();
101 compiled = CompilerUtils.compile(src, output,
102 "--patch-module", mn + "=" + src.toString());
103 assertTrue(compiled, "classes did not compile");
104
105 // javac --patch-module $MODULE=patches2/$MODULE -d patches2/$MODULE patches2/$MODULE/**
106 src = SRC2_DIR.resolve("java.base");
107 output = PATCHES2_DIR.resolve(src.getFileName());
108 Files.createDirectories(output);
109 mn = src.getFileName().toString();
110 compiled = CompilerUtils.compile(src, output,
111 "--patch-module", mn + "=" + src.toString());
112 assertTrue(compiled, "classes did not compile");
113
114 }
115
116 /**
117 * Test with --patch-module options patching the same module
118 */
119 public void testDuplicateModule() throws Exception {
120 int exitValue =
121 executeTestJava("--patch-module", "java.base=" + PATCHES1_DIR.resolve("java.base"),
122 "--patch-module", "java.base=" + PATCHES2_DIR.resolve("java.base"),
123 "--module-path", MODS_DIR.toString(),
124 "-m", "test/jdk.test.Main")
125 .outputTo(System.out)
126 .errorTo(System.out)
127 // error output by VM
128 .shouldContain("Cannot specify java.base more than once to --patch-module")
129 .getExitValue();
130
131 assertTrue(exitValue != 0);
|