InvokeSpecialICCE.java revision 10710:9489df4f2b94
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 IncompatibleClassChangeError
28 * @modules java.base/jdk.internal.org.objectweb.asm
29 * @library /runtime/SelectionResolution/classes
30 * @build selectionresolution.*
31 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies InvokeSpecialICCE
32 */
33
34import java.util.Arrays;
35import java.util.Collection;
36import java.util.EnumSet;
37import selectionresolution.ClassData;
38import selectionresolution.MethodData;
39import selectionresolution.Result;
40import selectionresolution.SelectionResolutionTest;
41import selectionresolution.SelectionResolutionTestCase;
42import selectionresolution.Template;
43
44public class InvokeSpecialICCE extends SelectionResolutionTest {
45
46    private static final SelectionResolutionTestCase.Builder initBuilder =
47        new SelectionResolutionTestCase.Builder();
48
49    static {
50        initBuilder.setResult(Result.ICCE);
51    }
52
53    private static final Collection<TestGroup> testgroups =
54        Arrays.asList(
55                /* invokespecial tests */
56                /* resolved method is static*/
57                /* Group 170: methodref = expected */
58                new TestGroup.Simple(initBuilder,
59                        Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
60                        Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
61                                             EnumSet.of(MethodData.Access.PUBLIC,
62                                                        MethodData.Access.PACKAGE,
63                                                        MethodData.Access.PROTECTED,
64                                                        MethodData.Access.PRIVATE),
65                                             EnumSet.of(MethodData.Context.STATIC),
66                                             EnumSet.of(ClassData.Package.SAME)),
67                        Template.OverrideAbstractExpectedClass,
68                        Template.MethodrefEqualsExpected,
69                        Template.IgnoredAbstract,
70                        Template.InvokespecialCallsiteCases,
71                        Template.ObjectrefAssignableToCallsite),
72                /* Group 171: methodref != expected, expected is class */
73                new TestGroup.Simple(initBuilder,
74                        Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
75                        Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
76                                             EnumSet.of(MethodData.Access.PUBLIC,
77                                                        MethodData.Access.PACKAGE,
78                                                        MethodData.Access.PROTECTED,
79                                                        MethodData.Access.PRIVATE),
80                                             EnumSet.of(MethodData.Context.STATIC),
81                                             EnumSet.of(ClassData.Package.SAME,
82                                                        ClassData.Package.DIFFERENT)),
83                        Template.OverrideAbstractExpectedClass,
84                        Template.MethodrefNotEqualsExpectedClass,
85                        Template.IgnoredAbstract,
86                        Template.InvokespecialCallsiteCases,
87                        Template.ObjectrefAssignableToCallsite),
88                /* Group 172: methodref != expected, expected is interface */
89                new TestGroup.Simple(initBuilder,
90                        Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
91                        Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
92                                             EnumSet.of(MethodData.Access.PUBLIC,
93                                                        MethodData.Access.PRIVATE),
94                                             EnumSet.of(MethodData.Context.STATIC),
95                                             EnumSet.of(ClassData.Package.SAME,
96                                                        ClassData.Package.DIFFERENT)),
97                        Template.OverrideAbstractExpectedIface,
98                        Template.MethodrefNotEqualsExpectedIface,
99                        Template.IgnoredAbstract,
100                        Template.InvokespecialCallsiteCases,
101                        Template.ObjectrefAssignableToCallsite),
102
103                /* Group 173: Ambiguous resolution */
104                new TestGroup.Simple(initBuilder,
105                        Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
106                        Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
107                                             EnumSet.of(MethodData.Access.PUBLIC,
108                                                        MethodData.Access.PRIVATE),
109                                             EnumSet.allOf(MethodData.Context.class),
110                                             EnumSet.of(ClassData.Package.SAME,
111                                                        ClassData.Package.DIFFERENT)),
112                        Template.OverrideAbstractExpectedIface,
113                        Template.MethodrefAmbiguous,
114                        Template.IgnoredAbstract,
115                        Template.InvokespecialCallsiteCases,
116                        Template.ObjectrefAssignableToCallsite)
117            );
118
119    private InvokeSpecialICCE() {
120        super(testgroups);
121    }
122
123    public static void main(final String... args) {
124        new InvokeSpecialICCE().run();
125    }
126}
127