UmodUpkg_Umod.java revision 10420:c558850fac57
10Sstevel@tonic-gate/* 20Sstevel@tonic-gate * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 30Sstevel@tonic-gate * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 40Sstevel@tonic-gate * 50Sstevel@tonic-gate * This code is free software; you can redistribute it and/or modify it 60Sstevel@tonic-gate * under the terms of the GNU General Public License version 2 only, as 70Sstevel@tonic-gate * published by the Free Software Foundation. Oracle designates this 80Sstevel@tonic-gate * particular file as subject to the "Classpath" exception as provided 90Sstevel@tonic-gate * by Oracle in the LICENSE file that accompanied this code. 100Sstevel@tonic-gate * 110Sstevel@tonic-gate * This code is distributed in the hope that it will be useful, but WITHOUT 120Sstevel@tonic-gate * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 130Sstevel@tonic-gate * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 140Sstevel@tonic-gate * version 2 for more details (a copy is included in the LICENSE file that 150Sstevel@tonic-gate * accompanied this code). 160Sstevel@tonic-gate * 170Sstevel@tonic-gate * You should have received a copy of the GNU General Public License version 180Sstevel@tonic-gate * 2 along with this work; if not, write to the Free Software Foundation, 190Sstevel@tonic-gate * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 200Sstevel@tonic-gate * 210Sstevel@tonic-gate * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 220Sstevel@tonic-gate * or visit www.oracle.com if you need additional information or have any 230Sstevel@tonic-gate * questions. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate/* 270Sstevel@tonic-gate * @test 280Sstevel@tonic-gate * @summary Test public type c5 defined in an unnamed package and unnamed module can 290Sstevel@tonic-gate * access public type p6.c6 defined in an unnamed module. 300Sstevel@tonic-gate * @compile myloaders/MySameClassLoader.java 310Sstevel@tonic-gate * @compile p6/c6.java 320Sstevel@tonic-gate * @compile c5.java 330Sstevel@tonic-gate * @build UmodUpkg_Umod 340Sstevel@tonic-gate * @run main/othervm -Xbootclasspath/a:. UmodUpkg_Umod 350Sstevel@tonic-gate */ 360Sstevel@tonic-gate 370Sstevel@tonic-gateimport myloaders.MySameClassLoader; 380Sstevel@tonic-gate 390Sstevel@tonic-gatepublic class UmodUpkg_Umod { 400Sstevel@tonic-gate 410Sstevel@tonic-gate public void testAccess() throws Throwable { 420Sstevel@tonic-gate 430Sstevel@tonic-gate Class c5_class = MySameClassLoader.loader1.loadClass("c5"); 440Sstevel@tonic-gate try { 450Sstevel@tonic-gate c5_class.newInstance(); 460Sstevel@tonic-gate } catch (IllegalAccessError e) { 470Sstevel@tonic-gate System.out.println(e.getMessage()); 480Sstevel@tonic-gate throw new RuntimeException("Test Failed, public type c5 defined in an unnamed package and unnamed " 490Sstevel@tonic-gate + "module should be able to access public type c6 defined in an unnamed module"); 500Sstevel@tonic-gate } 510Sstevel@tonic-gate } 520Sstevel@tonic-gate 530Sstevel@tonic-gate public static void main(String args[]) throws Throwable { 540Sstevel@tonic-gate UmodUpkg_Umod test = new UmodUpkg_Umod(); 550Sstevel@tonic-gate test.testAccess(); 560Sstevel@tonic-gate } 570Sstevel@tonic-gate} 580Sstevel@tonic-gate