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/timeout=1200 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies InvokeVirtualICCE 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.Result; 40 import selectionresolution.SelectionResolutionTest; 41 import selectionresolution.SelectionResolutionTestCase; 42 import selectionresolution.Template; 43 44 public class InvokeVirtualICCE 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 /* invokevirtual tests */ 56 57 /* resolved method is static*/ 58 /* Group 161: callsite = methodref = expected */ 59 new TestGroup.Simple(initBuilder, 60 Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL), 61 Template.ResultCombo(EnumSet.of(Template.Kind.CLASS), 62 EnumSet.of(MethodData.Access.PUBLIC, 63 MethodData.Access.PACKAGE, 64 MethodData.Access.PRIVATE), 65 EnumSet.of(MethodData.Context.STATIC), 66 EnumSet.of(ClassData.Package.SAME, 67 ClassData.Package.DIFFERENT)), 68 Template.OverrideAbstractExpectedClass, 69 Template.MethodrefEqualsExpected, 70 Template.IgnoredAbstract, 71 Template.AllCallsiteCases, 72 Template.MethodrefSelectionResolvedIsClass), 73 /* Group 162: callsite = methodref, methodref != expected, 74 * expected is class, expected and callsite in the same package 75 */ 76 new TestGroup.Simple(initBuilder, 77 Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL), 78 Template.ResultCombo(EnumSet.of(Template.Kind.CLASS), 79 EnumSet.of(MethodData.Access.PUBLIC, 80 MethodData.Access.PACKAGE, 81 MethodData.Access.PRIVATE), 82 EnumSet.of(MethodData.Context.STATIC), 83 EnumSet.of(ClassData.Package.SAME, 84 ClassData.Package.DIFFERENT)), 85 Template.OverrideAbstractExpectedClass, 86 Template.MethodrefNotEqualsExpectedClass, 87 Template.IgnoredAbstract, 88 Template.AllCallsiteCases, 89 Template.MethodrefSelectionResolvedIsClass), 90 /* Group 163: callsite = methodref, methodref != expected, 91 * expected is interface, expected and callsite in the same package 92 */ 93 new TestGroup.Simple(initBuilder, 94 Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL), 95 Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE), 96 EnumSet.of(MethodData.Access.PUBLIC, 97 MethodData.Access.PRIVATE), 98 EnumSet.of(MethodData.Context.STATIC), 99 EnumSet.of(ClassData.Package.SAME, 100 ClassData.Package.DIFFERENT)), 101 Template.OverrideAbstractExpectedIface, 102 Template.MethodrefNotEqualsExpectedIface, 103 Template.IgnoredAbstract, 104 Template.AllCallsiteCases, 105 Template.MethodrefSelectionResolvedIsIface), 106 107 /* methodref is an interface */ 108 /* Group 164: callsite = methodref = expected */ 109 new TestGroup.Simple(initBuilder, 110 Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL), 111 Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE), 112 EnumSet.of(MethodData.Access.PUBLIC, 113 MethodData.Access.PRIVATE), 114 EnumSet.allOf(MethodData.Context.class), 115 EnumSet.of(ClassData.Package.SAME, 116 ClassData.Package.DIFFERENT)), 117 Template.OverrideAbstractExpectedIface, 118 Template.MethodrefEqualsExpected, 119 Template.IgnoredAbstract, 120 Template.AllCallsiteCases, 121 Template.IfaceMethodrefSelection), 122 /* Group 165: callsite = methodref, methodref != expected, 123 * expected and callsite in the same package 124 */ 125 new TestGroup.Simple(initBuilder, 126 Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL), 127 Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE), 128 EnumSet.of(MethodData.Access.PUBLIC, 129 MethodData.Access.PRIVATE), 130 EnumSet.allOf(MethodData.Context.class), 131 EnumSet.of(ClassData.Package.SAME, 132 ClassData.Package.DIFFERENT)), 133 Template.OverrideAbstractExpectedIface, 134 Template.IfaceMethodrefNotEqualsExpected, 135 Template.IgnoredAbstract, 136 Template.AllCallsiteCases, 137 Template.IfaceMethodrefSelection), 138 139 /* Group 166: Ambiguous resolution tests */ 140 new TestGroup.Simple(initBuilder, 141 Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL), 142 Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE), 143 EnumSet.of(MethodData.Access.PUBLIC), 144 EnumSet.allOf(MethodData.Context.class), 145 EnumSet.of(ClassData.Package.SAME, 146 ClassData.Package.DIFFERENT)), 147 Template.OverrideAbstractExpectedIface, 148 Template.MethodrefAmbiguous, 149 Template.IgnoredAbstract, 150 Template.AllCallsiteCases, 151 Template.MethodrefSelectionResolvedIsIfaceNoOverride), 152 /* Group 167: ambiguous selection */ 153 new TestGroup.Simple(initBuilder, 154 Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL), 155 Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE), 156 EnumSet.of(MethodData.Access.PUBLIC), 157 EnumSet.of(MethodData.Context.INSTANCE), 158 EnumSet.of(ClassData.Package.SAME, 159 ClassData.Package.DIFFERENT)), 160 Template.OverrideAbstractExpectedIface, 161 Template.MethodrefNotEqualsExpectedIface, 162 Template.IgnoredAbstract, 163 Template.AllCallsiteCases, 164 Template.MethodrefAmbiguousResolvedIsIface) 165 ); 166 167 private InvokeVirtualICCE() { 168 super(testgroups); 169 } 170 171 public static void main(final String... args) { 172 new InvokeVirtualICCE().run(); 173 } 174 }