1 /* 2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @summary class p3.c3 defined in an unnamed module tries to access c4 defined in an unnamed package 27 * and an unnamed module. 28 * Access allowed since any class in an unnamed module can read an unnamed module. 29 * @compile myloaders/MySameClassLoader.java 30 * @compile c4.java 31 * @compile p3/c3.jcod 32 * @run main/othervm -Xbootclasspath/a:. Umod_UmodUpkg 33 */ 34 35 import myloaders.MySameClassLoader; 36 37 public class Umod_UmodUpkg { 38 39 public void testAccess() throws Throwable { 40 41 Class p3_c3_class = MySameClassLoader.loader1.loadClass("p3.c3"); 42 try { 43 p3_c3_class.newInstance(); 44 } catch (IllegalAccessError e) { 45 System.out.println(e.getMessage()); 46 throw new RuntimeException("Test Failed, public type c3 defined in an unnamed module should be able " + 47 "to access public type c4 defined in an unnamed module"); 48 } 49 } 50 51 public static void main(String args[]) throws Throwable { 52 Umod_UmodUpkg test = new Umod_UmodUpkg(); 53 test.testAccess(); 54 } 55 }