hotspot/test/runtime/SelectionResolution/InvokeInterfaceSuccessTest.java
changeset 37267 ad8c0e8de29f
parent 37196 f3f7367e8c53
child 40631 ed82623d7831
equal deleted inserted replaced
36848:33688f44fb2a 37267:ad8c0e8de29f
       
     1 /*
       
     2  * Copyright (c) 2016, 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 Test of method selection and resolution cases that
       
    27  * generate InvokeInterfaceSuccessTest
       
    28  * @modules java.base/jdk.internal.org.objectweb.asm
       
    29  * @library /runtime/SelectionResolution/classes
       
    30  * @build selectionresolution.*
       
    31  * @run main/othervm/timeout=300 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies InvokeInterfaceSuccessTest
       
    32  */
       
    33 
       
    34 import java.util.Arrays;
       
    35 import java.util.Collection;
       
    36 import java.util.EnumSet;
       
    37 import selectionresolution.ClassData;
       
    38 import selectionresolution.MethodData;
       
    39 import selectionresolution.SelectionResolutionTest;
       
    40 import selectionresolution.SelectionResolutionTestCase;
       
    41 import selectionresolution.Template;
       
    42 
       
    43 public class InvokeInterfaceSuccessTest extends SelectionResolutionTest {
       
    44 
       
    45     private static final SelectionResolutionTestCase.Builder initBuilder =
       
    46         new SelectionResolutionTestCase.Builder();
       
    47 
       
    48     static {
       
    49         initBuilder.invoke = SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE;
       
    50     }
       
    51 
       
    52     private static final Collection<TestGroup> testgroups =
       
    53         Arrays.asList(
       
    54                 /* invokeinterface tests */
       
    55 
       
    56                 /* Group 40: callsite = methodref = expected */
       
    57                 new TestGroup.Simple(initBuilder,
       
    58                         Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
       
    59                                              EnumSet.of(MethodData.Access.PUBLIC),
       
    60                                              EnumSet.of(MethodData.Context.INSTANCE,
       
    61                                                         MethodData.Context.ABSTRACT),
       
    62                                              EnumSet.of(ClassData.Package.SAME)),
       
    63                         Template.OverrideAbstractExpectedIface,
       
    64                         Template.MethodrefEqualsExpected,
       
    65                         Template.IgnoredAbstract,
       
    66                         Template.CallsiteEqualsMethodref,
       
    67                         Template.IfaceMethodrefSelection,
       
    68                         Template.SelectionOverrideAbstract),
       
    69                 /* Group 41: callsite = methodref, methodref != expected */
       
    70                 new TestGroup.Simple(initBuilder,
       
    71                         Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
       
    72                                              EnumSet.of(MethodData.Access.PUBLIC),
       
    73                                              EnumSet.of(MethodData.Context.INSTANCE,
       
    74                                                         MethodData.Context.ABSTRACT),
       
    75                                              EnumSet.of(ClassData.Package.SAME,
       
    76                                                         ClassData.Package.DIFFERENT)),
       
    77                         Template.OverrideAbstractExpectedIface,
       
    78                         Template.IfaceMethodrefNotEqualsExpected,
       
    79                         Template.IgnoredAbstract,
       
    80                         Template.CallsiteEqualsMethodref,
       
    81                         Template.IfaceMethodrefSelection,
       
    82                         Template.SelectionOverrideAbstract),
       
    83                 /* Group 42: callsite :> methodref, methodref = expected */
       
    84                 new TestGroup.Simple(initBuilder,
       
    85                         Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
       
    86                                              EnumSet.of(MethodData.Access.PUBLIC),
       
    87                                              EnumSet.of(MethodData.Context.INSTANCE,
       
    88                                                         MethodData.Context.ABSTRACT),
       
    89                                              EnumSet.of(ClassData.Package.SAME,
       
    90                                                         ClassData.Package.DIFFERENT)),
       
    91                         Template.OverrideAbstractExpectedIface,
       
    92                         Template.MethodrefEqualsExpected,
       
    93                         Template.IgnoredAbstract,
       
    94                         Template.CallsiteSubclassMethodref,
       
    95                         Template.IfaceMethodrefSelection,
       
    96                         Template.SelectionOverrideAbstract),
       
    97                 /* Group 43: callsite :> methodref, methodref != expected */
       
    98                 new TestGroup.Simple(initBuilder,
       
    99                         Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
       
   100                                              EnumSet.of(MethodData.Access.PUBLIC),
       
   101                                              EnumSet.of(MethodData.Context.INSTANCE,
       
   102                                                         MethodData.Context.ABSTRACT),
       
   103                                              EnumSet.of(ClassData.Package.SAME,
       
   104                                                         ClassData.Package.DIFFERENT)),
       
   105                         Template.OverrideAbstractExpectedIface,
       
   106                         Template.IfaceMethodrefNotEqualsExpected,
       
   107                         Template.IgnoredAbstract,
       
   108                         Template.CallsiteSubclassMethodref,
       
   109                         Template.IfaceMethodrefSelection,
       
   110                         Template.SelectionOverrideAbstract),
       
   111                 /* Group 44: callsite unrelated to methodref, methodref = expected */
       
   112                 new TestGroup.Simple(initBuilder,
       
   113                         Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
       
   114                                              EnumSet.of(MethodData.Access.PUBLIC),
       
   115                                              EnumSet.of(MethodData.Context.INSTANCE,
       
   116                                                         MethodData.Context.ABSTRACT),
       
   117                                              EnumSet.of(ClassData.Package.SAME,
       
   118                                                         ClassData.Package.DIFFERENT)),
       
   119                         Template.OverrideAbstractExpectedIface,
       
   120                         Template.MethodrefEqualsExpected,
       
   121                         Template.IgnoredAbstract,
       
   122                         Template.CallsiteUnrelatedToMethodref,
       
   123                         Template.IfaceMethodrefSelection,
       
   124                         Template.SelectionOverrideAbstract),
       
   125                 /* Group 45: callsite unrelated to methodref, methodref != expected */
       
   126                 new TestGroup.Simple(initBuilder,
       
   127                         Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
       
   128                                              EnumSet.of(MethodData.Access.PUBLIC),
       
   129                                              EnumSet.of(MethodData.Context.INSTANCE,
       
   130                                                         MethodData.Context.ABSTRACT),
       
   131                                              EnumSet.of(ClassData.Package.SAME,
       
   132                                                         ClassData.Package.DIFFERENT)),
       
   133                         Template.OverrideAbstractExpectedIface,
       
   134                         Template.IfaceMethodrefNotEqualsExpected,
       
   135                         Template.IgnoredAbstract,
       
   136                         Template.CallsiteUnrelatedToMethodref,
       
   137                         Template.IfaceMethodrefSelection,
       
   138                         Template.SelectionOverrideAbstract)
       
   139             );
       
   140 
       
   141     private InvokeInterfaceSuccessTest() {
       
   142         super(testgroups);
       
   143     }
       
   144 
       
   145     public static void main(final String... args) {
       
   146         new InvokeInterfaceSuccessTest().run();
       
   147     }
       
   148 }