47 */ 48 49 public class ProxyClassAccessTest { 50 51 private static final String TEST_SRC = System.getProperty("test.src"); 52 private static final String TEST_CLASSES = System.getProperty("test.classes"); 53 54 private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); 55 private static final Path MODS_DIR = Paths.get("mods"); 56 57 // the names of the modules in this test 58 private static List<String> modules = Arrays.asList("m1", "m2", "m3", "test"); 59 60 /** 61 * Compiles all modules used by the test 62 */ 63 @BeforeTest 64 public void compileAll() throws Exception { 65 for (String mn : modules) { 66 Path msrc = SRC_DIR.resolve(mn); 67 assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "-modulesourcepath", SRC_DIR.toString())); 68 } 69 } 70 71 /** 72 * Run the modular test 73 */ 74 @Test 75 public void runTest() throws Exception { 76 int exitValue = executeTestJava("-mp", MODS_DIR.toString(), 77 "-m", "test/jdk.test.ProxyClassAccess") 78 .outputTo(System.out) 79 .errorTo(System.out) 80 .getExitValue(); 81 82 assertTrue(exitValue == 0); 83 } 84 85 /** 86 * Test unnamed module has no access to other proxy interface 87 */ 88 @Test 89 public void testNoReadAccess() throws Exception { 90 ModuleFinder finder = ModuleFinder.of(MODS_DIR); 91 Layer bootLayer = Layer.boot(); 92 Configuration cf = bootLayer 93 .configuration() 94 .resolveRequiresAndUses(ModuleFinder.of(), finder, modules); 95 ClassLoader parentLoader = this.getClass().getClassLoader(); 96 Layer layer = bootLayer.defineModulesWithOneLoader(cf, parentLoader); | 47 */ 48 49 public class ProxyClassAccessTest { 50 51 private static final String TEST_SRC = System.getProperty("test.src"); 52 private static final String TEST_CLASSES = System.getProperty("test.classes"); 53 54 private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); 55 private static final Path MODS_DIR = Paths.get("mods"); 56 57 // the names of the modules in this test 58 private static List<String> modules = Arrays.asList("m1", "m2", "m3", "test"); 59 60 /** 61 * Compiles all modules used by the test 62 */ 63 @BeforeTest 64 public void compileAll() throws Exception { 65 for (String mn : modules) { 66 Path msrc = SRC_DIR.resolve(mn); 67 assertTrue(CompilerUtils.compile(msrc, MODS_DIR, "--module-source-path", SRC_DIR.toString())); 68 } 69 } 70 71 /** 72 * Run the modular test 73 */ 74 @Test 75 public void runTest() throws Exception { 76 int exitValue = executeTestJava("--module-path", MODS_DIR.toString(), 77 "-m", "test/jdk.test.ProxyClassAccess") 78 .outputTo(System.out) 79 .errorTo(System.out) 80 .getExitValue(); 81 82 assertTrue(exitValue == 0); 83 } 84 85 /** 86 * Test unnamed module has no access to other proxy interface 87 */ 88 @Test 89 public void testNoReadAccess() throws Exception { 90 ModuleFinder finder = ModuleFinder.of(MODS_DIR); 91 Layer bootLayer = Layer.boot(); 92 Configuration cf = bootLayer 93 .configuration() 94 .resolveRequiresAndUses(ModuleFinder.of(), finder, modules); 95 ClassLoader parentLoader = this.getClass().getClassLoader(); 96 Layer layer = bootLayer.defineModulesWithOneLoader(cf, parentLoader); |