< prev index next >
test/runtime/modules/Visibility/PatchModuleVisibility.java
Print this page
*** 21,46 ****
* questions.
*/
/*
* @test
! * @summary Ensure that a newly introduced java.base package placed within the -Xpatch directory
! * is considered part of the boot loader's visibility boundary
* @requires !(os.family == "windows")
* @library /testlibrary
* @modules java.base/jdk.internal.misc
* java.management
! * @run main/othervm XpatchVisibility
*/
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import jdk.test.lib.*;
! public class XpatchVisibility {
public static void main(String[] args) throws Throwable {
String Vis2_B_src =
"package p2;" +
--- 21,46 ----
* questions.
*/
/*
* @test
! * @summary Ensure that a newly introduced java.base package placed within the --patch-module
! * directory is considered part of the boot loader's visibility boundary
* @requires !(os.family == "windows")
* @library /testlibrary
* @modules java.base/jdk.internal.misc
* java.management
! * @run main/othervm PatchModuleVisibility
*/
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import jdk.test.lib.*;
! public class PatchModuleVisibility {
public static void main(String[] args) throws Throwable {
String Vis2_B_src =
"package p2;" +
*** 53,75 ****
String Vis2_A_src =
"import p2.*;" +
"public class Vis2_A {" +
" public static void main(String args[]) throws Exception {" +
// Try loading a class within a newly introduced java.base
! // package. Make sure the class can be found via -Xpatch.
" try {" +
" p2.Vis2_B b = new p2.Vis2_B();" +
" if (b.getClass().getClassLoader() != null) {" +
! " throw new RuntimeException(\"XpatchVisibility FAILED - class B " +
"should be loaded by boot class loader\\n\");" +
" }" +
" b.m();" +
" } catch (Throwable e) {" +
! " throw new RuntimeException(\"XpatchVisibility FAILED - test " +
"should not throw an error or exception\\n\");" +
" }" +
! " System.out.println(\"XpatchVisibility PASSED\\n\");" +
" }" +
"}";
ClassFileInstaller.writeClassToDisk("p2/Vis2_B",
InMemoryJavaCompiler.compile("p2.Vis2_B", Vis2_B_src), System.getProperty("test.classes"));
--- 53,75 ----
String Vis2_A_src =
"import p2.*;" +
"public class Vis2_A {" +
" public static void main(String args[]) throws Exception {" +
// Try loading a class within a newly introduced java.base
! // package. Make sure the class can be found via --patch-module.
" try {" +
" p2.Vis2_B b = new p2.Vis2_B();" +
" if (b.getClass().getClassLoader() != null) {" +
! " throw new RuntimeException(\"PatchModuleVisibility FAILED - class B " +
"should be loaded by boot class loader\\n\");" +
" }" +
" b.m();" +
" } catch (Throwable e) {" +
! " throw new RuntimeException(\"PatchModuleVisibility FAILED - test " +
"should not throw an error or exception\\n\");" +
" }" +
! " System.out.println(\"PatchModuleVisibility PASSED\\n\");" +
" }" +
"}";
ClassFileInstaller.writeClassToDisk("p2/Vis2_B",
InMemoryJavaCompiler.compile("p2.Vis2_B", Vis2_B_src), System.getProperty("test.classes"));
*** 81,91 ****
// Make sure the classes are actually being loaded from mods2
Files.delete(Paths.get(System.getProperty("test.classes") + File.separator +
"p2" + File.separator + "Vis2_B.class"));
new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(
! "-Xpatch:java.base=mods2/java.base",
! "-XaddExports:java.base/p2=ALL-UNNAMED",
"Vis2_A")
.start()).shouldHaveExitValue(0);
}
}
--- 81,91 ----
// Make sure the classes are actually being loaded from mods2
Files.delete(Paths.get(System.getProperty("test.classes") + File.separator +
"p2" + File.separator + "Vis2_B.class"));
new OutputAnalyzer(ProcessTools.createJavaProcessBuilder(
! "--patch-module=java.base=mods2/java.base",
! "--add-exports=java.base/p2=ALL-UNNAMED",
"Vis2_A")
.start()).shouldHaveExitValue(0);
}
}
< prev index next >