test/hotspot/jtreg/runtime/InnerClassesAttr/InnerClassesTest.jasm
changeset 52096 7a1e2d7ac55a
equal deleted inserted replaced
52095:c459186b9584 52096:7a1e2d7ac55a
       
     1 /*
       
     2  * Copyright (c) 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 /**
       
    26  * @test
       
    27  * @bug 8079784
       
    28  * @compile InnerClassesTest.jasm Base.java Child.java
       
    29  * @run main com.n.InnerClassesTest
       
    30  */
       
    31 
       
    32 // Test that if a class's InnerClasses attribute contains a class that is not
       
    33 // accessible to the class with the attribute then an IllegalAccessError
       
    34 // exception should not get thrown as a result of the class accessing other
       
    35 // classes in the InnerClasses attribute.
       
    36 //
       
    37 // In this test, class InnerClassesTest has an InnerClasses attribute with two
       
    38 // entries.  One for inaccessable (non-public) class com/g/Base and class
       
    39 // con/g/Base$Builder.  And, one entry for classes com/n/InnerClassTest and
       
    40 // com/n/InnerClasses/Test$Foo.  The test accesses com/n/InnerClsses/Test$Foo
       
    41 // by calling getSimpleName().  This should not cause an IllegalAccessError
       
    42 // exception to get thrown.
       
    43 //
       
    44 //
       
    45 // This jasm code was generated from the following Java code.  The only
       
    46 // difference is that, in the jasm code, the order of the entries in the
       
    47 // InnerClasses attributes for class InnerClassesTest were switched.
       
    48 //
       
    49 // package com.n;
       
    50 // import com.g.Child;
       
    51 //
       
    52 // public final class InnerClassesTest {
       
    53 //
       
    54 //     public static final class Foo { }
       
    55 //     void unused() {
       
    56 //         new Child().setJobName();
       
    57 //     }
       
    58 //
       
    59 //     public static void main(String[] args) {
       
    60 //         Class<?> clazz = InnerClassesTest.Foo.class;
       
    61 //         clazz.getSimpleName();
       
    62 //     }
       
    63 // }
       
    64 
       
    65 package com/n;
       
    66 
       
    67 super public final class InnerClassesTest$Foo version 53:0 {
       
    68 
       
    69     public Method "<init>":"()V" stack 1 locals 1 {
       
    70         aload_0;
       
    71         invokespecial Method java/lang/Object."<init>":"()V";
       
    72         return;
       
    73     }
       
    74 
       
    75 public static final InnerClass Foo=class InnerClassesTest$Foo of class InnerClassesTest;
       
    76 
       
    77 } // end Class InnerClassesTest$Foo
       
    78 
       
    79 
       
    80 super public final class InnerClassesTest version 53:0 {
       
    81 
       
    82 
       
    83     public Method "<init>":"()V" stack 1 locals 1 {
       
    84         aload_0;
       
    85         invokespecial    Method java/lang/Object."<init>":"()V";
       
    86         return;
       
    87     }
       
    88 
       
    89     Method unused:"()V" stack 2 locals 1 {
       
    90         new    class com/g/Child;
       
    91         dup;
       
    92         invokespecial    Method com/g/Child."<init>":"()V";
       
    93         invokevirtual    Method com/g/Child.setJobName:"()Lcom/g/Base$Builder;";
       
    94         pop;
       
    95         return;
       
    96     }
       
    97 
       
    98     public static Method main:"([Ljava/lang/String;)V" stack 1 locals 2 {
       
    99         ldc    class InnerClassesTest$Foo;
       
   100         astore_1;
       
   101         aload_1;
       
   102         invokevirtual    Method java/lang/Class.getSimpleName:"()Ljava/lang/String;";
       
   103         pop;
       
   104         return;
       
   105     }
       
   106 
       
   107 static InnerClass Builder=class com/g/Base$Builder of class com/g/Base;
       
   108 public static final InnerClass Foo=class InnerClassesTest$Foo of class InnerClassesTest;
       
   109 
       
   110 } // end Class InnerClassesTest