hotspot/test/runtime/modules/AccessCheck/UmodUpkg_Umod.java
author alanb
Fri, 10 Feb 2017 09:03:55 +0000
changeset 43665 4bb003cad9b9
parent 40631 ed82623d7831
permissions -rw-r--r--
8173393: Module system implementation refresh (2/2017) Reviewed-by: lfoltan, acorn, mchung Contributed-by: alan.bateman@oracle.com, george.triantafillou@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36508
diff changeset
     2
 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * accompanied this code).
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 *
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    23
 * questions.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    24
 */
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    25
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    26
/*
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    27
 * @test
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    28
 * @summary Test public type c5 defined in an unnamed package and unnamed module can
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    29
 *          access public type p6.c6 defined in an unnamed module.
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    30
 * @compile myloaders/MySameClassLoader.java
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    31
 * @compile p6/c6.java
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 * @compile c5.java
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    33
 * @run main/othervm -Xbootclasspath/a:. UmodUpkg_Umod
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    34
 */
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    35
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    36
import myloaders.MySameClassLoader;
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    37
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    38
public class UmodUpkg_Umod {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    39
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    40
    public void testAccess() throws Throwable {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    41
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    42
        Class c5_class = MySameClassLoader.loader1.loadClass("c5");
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    43
        try {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    44
            c5_class.newInstance();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    45
        } catch (IllegalAccessError e) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    46
          System.out.println(e.getMessage());
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    47
              throw new RuntimeException("Test Failed, public type c5 defined in an unnamed package and unnamed "
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    48
                      + "module should be able to access public type c6 defined in an unnamed module");
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    49
        }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    50
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    51
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    52
    public static void main(String args[]) throws Throwable {
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    53
      UmodUpkg_Umod test = new UmodUpkg_Umod();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    54
      test.testAccess();
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    55
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents:
diff changeset
    56
}