hotspot/test/runtime/modules/AccessCheckSuper.java
changeset 43665 4bb003cad9b9
parent 40631 ed82623d7831
child 44520 0553e129e0ec
equal deleted inserted replaced
43606:a5aa7536131c 43665:4bb003cad9b9
     1 /*
     1 /*
     2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    46         // Get the class loader for AccessCheckSuper and assume it's also used to
    46         // Get the class loader for AccessCheckSuper and assume it's also used to
    47         // load class p2.c2 and class p3.c3.
    47         // load class p2.c2 and class p3.c3.
    48         ClassLoader this_cldr = AccessCheckSuper.class.getClassLoader();
    48         ClassLoader this_cldr = AccessCheckSuper.class.getClassLoader();
    49 
    49 
    50         // Define a module for p2.
    50         // Define a module for p2.
    51         Object m2 = ModuleHelper.ModuleObject("module2", this_cldr, new String[] { "p2" });
    51         Object m2x = ModuleHelper.ModuleObject("module_two", this_cldr, new String[] { "p2" });
    52         assertNotNull(m2, "Module should not be null");
    52         assertNotNull(m2x, "Module should not be null");
    53         ModuleHelper.DefineModule(m2, "9.0", "m2/there", new String[] { "p2" });
    53         ModuleHelper.DefineModule(m2x, "9.0", "m2x/there", new String[] { "p2" });
    54 
    54 
    55         // Define a module for p3.
    55         // Define a module for p3.
    56         Object m3 = ModuleHelper.ModuleObject("module3", this_cldr, new String[] { "p3" });
    56         Object m3x = ModuleHelper.ModuleObject("module_three", this_cldr, new String[] { "p3" });
    57         assertNotNull(m3, "Module should not be null");
    57         assertNotNull(m3x, "Module should not be null");
    58         ModuleHelper.DefineModule(m3, "9.0", "m3/there", new String[] { "p3" });
    58         ModuleHelper.DefineModule(m3x, "9.0", "m3x/there", new String[] { "p3" });
    59 
    59 
    60         // Since a readability edge has not been established between module2
    60         // Since a readability edge has not been established between module_two
    61         // and module3, p3.c3 cannot read its superclass p2.c2.
    61         // and module_three, p3.c3 cannot read its superclass p2.c2.
    62         try {
    62         try {
    63             Class p3_c3_class = Class.forName("p3.c3");
    63             Class p3_c3_class = Class.forName("p3.c3");
    64             throw new RuntimeException("Failed to get IAE (can't read superclass)");
    64             throw new RuntimeException("Failed to get IAE (can't read superclass)");
    65         } catch (IllegalAccessError e) {
    65         } catch (IllegalAccessError e) {
    66             if (!e.getMessage().contains("superclass access check failed") ||
    66             if (!e.getMessage().contains("superclass access check failed") ||