8078112: [TESTBUG] Integrate Selection/Resolution test suite into jtreg tests
Reviewed-by: ctornqvi, acorn
This commit is contained in:
parent
a02f8f2d30
commit
6bf9194f41
@ -334,6 +334,15 @@ hotspot_runtime = \
|
||||
-runtime/memory/ReserveMemory.java \
|
||||
-runtime/memory/RunUnitTestsConcurrently.java \
|
||||
-runtime/Unsafe/RangeCheck.java \
|
||||
-runtime/SelectionResolution/AbstractMethodErrorTest.java \
|
||||
-runtime/SelectionResolution/IllegalAccessErrorTest.java \
|
||||
-runtime/SelectionResolution/InvokeInterfaceICCE.java \
|
||||
-runtime/SelectionResolution/InvokeInterfaceSuccessTest.java \
|
||||
-runtime/SelectionResolution/InvokeSpecialICCE.java \
|
||||
-runtime/SelectionResolution/InvokeSpecialSuccessTest.java \
|
||||
-runtime/SelectionResolution/InvokeStaticICCE.java \
|
||||
-runtime/SelectionResolution/InvokeVirtualICCE.java \
|
||||
-runtime/SelectionResolution/InvokeVirtualSuccessTest.java \
|
||||
-runtime/SharedArchiveFile/CdsSameObjectAlignment.java \
|
||||
-runtime/SharedArchiveFile/DefaultUseWithClient.java \
|
||||
-runtime/Thread/CancellableThreadTest.java \
|
||||
|
@ -0,0 +1,875 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of method selection and resolution cases that
|
||||
* generate AbstractMethodErrorTest
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @library /runtime/SelectionResolution/classes
|
||||
* @build selectionresolution.*
|
||||
* @run main/othervm/timeout=300 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies AbstractMethodErrorTest
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import selectionresolution.ClassData;
|
||||
import selectionresolution.MethodData;
|
||||
import selectionresolution.Result;
|
||||
import selectionresolution.SelectionResolutionTest;
|
||||
import selectionresolution.SelectionResolutionTestCase;
|
||||
import selectionresolution.Template;
|
||||
|
||||
public class AbstractMethodErrorTest extends SelectionResolutionTest {
|
||||
|
||||
private static final SelectionResolutionTestCase.Builder initBuilder =
|
||||
new SelectionResolutionTestCase.Builder();
|
||||
|
||||
static {
|
||||
initBuilder.setResult(Result.AME);
|
||||
}
|
||||
|
||||
private static final Collection<TestGroup> testgroups =
|
||||
Arrays.asList(
|
||||
/* invokevirtual tests */
|
||||
/* Group 63: callsite = methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 64: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 65: callsite = methodref = resolved, possibly
|
||||
* skip different package in selection.
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionPackageSkipNoOverride),
|
||||
/* Group 66: callsite = methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface),
|
||||
/* Group 67: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 68: callsite :> methodref, methodref = expected,
|
||||
* possibly skip different package in selection.
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionPackageSkipNoOverride),
|
||||
/* Group 69: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 70: callsite :> methodref, methodref != expected,
|
||||
* possibly skip different package in selection
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionPackageSkipNoOverride),
|
||||
/* Group 71: callsite :> methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface),
|
||||
/* Group 72: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 73: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionPackageSkipNoOverride),
|
||||
/* Group 74: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 75: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionPackageSkipNoOverride),
|
||||
/* Group 76: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface),
|
||||
/* Group 77: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 78: callsite = methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface),
|
||||
/* Group 79: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
|
||||
/* Group 80: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 81: callsite :> methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface),
|
||||
/* Group 82: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 83: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 84: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface),
|
||||
|
||||
/* Reabstraction during selection */
|
||||
/* Group 85: callsite = methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ReabstractMethodrefResolvedClass),
|
||||
/* Group 86: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ReabstractMethodrefResolvedClass),
|
||||
/* Group 87: callsite = methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ReabstractMethodrefResolvedIface),
|
||||
/* Group 88: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ReabstractMethodrefResolvedClass),
|
||||
/* Group 89: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ReabstractMethodrefResolvedClass),
|
||||
/* Group 90: callsite :> methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ReabstractMethodrefResolvedIface),
|
||||
/* Group 91: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.ReabstractMethodrefResolvedClass),
|
||||
/* Group 92: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.ReabstractMethodrefResolvedClass),
|
||||
/* Group 93: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.ReabstractMethodrefResolvedIface),
|
||||
/* Group 94: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ReabstractMethodrefResolvedClass),
|
||||
/* Group 95: callsite = methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ReabstractMethodrefResolvedIface),
|
||||
/* Group 96: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ReabstractMethodrefResolvedClass),
|
||||
|
||||
/* Group 97: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ReabstractMethodrefResolvedClass),
|
||||
/* Group 98: callsite :> methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ReabstractMethodrefResolvedIface),
|
||||
/* Group 99: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.ReabstractMethodrefResolvedClass),
|
||||
/* Group 100: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.ReabstractMethodrefResolvedClass),
|
||||
/* Group 101: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.ReabstractMethodrefResolvedIface),
|
||||
|
||||
/* invokeinterface */
|
||||
/* Group 102: callsite = methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.IfaceMethodrefSelection),
|
||||
/* Group 103: callsite = methodref, methodref != expected,
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.IfaceMethodrefSelection),
|
||||
/* Group 104: callsite :> methodref, methodref = expected,
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.IfaceMethodrefSelection),
|
||||
/* Group 105: callsite :> methodref, methodref != expected,
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.IfaceMethodrefSelection),
|
||||
/* Group 106: callsite unrelated to methodref, methodref = expected,
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.IfaceMethodrefSelection),
|
||||
/* Group 107: callsite unrelated to methodref, methodref != expected,
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.IfaceMethodrefSelection),
|
||||
|
||||
/* Reabstraction during selection */
|
||||
/* Group 108: callsite = methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ReabstractIfaceMethodrefResolved),
|
||||
/* Group 109: callsite = methodref, methodref != expected,
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ReabstractIfaceMethodrefResolved),
|
||||
/* Group 110: callsite :> methodref, methodref = expected,
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ReabstractIfaceMethodrefResolved),
|
||||
/* Group 111: callsite :> methodref, methodref != expected,
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ReabstractIfaceMethodrefResolved),
|
||||
/* Group 112: callsite unrelated to methodref, methodref = expected,
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.ReabstractIfaceMethodrefResolved),
|
||||
/* Group 113: callsite unrelated to methodref, methodref != expected,
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.ReabstractIfaceMethodrefResolved),
|
||||
|
||||
/* invokespecial tests */
|
||||
/* Group 114: callsite = methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
/* Group 115: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
/* Group 116: callsite = methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
/* Group 117: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
/* Group 118: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
/* Group 119: callsite :> methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
/* Group 120: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
/* Group 121: callsite = methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
/* Group 122: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
|
||||
/* Group 123: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.ReabstractExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
/* Group 124: callsite :> methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.ReabstractExpectedIface,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite)
|
||||
);
|
||||
|
||||
private AbstractMethodErrorTest() {
|
||||
super(testgroups);
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
new AbstractMethodErrorTest().run();
|
||||
}
|
||||
}
|
@ -0,0 +1,517 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of method selection and resolution cases that
|
||||
* generate IllegalAccessErrorTest
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @library /runtime/SelectionResolution/classes
|
||||
* @build selectionresolution.*
|
||||
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies IllegalAccessErrorTest
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import selectionresolution.ClassData;
|
||||
import selectionresolution.MethodData;
|
||||
import selectionresolution.Result;
|
||||
import selectionresolution.SelectionResolutionTest;
|
||||
import selectionresolution.SelectionResolutionTestCase;
|
||||
import selectionresolution.Template;
|
||||
|
||||
public class IllegalAccessErrorTest extends SelectionResolutionTest {
|
||||
|
||||
private static final SelectionResolutionTestCase.Builder initBuilder =
|
||||
new SelectionResolutionTestCase.Builder();
|
||||
|
||||
static {
|
||||
initBuilder.setResult(Result.IAE);
|
||||
}
|
||||
|
||||
private static final Collection<TestGroup> testgroups =
|
||||
Arrays.asList(
|
||||
/* invokestatic tests */
|
||||
/* Group 125 : callsite = methodref, methodref !=
|
||||
* expected, expected is class
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 126: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 127: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 128: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 129: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 130: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE,
|
||||
MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 131: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE,
|
||||
MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 132: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE,
|
||||
MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 133: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 134: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.TrivialObjectref),
|
||||
|
||||
/* invokevirtual tests */
|
||||
/* Group 135: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 136: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 137: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 138: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 139: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 140: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 141: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 142: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 143: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE,
|
||||
// protected causes verifier error.
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 144: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE,
|
||||
// protected causes verifier error.
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
|
||||
/* invokeinterface tests */
|
||||
/* Group 145: callsite = methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.IfaceMethodrefSelectionOverrideNonPublic),
|
||||
/* Group 146: callsite = methodref, methodref != expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.IfaceMethodrefSelectionOverrideNonPublic),
|
||||
/* Group 147: callsite :> methodref, methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.IfaceMethodrefSelectionOverrideNonPublic),
|
||||
/* Group 148: callsite :> methodref, methodref != expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.IfaceMethodrefSelectionOverrideNonPublic),
|
||||
/* Group 149: callsite unrelated to methodref, methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.IfaceMethodrefSelectionOverrideNonPublic),
|
||||
/* Group 150: callsite unrelated to methodref, methodref != expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.IfaceMethodrefSelectionOverrideNonPublic),
|
||||
|
||||
/* invokespecial tests */
|
||||
/* Group 151: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 152: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 153: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 154: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
/* Group 155: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite),
|
||||
/* Group 156: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefExactSubclassOfCallsite)
|
||||
);
|
||||
|
||||
private IllegalAccessErrorTest() {
|
||||
super(testgroups);
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
new IllegalAccessErrorTest().run();
|
||||
}
|
||||
}
|
@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of method selection and resolution cases that
|
||||
* generate IncompatibleClassChangeError
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @library /runtime/SelectionResolution/classes
|
||||
* @build selectionresolution.*
|
||||
* @run main/othervm/timeout=500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies InvokeInterfaceICCE
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import selectionresolution.ClassData;
|
||||
import selectionresolution.MethodData;
|
||||
import selectionresolution.Result;
|
||||
import selectionresolution.SelectionResolutionTest;
|
||||
import selectionresolution.SelectionResolutionTestCase;
|
||||
import selectionresolution.Template;
|
||||
|
||||
public class InvokeInterfaceICCE extends SelectionResolutionTest {
|
||||
|
||||
private static final SelectionResolutionTestCase.Builder initBuilder =
|
||||
new SelectionResolutionTestCase.Builder();
|
||||
|
||||
static {
|
||||
initBuilder.setResult(Result.ICCE);
|
||||
}
|
||||
|
||||
private static final Collection<TestGroup> testgroups =
|
||||
Arrays.asList(
|
||||
/* invokeinterface tests */
|
||||
|
||||
/* resolved method is static*/
|
||||
/* Group 168: methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.IfaceMethodrefSelection),
|
||||
/* Group 169: methodref != expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.IfaceMethodrefSelection),
|
||||
|
||||
/* methodref is a class */
|
||||
/* Group 170: methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 171: methodref != expected, expected is class */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 172: methodref != expected expected is interface */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.MethodrefSelectionResolvedIsIface),
|
||||
/* Group 173: ambiguous resolution */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.IfaceMethodrefAmbiguous,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.IfaceMethodrefSelectionNoOverride),
|
||||
/* Group 174: ambiguous selection */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.IfaceMethodrefAmbiguousResolvedIsIface),
|
||||
|
||||
/* Group 175: private method in interface */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.IfaceMethodrefSelection)
|
||||
);
|
||||
|
||||
private InvokeInterfaceICCE() {
|
||||
super(testgroups);
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
new InvokeInterfaceICCE().run();
|
||||
}
|
||||
}
|
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of method selection and resolution cases that
|
||||
* generate InvokeInterfaceSuccessTest
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @library /runtime/SelectionResolution/classes
|
||||
* @build selectionresolution.*
|
||||
* @run main/othervm/timeout=300 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies InvokeInterfaceSuccessTest
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import selectionresolution.ClassData;
|
||||
import selectionresolution.MethodData;
|
||||
import selectionresolution.SelectionResolutionTest;
|
||||
import selectionresolution.SelectionResolutionTestCase;
|
||||
import selectionresolution.Template;
|
||||
|
||||
public class InvokeInterfaceSuccessTest extends SelectionResolutionTest {
|
||||
|
||||
private static final SelectionResolutionTestCase.Builder initBuilder =
|
||||
new SelectionResolutionTestCase.Builder();
|
||||
|
||||
static {
|
||||
initBuilder.invoke = SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE;
|
||||
}
|
||||
|
||||
private static final Collection<TestGroup> testgroups =
|
||||
Arrays.asList(
|
||||
/* invokeinterface tests */
|
||||
|
||||
/* Group 40: callsite = methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.IfaceMethodrefSelection,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 41: callsite = methodref, methodref != expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.IfaceMethodrefSelection,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 42: callsite :> methodref, methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.IfaceMethodrefSelection,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 43: callsite :> methodref, methodref != expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.IfaceMethodrefSelection,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 44: callsite unrelated to methodref, methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.IfaceMethodrefSelection,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 45: callsite unrelated to methodref, methodref != expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.IfaceMethodrefSelection,
|
||||
Template.SelectionOverrideAbstract)
|
||||
);
|
||||
|
||||
private InvokeInterfaceSuccessTest() {
|
||||
super(testgroups);
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
new InvokeInterfaceSuccessTest().run();
|
||||
}
|
||||
}
|
126
hotspot/test/runtime/SelectionResolution/InvokeSpecialICCE.java
Normal file
126
hotspot/test/runtime/SelectionResolution/InvokeSpecialICCE.java
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of method selection and resolution cases that
|
||||
* generate IncompatibleClassChangeError
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @library /runtime/SelectionResolution/classes
|
||||
* @build selectionresolution.*
|
||||
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies InvokeSpecialICCE
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import selectionresolution.ClassData;
|
||||
import selectionresolution.MethodData;
|
||||
import selectionresolution.Result;
|
||||
import selectionresolution.SelectionResolutionTest;
|
||||
import selectionresolution.SelectionResolutionTestCase;
|
||||
import selectionresolution.Template;
|
||||
|
||||
public class InvokeSpecialICCE extends SelectionResolutionTest {
|
||||
|
||||
private static final SelectionResolutionTestCase.Builder initBuilder =
|
||||
new SelectionResolutionTestCase.Builder();
|
||||
|
||||
static {
|
||||
initBuilder.setResult(Result.ICCE);
|
||||
}
|
||||
|
||||
private static final Collection<TestGroup> testgroups =
|
||||
Arrays.asList(
|
||||
/* invokespecial tests */
|
||||
/* resolved method is static*/
|
||||
/* Group 170: methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.InvokespecialCallsiteCases,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 171: methodref != expected, expected is class */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.InvokespecialCallsiteCases,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 172: methodref != expected, expected is interface */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.InvokespecialCallsiteCases,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
|
||||
/* Group 173: Ambiguous resolution */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.allOf(MethodData.Context.class),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefAmbiguous,
|
||||
Template.IgnoredAbstract,
|
||||
Template.InvokespecialCallsiteCases,
|
||||
Template.ObjectrefAssignableToCallsite)
|
||||
);
|
||||
|
||||
private InvokeSpecialICCE() {
|
||||
super(testgroups);
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
new InvokeSpecialICCE().run();
|
||||
}
|
||||
}
|
@ -0,0 +1,301 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of method selection and resolution cases that
|
||||
* generate InvokeSpecialSuccessTest
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @library /runtime/SelectionResolution/classes
|
||||
* @build selectionresolution.*
|
||||
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies InvokeSpecialSuccessTest
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import selectionresolution.ClassData;
|
||||
import selectionresolution.MethodData;
|
||||
import selectionresolution.SelectionResolutionTest;
|
||||
import selectionresolution.SelectionResolutionTestCase;
|
||||
import selectionresolution.Template;
|
||||
|
||||
public class InvokeSpecialSuccessTest extends SelectionResolutionTest {
|
||||
|
||||
private static final SelectionResolutionTestCase.Builder initBuilder =
|
||||
new SelectionResolutionTestCase.Builder();
|
||||
|
||||
static {
|
||||
initBuilder.invoke = SelectionResolutionTestCase.InvokeInstruction.INVOKESPECIAL;
|
||||
}
|
||||
|
||||
private static final Collection<TestGroup> testgroups =
|
||||
Arrays.asList(
|
||||
/* Group 46: callsite = methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 47: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 48: callsite = methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 49: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 50: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 51: callsite :> methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 52: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 53: callsite = methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 54: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
|
||||
/* Group 55: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 56: callsite :> methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
|
||||
/* Funny cases */
|
||||
/* Group 57: callsite = methodref, methodref =
|
||||
* expected expected is interface, expected and
|
||||
* callsite in a different package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefEqualsOrExactSubclassOfCallsite),
|
||||
/* Group 58: callsite = methodref, methodref \!=
|
||||
* expected expected is interface, expected and
|
||||
* callsite in a different package */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.ObjectrefEqualsOrExactSubclassOfCallsite),
|
||||
/* Group 59: callsite subclass methodref, methodref =
|
||||
* expected expected is interface, expected and
|
||||
* callsite in a different package */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefEqualsOrExactSubclassOfCallsite),
|
||||
/* Group 60: callsite subclass methodref, methodref
|
||||
* \!= expected expected is interface, expected and
|
||||
* callsite in a different package */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefEqualsOrExactSubclassOfCallsite),
|
||||
|
||||
/* Methodref is an interface */
|
||||
/* Group 61: callsite :> methodref, methodref = expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefAssignableToCallsite),
|
||||
/* Group 62: callsite :> methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.ObjectrefAssignableToCallsite)
|
||||
);
|
||||
|
||||
private InvokeSpecialSuccessTest() {
|
||||
super(testgroups);
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
new InvokeSpecialSuccessTest().run();
|
||||
}
|
||||
}
|
126
hotspot/test/runtime/SelectionResolution/InvokeStaticICCE.java
Normal file
126
hotspot/test/runtime/SelectionResolution/InvokeStaticICCE.java
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of invokestatic method selection and resolution cases that
|
||||
* generate IncompatibleClassChangeError
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @library /runtime/SelectionResolution/classes
|
||||
* @build selectionresolution.*
|
||||
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies InvokeStaticICCE
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import selectionresolution.ClassData;
|
||||
import selectionresolution.MethodData;
|
||||
import selectionresolution.Result;
|
||||
import selectionresolution.SelectionResolutionTest;
|
||||
import selectionresolution.SelectionResolutionTestCase;
|
||||
import selectionresolution.Template;
|
||||
|
||||
public class InvokeStaticICCE extends SelectionResolutionTest {
|
||||
|
||||
private static final SelectionResolutionTestCase.Builder initBuilder =
|
||||
new SelectionResolutionTestCase.Builder();
|
||||
|
||||
static {
|
||||
initBuilder.setResult(Result.ICCE);
|
||||
}
|
||||
|
||||
private static final Collection<TestGroup> testgroups =
|
||||
Arrays.asList(
|
||||
/* invokestatic tests */
|
||||
/* Group 157: methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.AllCallsiteCases,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 158: methodref = expected, expected is interface */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.AllCallsiteCases,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 159: methodref != expected, expected is class
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.AllCallsiteCases,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 160: methodref = expected, expected is interface */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.AllCallsiteCases,
|
||||
Template.TrivialObjectref)
|
||||
);
|
||||
|
||||
private InvokeStaticICCE() {
|
||||
super(testgroups);
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
new InvokeStaticICCE().run();
|
||||
}
|
||||
}
|
@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of method selection and resolution cases that
|
||||
* generate InvokeStaticSuccessTest
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @library /runtime/SelectionResolution/classes
|
||||
* @build selectionresolution.*
|
||||
* @run main InvokeStaticSuccessTest
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import selectionresolution.ClassData;
|
||||
import selectionresolution.MethodData;
|
||||
import selectionresolution.SelectionResolutionTest;
|
||||
import selectionresolution.SelectionResolutionTestCase;
|
||||
import selectionresolution.Template;
|
||||
|
||||
public class InvokeStaticSuccessTest extends SelectionResolutionTest {
|
||||
|
||||
private static final SelectionResolutionTestCase.Builder initBuilder =
|
||||
new SelectionResolutionTestCase.Builder();
|
||||
|
||||
static {
|
||||
initBuilder.invoke = SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC;
|
||||
}
|
||||
|
||||
private static final Collection<TestGroup> testgroups =
|
||||
Arrays.asList(
|
||||
/* invokestatic tests */
|
||||
/* Group 1: callsite = methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 2: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 3: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 4: callsite :> methodref, methodref = expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 5: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 6: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 7: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 8: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 9: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 10: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 11: callsite :> methodref, methodref = expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 12: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 13: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 14: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* Group 15: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.TrivialObjectref)
|
||||
);
|
||||
|
||||
private InvokeStaticSuccessTest() {
|
||||
super(testgroups);
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
new InvokeStaticSuccessTest().run();
|
||||
}
|
||||
}
|
174
hotspot/test/runtime/SelectionResolution/InvokeVirtualICCE.java
Normal file
174
hotspot/test/runtime/SelectionResolution/InvokeVirtualICCE.java
Normal file
@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of method selection and resolution cases that
|
||||
* generate IncompatibleClassChangeError
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @library /runtime/SelectionResolution/classes
|
||||
* @build selectionresolution.*
|
||||
* @run main/othervm/timeout=1200 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies InvokeVirtualICCE
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import selectionresolution.ClassData;
|
||||
import selectionresolution.MethodData;
|
||||
import selectionresolution.Result;
|
||||
import selectionresolution.SelectionResolutionTest;
|
||||
import selectionresolution.SelectionResolutionTestCase;
|
||||
import selectionresolution.Template;
|
||||
|
||||
public class InvokeVirtualICCE extends SelectionResolutionTest {
|
||||
|
||||
private static final SelectionResolutionTestCase.Builder initBuilder =
|
||||
new SelectionResolutionTestCase.Builder();
|
||||
|
||||
static {
|
||||
initBuilder.setResult(Result.ICCE);
|
||||
}
|
||||
|
||||
private static final Collection<TestGroup> testgroups =
|
||||
Arrays.asList(
|
||||
/* invokevirtual tests */
|
||||
|
||||
/* resolved method is static*/
|
||||
/* Group 161: callsite = methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 162: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PACKAGE,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.MethodrefSelectionResolvedIsClass),
|
||||
/* Group 163: callsite = methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.STATIC),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.MethodrefSelectionResolvedIsIface),
|
||||
|
||||
/* methodref is an interface */
|
||||
/* Group 164: callsite = methodref = expected */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.allOf(MethodData.Context.class),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.IfaceMethodrefSelection),
|
||||
/* Group 165: callsite = methodref, methodref != expected,
|
||||
* expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PRIVATE),
|
||||
EnumSet.allOf(MethodData.Context.class),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.IfaceMethodrefSelection),
|
||||
|
||||
/* Group 166: Ambiguous resolution tests */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.allOf(MethodData.Context.class),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefAmbiguous,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.MethodrefSelectionResolvedIsIfaceNoOverride),
|
||||
/* Group 167: ambiguous selection */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.AllCallsiteCases,
|
||||
Template.MethodrefAmbiguousResolvedIsIface)
|
||||
);
|
||||
|
||||
private InvokeVirtualICCE() {
|
||||
super(testgroups);
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
new InvokeVirtualICCE().run();
|
||||
}
|
||||
}
|
@ -0,0 +1,429 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of method selection and resolution cases that
|
||||
* generate InvokeVirtualSuccessTest
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @library /runtime/SelectionResolution/classes
|
||||
* @build selectionresolution.*
|
||||
* @run main/othervm/timeout=400 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies InvokeVirtualSuccessTest
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import selectionresolution.ClassData;
|
||||
import selectionresolution.MethodData;
|
||||
import selectionresolution.SelectionResolutionTest;
|
||||
import selectionresolution.SelectionResolutionTestCase;
|
||||
import selectionresolution.Template;
|
||||
|
||||
public class InvokeVirtualSuccessTest extends SelectionResolutionTest {
|
||||
|
||||
private static final SelectionResolutionTestCase.Builder initBuilder =
|
||||
new SelectionResolutionTestCase.Builder();
|
||||
|
||||
static {
|
||||
initBuilder.invoke = SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL;
|
||||
}
|
||||
|
||||
private static final Collection<TestGroup> testgroups =
|
||||
Arrays.asList(
|
||||
/* invokevirtual tests */
|
||||
/* Group 16: callsite = methodref = expected, no override */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClassNoOverride),
|
||||
/* Group 17: callsite = methodref = expected, override allowed */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PROTECTED,
|
||||
MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 18: callsite = methodref = resolved, possibly
|
||||
* skip different package in selection.
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionPackageSkip,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 19: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 20: callsite = methodref, methodref \!=
|
||||
* expected, possibly skip different package in
|
||||
* selection.
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionPackageSkip,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 21: callsite = methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 22: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 23: callsite :>, methodref = expected,
|
||||
* possibly skip different package in selection
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionPackageSkip,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 24: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 25: callsite :>, methodref = expected,
|
||||
* possibly skip different package in selection
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionPackageSkip,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 26: callsite :> methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 27: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 28: callsite unrelated to methodref,
|
||||
* methodref = expected, possibly skip different
|
||||
* package in selection
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionPackageSkip,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 29: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 30: callsite unrelated to methodref,
|
||||
* methodref \!= expected, possibly skip different
|
||||
* package in selection
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PACKAGE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionPackageSkip,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 31: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 32: callsite = methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC,
|
||||
MethodData.Access.PROTECTED),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 33: callsite = methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteEqualsMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 34: callsite :> methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass,
|
||||
Template.SelectionOverrideAbstract),
|
||||
|
||||
/* Group 35: callsite :> methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 36: callsite :> methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteSubclassMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 37: callsite unrelated to methodref, methodref = expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefEqualsExpected,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 38: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is class, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.CLASS),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedClass,
|
||||
Template.MethodrefNotEqualsExpectedClass,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsClass,
|
||||
Template.SelectionOverrideAbstract),
|
||||
/* Group 39: callsite unrelated to methodref, methodref != expected,
|
||||
* expected is interface, expected and callsite not in the same package
|
||||
*/
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PUBLIC),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.DIFFERENT)),
|
||||
Template.OverrideAbstractExpectedIface,
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.IgnoredAbstract,
|
||||
Template.CallsiteUnrelatedToMethodref,
|
||||
Template.MethodrefSelectionResolvedIsIface,
|
||||
Template.SelectionOverrideAbstract)
|
||||
);
|
||||
|
||||
private InvokeVirtualSuccessTest() {
|
||||
super(testgroups);
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
new InvokeVirtualSuccessTest().run();
|
||||
}
|
||||
}
|
@ -0,0 +1,450 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test of method selection and resolution cases that
|
||||
* generate NoSuchMethodError
|
||||
* @modules java.base/jdk.internal.org.objectweb.asm
|
||||
* @library /runtime/SelectionResolution/classes
|
||||
* @build selectionresolution.*
|
||||
* @run main NoSuchMethodErrorTest
|
||||
*/
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
import selectionresolution.ClassData;
|
||||
import selectionresolution.MethodData;
|
||||
import selectionresolution.Result;
|
||||
import selectionresolution.SelectionResolutionTest;
|
||||
import selectionresolution.SelectionResolutionTestCase;
|
||||
import selectionresolution.Template;
|
||||
|
||||
public class NoSuchMethodErrorTest extends SelectionResolutionTest {
|
||||
|
||||
private static final SelectionResolutionTestCase.Builder initBuilder =
|
||||
new SelectionResolutionTestCase.Builder();
|
||||
|
||||
static {
|
||||
initBuilder.setResult(Result.NSME);
|
||||
}
|
||||
|
||||
private static final MethodData concreteMethod =
|
||||
new MethodData(MethodData.Access.PUBLIC, MethodData.Context.INSTANCE);
|
||||
|
||||
private static final MethodData staticMethod =
|
||||
new MethodData(MethodData.Access.PUBLIC, MethodData.Context.STATIC);
|
||||
|
||||
private static final MethodData privateMethod =
|
||||
new MethodData(MethodData.Access.PRIVATE, MethodData.Context.INSTANCE);
|
||||
|
||||
private static final ClassData withDef =
|
||||
new ClassData(ClassData.Package.SAME, concreteMethod);
|
||||
|
||||
private static final ClassData withStaticDef =
|
||||
new ClassData(ClassData.Package.SAME, staticMethod);
|
||||
|
||||
private static final ClassData withPrivateDef =
|
||||
new ClassData(ClassData.Package.SAME, staticMethod);
|
||||
|
||||
private static final Template NoMethodResolutionTemplateClassBottom =
|
||||
new Template("NoMethodResolutionTemplate",
|
||||
/* Empty single class
|
||||
*
|
||||
* C[]() = mref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.methodref = C;
|
||||
},
|
||||
/* Class bottom, inherit empty class
|
||||
*
|
||||
* C2[]()
|
||||
* C1[C2]() = mref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C1 = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int C2 = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.hier.addInherit(C1, C2);
|
||||
builder.methodref = C1;
|
||||
},
|
||||
/* Class bottom, inherit empty interface
|
||||
*
|
||||
* I[]()
|
||||
* C[I]() = mref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.hier.addInherit(C, I);
|
||||
builder.methodref = C;
|
||||
},
|
||||
/* Class bottom, inherit empty class and interface
|
||||
*
|
||||
* C2[](), I[]()
|
||||
* C1[C2,I]() = mref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C1 = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int C2 = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.hier.addInherit(C1, C2);
|
||||
builder.hier.addInherit(C1, I);
|
||||
builder.methodref = C1;
|
||||
},
|
||||
/* Class bottom, unrelated class defines
|
||||
*
|
||||
* C20[](con)
|
||||
* C1[]()
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.addClass(withDef);
|
||||
builder.methodref = C;
|
||||
},
|
||||
/* Class bottom, interface defines static
|
||||
*
|
||||
* I[](stat)
|
||||
* C[]()
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I = builder.addInterface(withStaticDef);
|
||||
builder.hier.addInherit(C, I);
|
||||
builder.methodref = C;
|
||||
},
|
||||
/* Class bottom, interface defines private
|
||||
*
|
||||
* I[](priv)
|
||||
* C[]()
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I = builder.addInterface(withPrivateDef);
|
||||
builder.hier.addInherit(C, I);
|
||||
builder.methodref = C;
|
||||
});
|
||||
|
||||
private static final Template NoMethodResolutionTemplateIfaceBottom =
|
||||
new Template("NoMethodResolutionTemplate",
|
||||
/* Empty single interface
|
||||
*
|
||||
* I[]() = mref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int I = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.methodref = I;
|
||||
},
|
||||
/* Interface bottom, inherit empty interface
|
||||
*
|
||||
* I2[]()
|
||||
* I1[I2]() = mref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int I1 = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I2 = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.hier.addInherit(I1, I2);
|
||||
builder.methodref = I1;
|
||||
},
|
||||
/* Interface bottom, unrelated class defines
|
||||
*
|
||||
* C0[](con)
|
||||
* I[]() = mref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int I = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.addClass(withDef);
|
||||
builder.methodref = I;
|
||||
},
|
||||
/* Interface bottom, interface defines static
|
||||
*
|
||||
* I2[](stat)
|
||||
* I1[I2]() = mref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int I1 = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I2 = builder.addInterface(withStaticDef);
|
||||
builder.hier.addInherit(I1, I2);
|
||||
builder.methodref = I1;
|
||||
},
|
||||
/* Interface bottom, interface defines private
|
||||
*
|
||||
* I2[](stat)
|
||||
* I1[I2]() = mref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int I1 = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I2 = builder.addInterface(withPrivateDef);
|
||||
builder.hier.addInherit(I1, I2);
|
||||
builder.methodref = I1;
|
||||
});
|
||||
|
||||
private static final Template NoMethodSelectionTemplateClassMethodref =
|
||||
new Template("NoMethodSelectionTemplate",
|
||||
/* objectref = methodref
|
||||
*
|
||||
* C[]() = mref = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
builder.objectref = builder.methodref;
|
||||
},
|
||||
/* Inherit methodref
|
||||
*
|
||||
* C2[]() = mref
|
||||
* C1[C2]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C1 = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int C2 = builder.methodref;
|
||||
builder.hier.addInherit(C1, C2);
|
||||
builder.objectref = C1;
|
||||
},
|
||||
/* Inherit methodref and interface
|
||||
*
|
||||
* C2[]() = mref, I[]()
|
||||
* C1[C2,I]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C2 = builder.methodref;
|
||||
final int C1 = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.hier.addInherit(C1, C2);
|
||||
builder.hier.addInherit(C1, I);
|
||||
builder.objectref = C1;
|
||||
},
|
||||
/* objectref = methodref, unrelated class defines
|
||||
*
|
||||
* C0[](def)
|
||||
* C[]() = mref = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
builder.addClass(withDef);
|
||||
builder.objectref = builder.methodref;
|
||||
},
|
||||
/* Inherit methodref, unrelated class defines
|
||||
*
|
||||
* C0[](def)
|
||||
* C2[]() = mref
|
||||
* C1[C2]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C1 = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int C2 = builder.methodref;
|
||||
builder.addClass(withDef);
|
||||
builder.hier.addInherit(C1, C2);
|
||||
builder.objectref = C1;
|
||||
},
|
||||
/* Inherit methodref and interface, unrelated class defines.
|
||||
*
|
||||
* C0[](def)
|
||||
* C2[]() = mref, I[]()
|
||||
* C1[C2,I]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C2 = builder.methodref;
|
||||
final int C1 = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.addClass(withDef);
|
||||
builder.hier.addInherit(C1, C2);
|
||||
builder.hier.addInherit(C1, I);
|
||||
builder.objectref = C1;
|
||||
},
|
||||
/* objectref = methodref, unrelated interface defines
|
||||
*
|
||||
* I0[](def)
|
||||
* C[]() = mref = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
builder.addInterface(withDef);
|
||||
builder.objectref = builder.methodref;
|
||||
},
|
||||
/* Inherit methodref, interface defines static
|
||||
*
|
||||
* C2[]() = mref, I0[](stat)
|
||||
* C1[C2]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C1 = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int C2 = builder.methodref;
|
||||
final int I0 = builder.addInterface(withStaticDef);
|
||||
builder.hier.addInherit(C1, C2);
|
||||
builder.hier.addInherit(C1, I0);
|
||||
builder.objectref = C1;
|
||||
},
|
||||
/* Inherit methodref, interface defines private
|
||||
*
|
||||
* C2[]() = mref, I0[](stat)
|
||||
* C1[C2]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C1 = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int C2 = builder.methodref;
|
||||
final int I0 = builder.addInterface(withPrivateDef);
|
||||
builder.hier.addInherit(C1, C2);
|
||||
builder.hier.addInherit(C1, I0);
|
||||
builder.objectref = C1;
|
||||
});
|
||||
|
||||
private static final Template NoMethodSelectionTemplateIfaceMethodref =
|
||||
new Template("NoMethodSelectionTemplate",
|
||||
/* Inherit methodref
|
||||
*
|
||||
* I[]() = mref
|
||||
* C[I]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I = builder.methodref;
|
||||
builder.hier.addInherit(C, I);
|
||||
builder.objectref = C;
|
||||
},
|
||||
/* Inherit methodref and interface
|
||||
*
|
||||
* I1[]() = mref, I2[]()
|
||||
* C[T,I]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int I1 = builder.methodref;
|
||||
final int C = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I2 = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.hier.addInherit(C, I1);
|
||||
builder.hier.addInherit(C, I2);
|
||||
builder.objectref = C;
|
||||
},
|
||||
/* Inherit methodref, unrelated class defines
|
||||
*
|
||||
* C0[](def)
|
||||
* I[]() = mref
|
||||
* C[I]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I = builder.methodref;
|
||||
builder.addClass(withDef);
|
||||
builder.hier.addInherit(C, I);
|
||||
builder.objectref = C;
|
||||
},
|
||||
/* Inherit methodref and interface, unrelated class defines
|
||||
*
|
||||
* C0[](def)
|
||||
* I1[]() = mref, I2[]()
|
||||
* C[I1,I2]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int I1 = builder.methodref;
|
||||
final int C = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I2 = builder.addInterface(Template.emptyClass(ClassData.Package.SAME));
|
||||
builder.addClass(withDef);
|
||||
builder.hier.addInherit(C, I1);
|
||||
builder.hier.addInherit(C, I2);
|
||||
builder.objectref = C;
|
||||
},
|
||||
/* Inherit methodref, interface defines static
|
||||
*
|
||||
* I[]() = mref, I0[](stat)
|
||||
* C[I,I0]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I = builder.methodref;
|
||||
final int I0 = builder.addInterface(withStaticDef);
|
||||
builder.hier.addInherit(C, I);
|
||||
builder.hier.addInherit(C, I0);
|
||||
builder.objectref = C;
|
||||
},
|
||||
/* Inherit methodref, unrelated class defines private
|
||||
*
|
||||
* I[]() = mref, I0[](priv)
|
||||
* C[I,I0]() = oref
|
||||
*/
|
||||
(final SelectionResolutionTestCase.Builder builder) -> {
|
||||
final int C = builder.addClass(Template.emptyClass(ClassData.Package.SAME));
|
||||
final int I = builder.methodref;
|
||||
final int I0 = builder.addInterface(withPrivateDef);
|
||||
builder.hier.addInherit(C, I);
|
||||
builder.hier.addInherit(C, I0);
|
||||
builder.objectref = C;
|
||||
});
|
||||
|
||||
private static final Collection<TestGroup> testgroups =
|
||||
Arrays.asList(
|
||||
/* invokestatic tests */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
NoMethodResolutionTemplateClassBottom,
|
||||
Template.AllCallsiteCases,
|
||||
Template.TrivialObjectref),
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKESTATIC),
|
||||
NoMethodResolutionTemplateIfaceBottom,
|
||||
Template.CallsiteNotEqualsMethodref,
|
||||
Template.TrivialObjectref),
|
||||
/* invokevirtual tests */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
NoMethodResolutionTemplateClassBottom,
|
||||
Template.AllCallsiteCases,
|
||||
NoMethodSelectionTemplateClassMethodref),
|
||||
/* invokeinterface tests */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
NoMethodResolutionTemplateIfaceBottom,
|
||||
Template.CallsiteNotEqualsMethodref,
|
||||
NoMethodSelectionTemplateIfaceMethodref),
|
||||
|
||||
/* Hiding of private interface methods */
|
||||
/* invokevirtual */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEVIRTUAL),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.MethodrefNotEqualsExpectedIface,
|
||||
Template.AllCallsiteCases,
|
||||
Template.TrivialObjectref),
|
||||
/* invokeinterface */
|
||||
new TestGroup.Simple(initBuilder,
|
||||
Template.SetInvoke(SelectionResolutionTestCase.InvokeInstruction.INVOKEINTERFACE),
|
||||
Template.ResultCombo(EnumSet.of(Template.Kind.INTERFACE),
|
||||
EnumSet.of(MethodData.Access.PRIVATE),
|
||||
EnumSet.of(MethodData.Context.INSTANCE,
|
||||
MethodData.Context.ABSTRACT),
|
||||
EnumSet.of(ClassData.Package.SAME,
|
||||
ClassData.Package.DIFFERENT)),
|
||||
Template.IfaceMethodrefNotEqualsExpected,
|
||||
Template.AllCallsiteCases,
|
||||
Template.TrivialObjectrefNotEqualMethodref)
|
||||
);
|
||||
|
||||
private NoSuchMethodErrorTest() {
|
||||
super(testgroups);
|
||||
}
|
||||
|
||||
public static void main(final String... args) {
|
||||
new NoSuchMethodErrorTest().run();
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
abstract class Builder {
|
||||
protected final SelectionResolutionTestCase testcase;
|
||||
protected final HierarchyShape hier;
|
||||
protected final HashMap<Integer,ClassData> classdata;
|
||||
|
||||
public Builder(SelectionResolutionTestCase testcase) {
|
||||
this.testcase = testcase;
|
||||
this.hier = testcase.hier;
|
||||
this.classdata = testcase.classdata;
|
||||
}
|
||||
|
||||
protected String getName(int id) {
|
||||
StringBuilder name = new StringBuilder();
|
||||
|
||||
name.append(getPackageName(classdata.get(id).packageId.ordinal()));
|
||||
|
||||
// Name classes C<id> and interfaces I<id>
|
||||
name.append(getClassName(id));
|
||||
|
||||
return name.toString();
|
||||
}
|
||||
|
||||
protected String getPackageName(int packageId) {
|
||||
return "P" + packageId + "/";
|
||||
}
|
||||
|
||||
protected String getClassName(int id) {
|
||||
// Name classes C<id> and interfaces I<id>
|
||||
if (isClass(id)) {
|
||||
return "C" + id;
|
||||
} else {
|
||||
return "I" + id;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isClass(int id) {
|
||||
return hier.isClass(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
public class ByteCodeClassLoader extends ClassLoader {
|
||||
ArrayList<ClassConstruct> classes = new ArrayList<>();
|
||||
HashMap<String, Class> loadedClasses = new HashMap<>();
|
||||
|
||||
public void addClasses(ClassConstruct... classes) {
|
||||
this.classes.addAll(Arrays.asList(classes));
|
||||
}
|
||||
|
||||
public void loadAll() throws ClassNotFoundException {
|
||||
for (ClassConstruct clazz : classes) {
|
||||
findClass(clazz.getDottedName());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class findClass(String name) throws ClassNotFoundException {
|
||||
|
||||
Class cls = loadedClasses.get(name);
|
||||
|
||||
if (cls != null) {
|
||||
return cls;
|
||||
}
|
||||
|
||||
for (ClassConstruct clazz : classes) {
|
||||
if (clazz.getDottedName().equals(name)) {
|
||||
return load(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class loadClass(String name) throws ClassNotFoundException {
|
||||
try {
|
||||
return findClass(name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
return super.loadClass(name);
|
||||
}
|
||||
}
|
||||
|
||||
private Class load(ClassConstruct clazz) {
|
||||
byte[] bytecode = clazz.generateBytes();
|
||||
Class loadedClass = defineClass(clazz.getDottedName(), bytecode, 0, bytecode.length);
|
||||
loadedClasses.put(clazz.getDottedName(), loadedClass);
|
||||
return loadedClass;
|
||||
}
|
||||
}
|
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_ABSTRACT;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PRIVATE;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PROTECTED;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC;
|
||||
|
||||
/**
|
||||
* Constructs classes and interfaces based on the information from a
|
||||
* DefaultMethodTestCase
|
||||
*
|
||||
*/
|
||||
public class ClassBuilder extends Builder {
|
||||
private final ArrayList<ClassConstruct> classes;
|
||||
|
||||
// Add a class in every package to be able to instantiate package
|
||||
// private classes from outside the package
|
||||
private final Clazz[] helpers = new Clazz[4];
|
||||
private ClassConstruct callsiteClass;
|
||||
|
||||
public enum ExecutionMode { DIRECT, INDY, MH_INVOKE_EXACT, MH_INVOKE_GENERIC}
|
||||
private final ExecutionMode execMode;
|
||||
|
||||
public ClassBuilder(SelectionResolutionTestCase testcase,
|
||||
ExecutionMode execMode) {
|
||||
super(testcase);
|
||||
this.classes = new ArrayList<>();
|
||||
this.execMode = execMode;
|
||||
}
|
||||
|
||||
public ClassConstruct[] build() throws Exception {
|
||||
buildClassConstructs();
|
||||
return classes.toArray(new ClassConstruct[0]);
|
||||
}
|
||||
|
||||
public ClassConstruct getCallsiteClass() {
|
||||
return callsiteClass;
|
||||
}
|
||||
|
||||
private void buildClassConstructs() throws Exception {
|
||||
TestBuilder tb = new TestBuilder(testcase.methodref, testcase);
|
||||
|
||||
classes.add(new Clazz("Test", ACC_PUBLIC, -1));
|
||||
|
||||
for (int classId = 0; classId < classdata.size(); classId++) {
|
||||
ClassConstruct C;
|
||||
String[] interfaces = getInterfaces(classId);
|
||||
ClassData data = classdata.get(classId);
|
||||
|
||||
if (isClass(classId)) {
|
||||
C = new Clazz(getName(classId),
|
||||
getExtending(classId),
|
||||
getClassModifiers(data),
|
||||
classId,
|
||||
interfaces);
|
||||
|
||||
addHelperMethod(classId);
|
||||
|
||||
} else {
|
||||
C = new Interface(getName(classId),
|
||||
getAccessibility(data.access),
|
||||
classId, interfaces);
|
||||
}
|
||||
|
||||
// Add a method "m()LTestObject;" if applicable
|
||||
if (containsMethod(data)) {
|
||||
// Method will either be abstract or concrete depending on the
|
||||
// abstract modifier
|
||||
C.addTestMethod(getMethodModifiers(data));
|
||||
}
|
||||
|
||||
if (classId == testcase.callsite) {
|
||||
// Add test() method
|
||||
tb.addTest(C, execMode);
|
||||
callsiteClass = C;
|
||||
}
|
||||
|
||||
classes.add(C);
|
||||
}
|
||||
classes.add(tb.getMainTestClass());
|
||||
|
||||
}
|
||||
|
||||
private void addHelperMethod(int classId) {
|
||||
int packageId = classdata.get(classId).packageId.ordinal();
|
||||
Clazz C = helpers[packageId];
|
||||
if (C == null) {
|
||||
C = new Clazz(getPackageName(packageId) + "Helper", -1, ACC_PUBLIC);
|
||||
helpers[packageId] = C;
|
||||
classes.add(C);
|
||||
}
|
||||
|
||||
Method m = C.addMethod("get" + getClassName(classId),
|
||||
"()L" + getName(classId) + ";",
|
||||
ACC_PUBLIC + ACC_STATIC);
|
||||
m.makeInstantiateMethod(getName(classId));
|
||||
}
|
||||
|
||||
private String[] getInterfaces(int classId) {
|
||||
ArrayList<String> interfaces = new ArrayList<>();
|
||||
|
||||
// Figure out if we're extending/implementing an interface
|
||||
for (final int intf : hier.interfaces()) {
|
||||
if (hier.inherits(classId, intf)) {
|
||||
interfaces.add(getName(intf));
|
||||
}
|
||||
}
|
||||
return interfaces.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private String getExtending(int classId) {
|
||||
int extending = -1;
|
||||
|
||||
// See if we're extending another class
|
||||
for (final int extendsClass : hier.classes()) {
|
||||
if (hier.inherits(classId, extendsClass)) {
|
||||
// Sanity check that we haven't already found an extending class
|
||||
if (extending != -1) {
|
||||
throw new RuntimeException("Multiple extending classes");
|
||||
}
|
||||
extending = extendsClass;
|
||||
}
|
||||
}
|
||||
|
||||
return extending == -1 ? null : getName(extending);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns modifiers for a Class
|
||||
* @param cd ClassData for the Class
|
||||
* @return ASM modifiers for a Class
|
||||
*/
|
||||
private int getClassModifiers(ClassData cd) {
|
||||
// For Classes we only care about accessibility (public, private etc)
|
||||
return getAccessibility(cd.access) | getAbstraction(cd.abstraction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns modifiers for Method type
|
||||
* @param cd ClassData for the Class or Interface where the Method resides
|
||||
* @return ASM modifiers for the Method
|
||||
*/
|
||||
private int getMethodModifiers(ClassData cd) {
|
||||
int mod = 0;
|
||||
|
||||
// For methods we want everything
|
||||
mod += getAccessibility(cd.methoddata.access);
|
||||
mod += getAbstraction(cd.methoddata.context);
|
||||
mod += getContext(cd.methoddata.context);
|
||||
mod += getExtensibility();
|
||||
return mod;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert ClassData access type to ASM
|
||||
* @param access
|
||||
* @return ASM version of accessibility (public / private / protected)
|
||||
*/
|
||||
private int getAccessibility(MethodData.Access access) {
|
||||
switch(access) {
|
||||
case PACKAGE:
|
||||
//TODO: Do I need to set this or will this be the default?
|
||||
return 0;
|
||||
case PRIVATE:
|
||||
return ACC_PRIVATE;
|
||||
case PROTECTED:
|
||||
return ACC_PROTECTED;
|
||||
case PUBLIC:
|
||||
return ACC_PUBLIC;
|
||||
default:
|
||||
throw new RuntimeException("Illegal accessibility modifier: " + access);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert ClassData abstraction type to ASM
|
||||
* @param abstraction
|
||||
* @return ASM version of abstraction (abstract / non-abstract)
|
||||
*/
|
||||
private int getAbstraction(MethodData.Context context) {
|
||||
return context == MethodData.Context.ABSTRACT ? ACC_ABSTRACT : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert ClassData context type to ASM
|
||||
* @param context
|
||||
* @return ASM version of context (static / non-static)
|
||||
*/
|
||||
private int getContext(MethodData.Context context) {
|
||||
return context == MethodData.Context.STATIC ? ACC_STATIC : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert ClassData extensibility type to ASM
|
||||
* @param extensibility
|
||||
* @return ASM version of extensibility (final / non-final)
|
||||
*/
|
||||
private int getExtensibility() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if we need a method at all, abstraction is set to null if this
|
||||
* Class/Interface should not have a test method
|
||||
* @param cd
|
||||
* @return
|
||||
*/
|
||||
private boolean containsMethod(ClassData cd) {
|
||||
return cd.methoddata != null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||
import jdk.internal.org.objectweb.asm.Opcodes;
|
||||
|
||||
public abstract class ClassConstruct {
|
||||
private final ClassWriter cw;
|
||||
private final String name;
|
||||
private final boolean isInterface;
|
||||
private final int index;
|
||||
|
||||
/**
|
||||
* Base constructor for building a Class or Interface
|
||||
* @param name Name of Class/Interface, including package name
|
||||
* @param extending Name of extending Class if any
|
||||
* @param access Access for Class/Interface
|
||||
* @param classFileVersion Class file version
|
||||
* @param interfaces Interface implemented
|
||||
*/
|
||||
public ClassConstruct(String name,
|
||||
String extending,
|
||||
int access,
|
||||
int classFileVersion,
|
||||
int index,
|
||||
String... interfaces) {
|
||||
this.name = name;
|
||||
isInterface = (access & Opcodes.ACC_INTERFACE) == Opcodes.ACC_INTERFACE;
|
||||
cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
||||
cw.visit(classFileVersion, access, name, null, extending, interfaces == null ? new String[] { } : interfaces);
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full Class/Interface name including package name, as it
|
||||
* should appear in a classfile.
|
||||
*
|
||||
* @return The full Class/Interface name including package name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the class, including package as it would appear
|
||||
* in Java source.
|
||||
*
|
||||
* @return The name of the class as it would appear in Java source.
|
||||
*/
|
||||
public String getDottedName() {
|
||||
return name.replace("/", ".");
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
final int idx = name.lastIndexOf('/');
|
||||
if (idx != -1) {
|
||||
return name.substring(0, name.indexOf('/'));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
final int idx = name.lastIndexOf('/');
|
||||
if (idx != -1) {
|
||||
return name.substring(name.indexOf('/'));
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a method, no code associated with it yet
|
||||
* @param name Name of method
|
||||
* @param descriptor Descriptor for method
|
||||
* @param access Access for the method
|
||||
* @return Method object that can be used for constructing a method body
|
||||
*/
|
||||
public Method addMethod(String name,
|
||||
String descriptor,
|
||||
int access) {
|
||||
return addMethod(name, descriptor, access, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a method, no code associated with it yet
|
||||
* @param name Name of method
|
||||
* @param descriptor Descriptor for method
|
||||
* @param access Access for the method
|
||||
* @param execMode The execution mode for the method.
|
||||
* @return Method object that can be used for constructing a method body
|
||||
*/
|
||||
public Method addMethod(String name,
|
||||
String descriptor,
|
||||
int access,
|
||||
ClassBuilder.ExecutionMode execMode) {
|
||||
return new Method(this, cw, name, descriptor, access, execMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a m()LTestObject; method which returns null unless the method is abstract
|
||||
* @param access Access for the method
|
||||
*/
|
||||
public void addTestMethod(int access) {
|
||||
Method m = new Method(this, cw, Method.defaultMethodName, Method.defaultMethodDescriptor, access, null);
|
||||
if ((access & Opcodes.ACC_ABSTRACT) != Opcodes.ACC_ABSTRACT) {
|
||||
m.makeDefaultMethod();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the class to a byte[]
|
||||
* @return byte[] with class file
|
||||
*/
|
||||
public byte[] generateBytes() {
|
||||
cw.visitEnd();
|
||||
return cw.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out a class to a file in the specified directory.
|
||||
*
|
||||
* @param dir Directory to which to write out the file.
|
||||
*/
|
||||
public void writeClass(final File dir) throws Exception {
|
||||
final String pkgname = getPackageName();
|
||||
final File pkgdir = pkgname != null ? new File(dir, getPackageName()) : dir;
|
||||
pkgdir.mkdirs();
|
||||
final File out = new File(pkgdir, getClassName() + ".class");
|
||||
out.createNewFile();
|
||||
try (final FileOutputStream fos = new FileOutputStream(out)) {
|
||||
fos.write(generateBytes());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInterface() {
|
||||
return isInterface;
|
||||
}
|
||||
|
||||
public Integer getIndex() {
|
||||
return index;
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
/**
|
||||
* A representation of information about a class. Note that classes
|
||||
* here define only one method.
|
||||
*/
|
||||
public class ClassData {
|
||||
|
||||
public enum Package {
|
||||
/**
|
||||
* Same package as the callsite.
|
||||
*/
|
||||
SAME,
|
||||
/**
|
||||
* Different package from the callsite.
|
||||
*/
|
||||
DIFFERENT,
|
||||
/**
|
||||
* Same as DIFFERENT, and also implies that the class access
|
||||
* is package-private.
|
||||
*/
|
||||
INACCESSIBLE,
|
||||
/**
|
||||
* Different from everything else. Used in selection only, to
|
||||
* test skipping package-private definitions.
|
||||
*/
|
||||
OTHER,
|
||||
/**
|
||||
* Placeholder, used solely by the template dumper for
|
||||
* printing out the effects of templates. Don't use for
|
||||
* anything else.
|
||||
*/
|
||||
PLACEHOLDER;
|
||||
}
|
||||
|
||||
/**
|
||||
* The package ID for the class.
|
||||
*/
|
||||
public final Package packageId;
|
||||
|
||||
/**
|
||||
* The method data for the method definition. If there is no
|
||||
* method definition, this will be null.
|
||||
*/
|
||||
public final MethodData methoddata;
|
||||
|
||||
/**
|
||||
* The class access. Note that this is controlled by the packageId.
|
||||
*/
|
||||
public final MethodData.Access access;
|
||||
|
||||
// This is a hardwired value necessary for ClassBuilder
|
||||
public final MethodData.Context abstraction = MethodData.Context.INSTANCE;
|
||||
|
||||
public ClassData(final Package packageId,
|
||||
final MethodData methoddata) {
|
||||
this.packageId = packageId;
|
||||
this.methoddata = methoddata;
|
||||
|
||||
if (packageId == Package.INACCESSIBLE)
|
||||
access = MethodData.Access.PACKAGE;
|
||||
else
|
||||
access = MethodData.Access.PUBLIC;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(" { ");
|
||||
|
||||
if (methoddata != null) {
|
||||
sb.append(methoddata);
|
||||
}
|
||||
|
||||
sb.append(" }\n\n");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.V1_8;
|
||||
|
||||
|
||||
class Clazz extends ClassConstruct {
|
||||
|
||||
/**
|
||||
* Construct a Class
|
||||
* @param name Name of Class
|
||||
* @param access Access for the Class
|
||||
*/
|
||||
public Clazz(String name, int access, int index) {
|
||||
this(name, null, access, V1_8, index, new String[] { });
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a Class
|
||||
* @param name Name of Class
|
||||
* @param extending Class being extended
|
||||
* @param access Access for the Class
|
||||
*/
|
||||
public Clazz(String name, String extending, int access, int index) {
|
||||
this(name, extending, access, V1_8, index, new String[] { });
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a Class
|
||||
* @param name Name of Class
|
||||
* @param extending Class being extended
|
||||
* @param access access for the Class
|
||||
* @param implementing Interfaces implemented
|
||||
*/
|
||||
public Clazz(String name, String extending, int access, int index, String... implementing) {
|
||||
this(name, extending, access, V1_8, index, implementing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a Class
|
||||
* @param name Name of Class
|
||||
* @param extending Class being extended
|
||||
* @param access Access for the Class
|
||||
* @param classFileVersion Class file version
|
||||
* @param implementing Interfaces implemented
|
||||
*/
|
||||
public Clazz(String name, String extending, int access, int classFileVersion, int index, String... implementing) {
|
||||
super(name, extending == null ? "java/lang/Object" : extending, access + ACC_SUPER, classFileVersion, index, implementing);
|
||||
// Add the default constructor
|
||||
addMethod("<init>", "()V", ACC_PUBLIC).makeConstructor(extending);
|
||||
}
|
||||
}
|
@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A representation of a class/interface hierarchy graph (just the
|
||||
* graph; the class data is represented elsewhere).
|
||||
*/
|
||||
public class HierarchyShape {
|
||||
public static final int OBJECT_CLASS = -1;
|
||||
|
||||
protected int maxId;
|
||||
|
||||
/**
|
||||
* The names of all the classes.
|
||||
*/
|
||||
private final HashSet<Integer> classes;
|
||||
|
||||
/**
|
||||
* The names of all the interfaces.
|
||||
*/
|
||||
private final HashSet<Integer> interfaces;
|
||||
private final HashMap<Integer, HashSet<Integer>> extensions;
|
||||
|
||||
/**
|
||||
* Create an empty hierarchy shape.
|
||||
*/
|
||||
public HierarchyShape() {
|
||||
this(0, new HashSet<>(), new HashSet<>(), new HashMap<>());
|
||||
}
|
||||
|
||||
private HierarchyShape(final int maxId,
|
||||
final HashSet<Integer> classes,
|
||||
final HashSet<Integer> interfaces,
|
||||
final HashMap<Integer, HashSet<Integer>> extensions) {
|
||||
this.maxId = maxId;
|
||||
this.classes = classes;
|
||||
this.interfaces = interfaces;
|
||||
this.extensions = extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a copy of this hierarchy shape.
|
||||
*/
|
||||
public HierarchyShape copy() {
|
||||
final HashMap<Integer, HashSet<Integer>> newextensions = new HashMap<>();
|
||||
|
||||
for(final Map.Entry<Integer, HashSet<Integer>> entry :
|
||||
extensions.entrySet()) {
|
||||
newextensions.put(entry.getKey(),
|
||||
(HashSet<Integer>)entry.getValue().clone());
|
||||
}
|
||||
|
||||
return new HierarchyShape(maxId, (HashSet<Integer>) classes.clone(),
|
||||
(HashSet<Integer>) interfaces.clone(),
|
||||
newextensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a class, and return its id.
|
||||
*
|
||||
* @return The new class id.
|
||||
*/
|
||||
public int addClass() {
|
||||
final int id = maxId++;
|
||||
classes.add(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an interface, and return its id.
|
||||
*
|
||||
* @return The new interface id.
|
||||
*/
|
||||
public int addInterface() {
|
||||
final int id = maxId++;
|
||||
interfaces.add(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an inheritance.
|
||||
*
|
||||
* @param sub The sub class/interface.
|
||||
* @param sup The super class/interface
|
||||
*/
|
||||
public void addInherit(final int sub,
|
||||
final int sup) {
|
||||
HashSet<Integer> ext = extensions.get(sub);
|
||||
|
||||
if (ext == null) {
|
||||
ext = new HashSet<>();
|
||||
extensions.put(sub, ext);
|
||||
}
|
||||
|
||||
ext.add(sup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String out = "";
|
||||
for(int i = maxId - 1; i >= 0; i--) {
|
||||
out += i + ": ";
|
||||
for(int j = 0; j < maxId; j++) {
|
||||
out += "[" + (inherits(i, j) ? "1" : "0") + "]";
|
||||
}
|
||||
out += "\n";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate whether the first class inherits from the second.
|
||||
*
|
||||
* @param sub The possible subtype.
|
||||
* @param sup The possible supertype.
|
||||
* @return Whether or not {@code sub} inherits from {@code sup}.
|
||||
*/
|
||||
public boolean inherits(final int sub, final int sup) {
|
||||
final Set<Integer> ext = extensions.get(sub);
|
||||
if (ext != null) {
|
||||
return ext.contains(sup);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate whether a given type name is a class.
|
||||
*
|
||||
* @param id The type in question.
|
||||
* @return Whether or not the type is a class.
|
||||
*/
|
||||
public boolean isClass(final int id) {
|
||||
if (id == OBJECT_CLASS) {
|
||||
return true;
|
||||
}
|
||||
return classes.contains(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate whether a given type name is an interface.
|
||||
*
|
||||
* @param id The type in question.
|
||||
* @return Whether or not the type is an interface.
|
||||
*/
|
||||
public boolean isInterface(final int id) {
|
||||
if (id == OBJECT_CLASS) {
|
||||
return false;
|
||||
}
|
||||
return interfaces.contains(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an iterator over the classes.
|
||||
*
|
||||
* @return An iterator over classes.
|
||||
*/
|
||||
public Collection<Integer> classes() {
|
||||
return classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an iterator over the interfaces.
|
||||
*
|
||||
* @return An iterator over interfaces.
|
||||
*/
|
||||
public Collection<Integer> interfaces() {
|
||||
return interfaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an iterator over all types.
|
||||
*
|
||||
* @return An iterator over all types.
|
||||
*/
|
||||
public Collection<Integer> types() {
|
||||
final Set<Integer> combined = new HashSet(classes);
|
||||
combined.addAll(interfaces);
|
||||
return combined;
|
||||
}
|
||||
|
||||
public int numClasses() {
|
||||
return classes.size();
|
||||
}
|
||||
|
||||
public int numInterfaces() {
|
||||
return interfaces.size();
|
||||
}
|
||||
|
||||
public int numTypes() {
|
||||
return numClasses() + numInterfaces();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_ABSTRACT;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_INTERFACE;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.V1_8;
|
||||
|
||||
class Interface extends ClassConstruct {
|
||||
|
||||
public Interface(String name, int access, int index) {
|
||||
this(name, V1_8, access, index, (String)null);
|
||||
}
|
||||
|
||||
public Interface(String name, int index) {
|
||||
this(name, V1_8, index, (String)null);
|
||||
}
|
||||
|
||||
|
||||
public Interface(String name, int access, int index, String... extending) {
|
||||
this(name, V1_8, access, index, extending);
|
||||
}
|
||||
|
||||
public Interface(String name, int classFileVersion, int access, int index, String... extending) {
|
||||
super(name, "java/lang/Object", access + ACC_ABSTRACT + ACC_INTERFACE, classFileVersion, index, extending);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,266 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import jdk.internal.org.objectweb.asm.ClassVisitor;
|
||||
import jdk.internal.org.objectweb.asm.Handle;
|
||||
import jdk.internal.org.objectweb.asm.MethodVisitor;
|
||||
|
||||
import java.lang.invoke.CallSite;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ALOAD;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ARETURN;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.DUP;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.POP;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.NEW;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.SWAP;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ASTORE;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.RETURN;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESPECIAL;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESTATIC;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKEINTERFACE;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESPECIAL;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESTATIC;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKEINTERFACE;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKEVIRTUAL;
|
||||
|
||||
class Method {
|
||||
public static final String defaultMethodName = "m";
|
||||
public static final String defaultMethodDescriptor = "()Ljava/lang/Integer;";
|
||||
public static final String methodDescriptorTemplate = "(L%s;)Ljava/lang/Integer;";
|
||||
private final ClassConstruct ownerClass;
|
||||
private final String ownerClassName;
|
||||
private final ClassVisitor cv;
|
||||
private final MethodVisitor mv;
|
||||
private final boolean isInterface;
|
||||
private final ClassBuilder.ExecutionMode execMode;
|
||||
|
||||
public Method(ClassConstruct ownerClass, ClassVisitor cv, String name, String descriptor, int access,
|
||||
ClassBuilder.ExecutionMode execMode) {
|
||||
this.ownerClassName = ownerClass.getName();
|
||||
this.ownerClass = ownerClass;
|
||||
this.isInterface = ownerClass.isInterface();
|
||||
this.execMode = execMode;
|
||||
this.cv = cv;
|
||||
mv = cv.visitMethod(access, name, descriptor, null, null);
|
||||
mv.visitCode();
|
||||
}
|
||||
/**
|
||||
* Add code for the m()Ljava/lang/Integer; method, always returns null
|
||||
*/
|
||||
public void makeDefaultMethod() {
|
||||
mv.visitTypeInsn(NEW, "java/lang/Integer");
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitLdcInsn(ownerClass.getIndex());
|
||||
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Integer", "<init>", "(I)V");
|
||||
mv.visitInsn(ARETURN);
|
||||
mv.visitMaxs(0, 0);
|
||||
mv.visitEnd();
|
||||
}
|
||||
|
||||
public void makePrivateCallMethod(String className) {
|
||||
makeSuperCallMethod(INVOKESPECIAL, className);
|
||||
}
|
||||
|
||||
public void makeSuperCallMethod(int invokeInstruction, String className) {
|
||||
mv.visitVarInsn(ALOAD, 0);
|
||||
makeCall(invokeInstruction, className);
|
||||
mv.visitInsn(POP);
|
||||
done();
|
||||
}
|
||||
|
||||
public void defaultInvoke(int instr, String className, String objectRef) {
|
||||
switch (instr) {
|
||||
case INVOKEVIRTUAL:
|
||||
defaultInvokeVirtual(className, objectRef);
|
||||
break;
|
||||
case INVOKEINTERFACE:
|
||||
defaultInvokeInterface(className, objectRef);
|
||||
break;
|
||||
case INVOKESTATIC:
|
||||
defaultInvokeStatic(className);
|
||||
break;
|
||||
case INVOKESPECIAL:
|
||||
defaultInvokeSpecial(className, objectRef);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
mv.visitInsn(ARETURN);
|
||||
mv.visitMaxs(0, 0);
|
||||
mv.visitEnd();
|
||||
}
|
||||
|
||||
public void defaultInvokeVirtual(String className, String objectRef) {
|
||||
String objectRefPackageName = objectRef.substring(0, objectRef.lastIndexOf("/"));
|
||||
makeNewObject(objectRef, objectRefPackageName);
|
||||
makeCall(INVOKEVIRTUAL, className, false);
|
||||
}
|
||||
|
||||
public void defaultInvokeInterface(String className, String objectRef) {
|
||||
String objectRefPackageName = objectRef.substring(0, objectRef.lastIndexOf("/"));
|
||||
makeNewObject(objectRef, objectRefPackageName);
|
||||
makeCall(INVOKEINTERFACE, className, true);
|
||||
}
|
||||
|
||||
public void defaultInvokeSpecial(String className, String objectRef) {
|
||||
String objectRefPackageName = objectRef.substring(0, objectRef.lastIndexOf("/"));
|
||||
makeNewObject(objectRef, objectRefPackageName);
|
||||
makeCall(INVOKESPECIAL, className, false);
|
||||
}
|
||||
|
||||
public void defaultInvokeStatic(String className) {
|
||||
makeCall(INVOKESTATIC, className);
|
||||
}
|
||||
|
||||
private Method makeCall(int invokeInstruction, String className) {
|
||||
return makeCall(invokeInstruction, className, isInterface);
|
||||
}
|
||||
|
||||
private Method makeCall(int invokeInstruction, String className, boolean isInterface) {
|
||||
switch(execMode) {
|
||||
case DIRECT: {
|
||||
mv.visitMethodInsn(invokeInstruction, className, defaultMethodName, defaultMethodDescriptor, isInterface);
|
||||
break;
|
||||
}
|
||||
case INDY: {
|
||||
Handle m = convertToHandle(invokeInstruction, className, defaultMethodName, defaultMethodDescriptor);
|
||||
Handle bsm = generateBootstrapMethod(m);
|
||||
mv.visitInvokeDynamicInsn(defaultMethodName, defaultMethodDescriptor, bsm);
|
||||
break;
|
||||
}
|
||||
case MH_INVOKE_EXACT:
|
||||
case MH_INVOKE_GENERIC: {
|
||||
String invokerName = execMode == ClassBuilder.ExecutionMode.MH_INVOKE_GENERIC
|
||||
? "invoke" : "invokeExact";
|
||||
|
||||
Handle m = convertToHandle(invokeInstruction, className, defaultMethodName, defaultMethodDescriptor);
|
||||
mv.visitLdcInsn(m);
|
||||
mv.visitInsn(SWAP);
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL,
|
||||
"java/lang/invoke/MethodHandle",
|
||||
invokerName,
|
||||
String.format(methodDescriptorTemplate, className),
|
||||
false);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Error("Unknown execution mode: " + execMode);
|
||||
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private Handle generateBootstrapMethod(Handle h) {
|
||||
String bootstrapName = "bootstrapMethod";
|
||||
MethodType bootstrapType = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class);
|
||||
|
||||
MethodVisitor bmv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, bootstrapName, bootstrapType.toMethodDescriptorString(), null, null);
|
||||
bmv.visitCode();
|
||||
|
||||
String constCallSite = "java/lang/invoke/ConstantCallSite";
|
||||
bmv.visitTypeInsn(NEW, constCallSite);
|
||||
bmv.visitInsn(DUP);
|
||||
|
||||
bmv.visitLdcInsn(h);
|
||||
|
||||
bmv.visitMethodInsn(INVOKESPECIAL, constCallSite, "<init>", "(Ljava/lang/invoke/MethodHandle;)V", false);
|
||||
bmv.visitInsn(ARETURN);
|
||||
|
||||
bmv.visitMaxs(0,0);
|
||||
bmv.visitEnd();
|
||||
|
||||
return new Handle(H_INVOKESTATIC, ownerClassName, bootstrapName, bootstrapType.toMethodDescriptorString());
|
||||
}
|
||||
|
||||
|
||||
private static Handle convertToHandle(int invokeInstruction, String className, String methodName, String methodDesc) {
|
||||
int tag;
|
||||
switch (invokeInstruction) {
|
||||
case INVOKEVIRTUAL: tag = H_INVOKEVIRTUAL; break;
|
||||
case INVOKEINTERFACE: tag = H_INVOKEINTERFACE; break;
|
||||
case INVOKESPECIAL: tag = H_INVOKESPECIAL; break;
|
||||
case INVOKESTATIC: tag = H_INVOKESTATIC; break;
|
||||
default:
|
||||
throw new Error("Unknown invoke instruction: "+invokeInstruction);
|
||||
}
|
||||
|
||||
return new Handle(tag, className, methodName, methodDesc);
|
||||
}
|
||||
|
||||
private void makeNewObject(String objectRef, String objectRefPackageName) {
|
||||
String className = objectRef.substring(objectRef.lastIndexOf("/") + 1);
|
||||
makeStaticCall( objectRefPackageName + "/Helper",
|
||||
"get" + className,
|
||||
"()L" + objectRef + ";");
|
||||
mv.visitVarInsn(ASTORE, 1);
|
||||
mv.visitVarInsn(ALOAD, 1);
|
||||
}
|
||||
|
||||
public void makeTestCall(String className) {
|
||||
mv.visitTypeInsn(NEW, className);
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitMethodInsn(INVOKESPECIAL, className, "<init>", "()V", false);
|
||||
mv.visitVarInsn(ASTORE, 1);
|
||||
mv.visitVarInsn(ALOAD, 1);
|
||||
mv.visitMethodInsn(INVOKEVIRTUAL, className, "test", "()Ljava/lang/Integer;", false);
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(2, 2);
|
||||
mv.visitEnd();
|
||||
}
|
||||
|
||||
public Method makeStaticCall(String classname, String method, String descriptor) {
|
||||
mv.visitMethodInsn(INVOKESTATIC, classname, method, descriptor, isInterface);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void makeConstructor(String extending) {
|
||||
mv.visitVarInsn(ALOAD, 0);
|
||||
mv.visitMethodInsn(INVOKESPECIAL, extending == null ? "java/lang/Object" : extending, "<init>", "()V", isInterface);
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(0, 0);
|
||||
mv.visitEnd();
|
||||
}
|
||||
|
||||
public void makeInstantiateMethod(String className) {
|
||||
mv.visitTypeInsn(NEW, className);
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitMethodInsn(INVOKESPECIAL, className, "<init>", "()V", false);
|
||||
mv.visitInsn(ARETURN);
|
||||
mv.visitMaxs(0, 0);
|
||||
mv.visitEnd();
|
||||
}
|
||||
|
||||
public void done() {
|
||||
mv.visitInsn(RETURN);
|
||||
mv.visitMaxs(0, 0);
|
||||
mv.visitEnd();
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
/**
|
||||
* A representation of a method definition.
|
||||
*/
|
||||
public class MethodData {
|
||||
|
||||
public enum Access {
|
||||
PUBLIC(1),
|
||||
PACKAGE(0),
|
||||
PROTECTED(4),
|
||||
PRIVATE(2),
|
||||
/**
|
||||
* Placeholder, used solely for printing out the effects of
|
||||
* templates. Don't use.
|
||||
*/
|
||||
PLACEHOLDER(-1);
|
||||
|
||||
public final int flag;
|
||||
|
||||
Access(int flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Context {
|
||||
ABSTRACT,
|
||||
INSTANCE,
|
||||
STATIC,
|
||||
/**
|
||||
* Placeholder, used solely for printing out the effects of
|
||||
* templates. Don't use.
|
||||
*/
|
||||
PLACEHOLDER;
|
||||
};
|
||||
|
||||
/**
|
||||
* Access for the method.
|
||||
*/
|
||||
public final Access access;
|
||||
|
||||
/**
|
||||
* Context (static, instance, abstract) for the method.
|
||||
*/
|
||||
public final Context context;
|
||||
|
||||
/**
|
||||
* Create method data.
|
||||
*/
|
||||
public MethodData(final Access access,
|
||||
final Context context) {
|
||||
|
||||
this.access = access;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
switch (access) {
|
||||
case PUBLIC: sb.append("public"); break;
|
||||
case PACKAGE: sb.append("package"); break;
|
||||
case PROTECTED: sb.append("protected"); break;
|
||||
case PRIVATE: sb.append("private"); break;
|
||||
case PLACEHOLDER: sb.append(" _"); break;
|
||||
default: throw new RuntimeException("Impossible case");
|
||||
}
|
||||
|
||||
switch (context) {
|
||||
case STATIC: sb.append(" static"); break;
|
||||
case INSTANCE: sb.append(" instance"); break;
|
||||
case ABSTRACT: sb.append(" abstract"); break;
|
||||
case PLACEHOLDER: sb.append(" _"); break;
|
||||
default: throw new RuntimeException("Impossible case");
|
||||
}
|
||||
sb.append(" Integer m();");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,262 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Representation of an expected result.
|
||||
*/
|
||||
public interface Result {
|
||||
public static final Result ICCE = new Exception(IncompatibleClassChangeError.class);
|
||||
public static final Result IAE = new Exception(IllegalAccessError.class);
|
||||
public static final Result NSME = new Exception(NoSuchMethodError.class);
|
||||
public static final Result AME = new Exception(AbstractMethodError.class);
|
||||
|
||||
// Factories
|
||||
|
||||
/**
|
||||
* Create a result that expects the given class.
|
||||
*/
|
||||
public static Result is(int id) {
|
||||
return new Single(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a result that expects the given classes.
|
||||
*/
|
||||
public static Result is(int... multiple) {
|
||||
assert multiple.length > 0;
|
||||
|
||||
if (multiple.length == 1) {
|
||||
return new Single(multiple[0]);
|
||||
} else {
|
||||
return new Any(multiple);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a result that expects the given exception to be thrown.
|
||||
*/
|
||||
public static Result is(Class<? extends Throwable> exType) {
|
||||
return new Exception(exType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a result that expects the given exception to be thrown.
|
||||
*/
|
||||
public static Result is(Throwable ex) {
|
||||
return Result.is(ex.getClass());
|
||||
}
|
||||
|
||||
public static final Result EMPTY = new Empty();
|
||||
|
||||
/**
|
||||
* Create an empty Result.
|
||||
*/
|
||||
public static Result empty() {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
|
||||
public boolean complyWith(int i);
|
||||
public boolean complyWith(Throwable e);
|
||||
public boolean complyWith(Result r);
|
||||
|
||||
static class Empty implements Result {
|
||||
@Override
|
||||
public boolean complyWith(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complyWith(Throwable e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complyWith(Result r) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static class Single implements Result {
|
||||
public int id;
|
||||
|
||||
public Single(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complyWith(int i) {
|
||||
return id == i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complyWith(Throwable e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complyWith(Result r) {
|
||||
if (r instanceof Single) {
|
||||
return complyWith(((Single)r).id);
|
||||
} else if (r instanceof Any) {
|
||||
return r.complyWith(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Single)) return false;
|
||||
|
||||
Single single = (Single) o;
|
||||
|
||||
return (id == single.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("Result=Single{");
|
||||
sb.append("id=").append(id);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class Any implements Result {
|
||||
public int[] ids;
|
||||
public Any(int[] ids) {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complyWith(int i) {
|
||||
return Arrays.stream(ids)
|
||||
.anyMatch(j -> j == i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complyWith(Throwable e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complyWith(Result r) {
|
||||
if (r instanceof Single) {
|
||||
return complyWith(((Single)r).id);
|
||||
}
|
||||
if (r instanceof Any) {
|
||||
return Arrays.equals(ids, ((Any) r).ids);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Any any = (Any) o;
|
||||
|
||||
return Arrays.equals(ids, any.ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("Result=Any{");
|
||||
sb.append("ids=");
|
||||
if (ids == null) sb.append("null");
|
||||
else {
|
||||
sb.append('[');
|
||||
for (int i = 0; i < ids.length; ++i)
|
||||
sb.append(i == 0 ? "" : ", ").append(ids[i]);
|
||||
sb.append(']');
|
||||
}
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class Exception implements Result {
|
||||
public Class<? extends Throwable> exc;
|
||||
public Exception(Class<? extends Throwable> e) {
|
||||
this.exc = e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complyWith(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complyWith(Throwable e) {
|
||||
return exc.isAssignableFrom(e.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complyWith(Result r) {
|
||||
if (r instanceof Exception) {
|
||||
return exc.isAssignableFrom(((Exception) r).exc);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Exception)) return false;
|
||||
|
||||
Exception exception = (Exception) o;
|
||||
|
||||
return exc.equals(exception.exc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return exc.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer("Result=Exception{");
|
||||
sb.append("exc=").append(exc);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A master superclass for all selection/resolution tests. Contains a
|
||||
* couple of standard definitions that make writing these tests
|
||||
* easier.
|
||||
*/
|
||||
public abstract class SelectionResolutionTest {
|
||||
|
||||
/**
|
||||
* A unified output function, to ensure that all output goes to
|
||||
* the right string (System.err).
|
||||
*
|
||||
* @param str The line to print.
|
||||
*/
|
||||
protected void println(final String str) {
|
||||
System.err.println(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* A test group is a generator for a set of tests that should
|
||||
* share common characteristics. The Simple class provides a
|
||||
* default implementation that should work for most purposes.
|
||||
*/
|
||||
public static interface TestGroup {
|
||||
/**
|
||||
* Given an action that runs a given test case, generate and
|
||||
* run all cases in this test group.
|
||||
*/
|
||||
public void runCases(Consumer<SelectionResolutionTestCase> runner);
|
||||
|
||||
/**
|
||||
* The basic implementation of TestGroup. Produces one case
|
||||
* for every possible combination of cases from each of its
|
||||
* templates, by running them in order on an empty
|
||||
* SelectionResolutionTestCase.Builder. This should be good
|
||||
* enough for writing most tests.
|
||||
*/
|
||||
public static class Simple implements TestGroup {
|
||||
private final Template[] templates;
|
||||
private final SelectionResolutionTestCase.Builder initBuilder;
|
||||
|
||||
public Simple(final SelectionResolutionTestCase.Builder initBuilder,
|
||||
final Template... templates) {
|
||||
this.templates = templates;
|
||||
this.initBuilder = initBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCases(final Consumer<SelectionResolutionTestCase> runner) {
|
||||
Consumer<SelectionResolutionTestCase.Builder> curr = (builder) -> {
|
||||
runner.accept(builder.build());
|
||||
};
|
||||
|
||||
for(int i = templates.length - 1; i >= 0; i--) {
|
||||
final Consumer<SelectionResolutionTestCase.Builder> next = curr;
|
||||
final Template template = templates[i];
|
||||
curr = (builder) -> {
|
||||
template.runCases(next, builder);
|
||||
};
|
||||
}
|
||||
|
||||
curr.accept(initBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final List<String> errs = new LinkedList<String>();
|
||||
|
||||
private final Collection<TestGroup> testGroups;
|
||||
|
||||
private int testcount = 0;
|
||||
|
||||
/**
|
||||
* Create a test from a set of test groups. Most actual tests can
|
||||
* just define the test groups and pass them into this
|
||||
* constructor, then call run.
|
||||
*/
|
||||
protected SelectionResolutionTest(final Collection<TestGroup> testGroups) {
|
||||
this.testGroups = testGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run all the tests, report errors if they happen.
|
||||
*/
|
||||
protected void run() {
|
||||
testGroups.stream().forEach(
|
||||
(group) -> {
|
||||
group.runCases((final SelectionResolutionTestCase testcase) -> {
|
||||
testcount++;
|
||||
final String err = testcase.run();
|
||||
|
||||
if (err != null) {
|
||||
errs.add(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
println("Ran " + testcount + " cases");
|
||||
|
||||
if(!errs.isEmpty()) {
|
||||
println("Errors occurred in test:");
|
||||
for(final String err : errs) {
|
||||
println(err);
|
||||
}
|
||||
throw new RuntimeException("Errors occurred in test");
|
||||
} else {
|
||||
println("All test cases succeeded");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,452 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* One individual test case. This class also defines a builder, which
|
||||
* can be used to build up cases.
|
||||
*/
|
||||
public class SelectionResolutionTestCase {
|
||||
|
||||
public enum InvokeInstruction {
|
||||
INVOKESTATIC,
|
||||
INVOKESPECIAL,
|
||||
INVOKEINTERFACE,
|
||||
INVOKEVIRTUAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* The class data (includes interface data).
|
||||
*/
|
||||
public final HashMap<Integer, ClassData> classdata;
|
||||
/**
|
||||
* The hierarchy shape.
|
||||
*/
|
||||
public final HierarchyShape hier;
|
||||
/**
|
||||
* The invoke instruction to use.
|
||||
*/
|
||||
public final InvokeInstruction invoke;
|
||||
/**
|
||||
* Which class is the methodref (or interface methodref).
|
||||
*/
|
||||
public final int methodref;
|
||||
/**
|
||||
* Which class is the objectref.
|
||||
*/
|
||||
public final int objectref;
|
||||
/**
|
||||
* Which class is the callsite (this must be a class, not an interface.
|
||||
*/
|
||||
public final int callsite;
|
||||
/**
|
||||
* The expected result.
|
||||
*/
|
||||
public final Result result;
|
||||
|
||||
private SelectionResolutionTestCase(final HashMap<Integer, ClassData> classdata,
|
||||
final HierarchyShape hier,
|
||||
final InvokeInstruction invoke,
|
||||
final int methodref,
|
||||
final int objectref,
|
||||
final int callsite,
|
||||
final int expected) {
|
||||
this.classdata = classdata;
|
||||
this.hier = hier;
|
||||
this.invoke = invoke;
|
||||
this.methodref = methodref;
|
||||
this.objectref = objectref;
|
||||
this.callsite = callsite;
|
||||
this.result = Result.is(expected);
|
||||
}
|
||||
|
||||
private SelectionResolutionTestCase(final HashMap<Integer, ClassData> classdata,
|
||||
final HierarchyShape hier,
|
||||
final InvokeInstruction invoke,
|
||||
final int methodref,
|
||||
final int objectref,
|
||||
final int callsite,
|
||||
final Result result) {
|
||||
this.classdata = classdata;
|
||||
this.hier = hier;
|
||||
this.invoke = invoke;
|
||||
this.methodref = methodref;
|
||||
this.objectref = objectref;
|
||||
this.callsite = callsite;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
private static int currError = 0;
|
||||
|
||||
private String dumpClasses(final ClassConstruct[] classes)
|
||||
throws Exception {
|
||||
final String errorDirName = "error_" + currError++;
|
||||
final File errorDir = new File(errorDirName);
|
||||
errorDir.mkdirs();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
classes[i].writeClass(errorDir);
|
||||
}
|
||||
try (final FileWriter fos =
|
||||
new FileWriter(new File(errorDir, "description.txt"))) {
|
||||
fos.write(this.toString());
|
||||
}
|
||||
return errorDirName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run this case, return an error message, or null.
|
||||
*
|
||||
* @return An error message, or null if the case succeeded.
|
||||
*/
|
||||
public String run() {
|
||||
/* Uncomment this line to print EVERY case */
|
||||
//System.err.println("Running\n" + this);
|
||||
final ClassBuilder builder =
|
||||
new ClassBuilder(this, ClassBuilder.ExecutionMode.DIRECT);
|
||||
try {
|
||||
final ByteCodeClassLoader bcl = new ByteCodeClassLoader();
|
||||
final ClassConstruct[] classes = builder.build();
|
||||
|
||||
try {
|
||||
bcl.addClasses(classes);
|
||||
bcl.loadAll();
|
||||
|
||||
// Grab the callsite class.
|
||||
final Class testclass =
|
||||
bcl.findClass(builder.getCallsiteClass().getDottedName());
|
||||
|
||||
// Get the 'test' method out of it and call it. The
|
||||
// return value tess which class that got selected.
|
||||
final java.lang.reflect.Method method =
|
||||
testclass.getDeclaredMethod("test");
|
||||
final int actual = (Integer) method.invoke(null);
|
||||
// Check the result.
|
||||
if (!result.complyWith(actual)) {
|
||||
final String dump = dumpClasses(classes);
|
||||
return "Failed:\n" + this + "\nExpected " + result + " got " + actual + "\nClasses written to " + dump;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
// This catch block is handling exceptions that we
|
||||
// might expect to see.
|
||||
final Throwable actual = t.getCause();
|
||||
if (actual == null) {
|
||||
final String dump = dumpClasses(classes);
|
||||
System.err.println("Unexpected exception in test\n" + this + "\nClasses written to " + dump);
|
||||
throw t;
|
||||
} else if (result == null) {
|
||||
final String dump = dumpClasses(classes);
|
||||
return "Failed:\n" + this + "\nUnexpected exception " + actual + "\nClasses written to " + dump;
|
||||
} else if (!result.complyWith(actual)) {
|
||||
final String dump = dumpClasses(classes);
|
||||
return "Failed:\n" + this + "\nExpected " + this.result + " got " + actual + "\nClasses written to " + dump;
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void addPackage(final StringBuilder sb,
|
||||
final ClassData cd) {
|
||||
switch (cd.packageId) {
|
||||
case SAME: sb.append("Same."); break;
|
||||
case DIFFERENT: sb.append("Different."); break;
|
||||
case OTHER: sb.append("Other."); break;
|
||||
case PLACEHOLDER: sb.append("_."); break;
|
||||
default: throw new RuntimeException("Impossible case");
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
//sb.append("hierarchy:\n" + hier + "\n");
|
||||
sb.append("invoke: " + invoke + "\n");
|
||||
if (methodref != -1) {
|
||||
if (hier.isClass(methodref)) {
|
||||
sb.append("methodref: C" + methodref + "\n");
|
||||
} else {
|
||||
sb.append("methodref: I" + methodref + "\n");
|
||||
}
|
||||
}
|
||||
if (objectref != -1) {
|
||||
if (hier.isClass(objectref)) {
|
||||
sb.append("objectref: C" + objectref + "\n");
|
||||
} else {
|
||||
sb.append("objectref: I" + objectref + "\n");
|
||||
}
|
||||
}
|
||||
if (callsite != -1) {
|
||||
if (hier.isClass(callsite)) {
|
||||
sb.append("callsite: C" + callsite + "\n");
|
||||
} else {
|
||||
sb.append("callsite: I" + callsite + "\n");
|
||||
}
|
||||
}
|
||||
sb.append("result: " + result + "\n");
|
||||
sb.append("classes:\n\n");
|
||||
|
||||
for(int i = 0; classdata.containsKey(i); i++) {
|
||||
final ClassData cd = classdata.get(i);
|
||||
|
||||
if (hier.isClass(i)) {
|
||||
sb.append("class ");
|
||||
addPackage(sb, cd);
|
||||
sb.append("C" + i);
|
||||
} else {
|
||||
sb.append("interface ");
|
||||
addPackage(sb, cd);
|
||||
sb.append("I" + i);
|
||||
}
|
||||
|
||||
boolean first = true;
|
||||
for(final int j : hier.classes()) {
|
||||
if (hier.inherits(i, j)) {
|
||||
if (first) {
|
||||
sb.append(" extends C" + j);
|
||||
} else {
|
||||
sb.append(", C" + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
first = true;
|
||||
for(final int j : hier.interfaces()) {
|
||||
if (hier.inherits(i, j)) {
|
||||
if (first) {
|
||||
sb.append(" implements I" + j);
|
||||
} else {
|
||||
sb.append(", I" + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sb.append(cd);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder, facilitating building up test cases.
|
||||
*/
|
||||
public static class Builder {
|
||||
/**
|
||||
* A map from class (or interface) id's to ClassDatas
|
||||
*/
|
||||
public final HashMap<Integer, ClassData> classdata;
|
||||
/**
|
||||
* The hierarchy shape.
|
||||
*/
|
||||
public final HierarchyShape hier;
|
||||
/**
|
||||
* Which invoke instruction to use.
|
||||
*/
|
||||
public InvokeInstruction invoke;
|
||||
/**
|
||||
* The id of the methodref (or interface methodref).
|
||||
*/
|
||||
public int methodref = -1;
|
||||
/**
|
||||
* The id of the object ref. Note that for the generator
|
||||
* framework to work, this must be set to something. If an
|
||||
* objectref isn't used, just set it to the methodref.
|
||||
*/
|
||||
public int objectref = -1;
|
||||
/**
|
||||
* The id of the callsite.
|
||||
*/
|
||||
public int callsite = -1;
|
||||
/**
|
||||
* The id of the expected result. This is used to store the
|
||||
* expected resolution result.
|
||||
*/
|
||||
public int expected;
|
||||
/**
|
||||
* The expected result. This needs to be set before the final
|
||||
* test case is built.
|
||||
*/
|
||||
public Result result;
|
||||
|
||||
/**
|
||||
* Create an empty Builder object.
|
||||
*/
|
||||
public Builder() {
|
||||
classdata = new HashMap<>();
|
||||
hier = new HierarchyShape();
|
||||
}
|
||||
|
||||
private Builder(final HashMap<Integer, ClassData> classdata,
|
||||
final HierarchyShape hier,
|
||||
final InvokeInstruction invoke,
|
||||
final int methodref,
|
||||
final int objectref,
|
||||
final int callsite,
|
||||
final int expected,
|
||||
final Result result) {
|
||||
this.classdata = classdata;
|
||||
this.hier = hier;
|
||||
this.invoke = invoke;
|
||||
this.methodref = methodref;
|
||||
this.objectref = objectref;
|
||||
this.callsite = callsite;
|
||||
this.expected = expected;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
private Builder(final Builder other) {
|
||||
this((HashMap<Integer, ClassData>) other.classdata.clone(),
|
||||
other.hier.copy(), other.invoke, other.methodref, other.objectref,
|
||||
other.callsite, other.expected, other.result);
|
||||
}
|
||||
|
||||
public SelectionResolutionTestCase build() {
|
||||
if (result != null) {
|
||||
return new SelectionResolutionTestCase(classdata, hier, invoke,
|
||||
methodref, objectref,
|
||||
callsite, result);
|
||||
} else {
|
||||
return new SelectionResolutionTestCase(classdata, hier, invoke,
|
||||
methodref, objectref,
|
||||
callsite, expected);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the expected result.
|
||||
*/
|
||||
public void setResult(final Result result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a class, and return its id.
|
||||
*
|
||||
* @return The new class' id.
|
||||
*/
|
||||
public int addClass(final ClassData data) {
|
||||
final int id = hier.addClass();
|
||||
classdata.put(id, data);
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an interface, and return its id.
|
||||
*
|
||||
* @return The new class' id.
|
||||
*/
|
||||
public int addInterface(final ClassData data) {
|
||||
final int id = hier.addInterface();
|
||||
classdata.put(id, data);
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a copy of this builder.
|
||||
*/
|
||||
public Builder copy() {
|
||||
return new Builder(this);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
//sb.append("hierarchy:\n" + hier + "\n");
|
||||
sb.append("invoke: " + invoke + "\n");
|
||||
if (methodref != -1) {
|
||||
if (hier.isClass(methodref)) {
|
||||
sb.append("methodref: C" + methodref + "\n");
|
||||
} else {
|
||||
sb.append("methodref: I" + methodref + "\n");
|
||||
}
|
||||
}
|
||||
if (objectref != -1) {
|
||||
if (hier.isClass(objectref)) {
|
||||
sb.append("objectref: C" + objectref + "\n");
|
||||
} else {
|
||||
sb.append("objectref: I" + objectref + "\n");
|
||||
}
|
||||
}
|
||||
if (callsite != -1) {
|
||||
if (hier.isClass(callsite)) {
|
||||
sb.append("callsite: C" + callsite + "\n");
|
||||
} else {
|
||||
sb.append("callsite: I" + callsite + "\n");
|
||||
}
|
||||
}
|
||||
if (expected != -1) {
|
||||
if (hier.isClass(expected)) {
|
||||
sb.append("expected: C" + expected + "\n");
|
||||
} else {
|
||||
sb.append("expected: I" + expected + "\n");
|
||||
}
|
||||
}
|
||||
sb.append("result: " + result + "\n");
|
||||
sb.append("classes:\n\n");
|
||||
|
||||
for(int i = 0; classdata.containsKey(i); i++) {
|
||||
final ClassData cd = classdata.get(i);
|
||||
|
||||
if (hier.isClass(i)) {
|
||||
sb.append("class ");
|
||||
addPackage(sb, cd);
|
||||
sb.append("C" + i);
|
||||
} else {
|
||||
sb.append("interface ");
|
||||
addPackage(sb, cd);
|
||||
sb.append("I" + i);
|
||||
}
|
||||
|
||||
boolean first = true;
|
||||
for(final int j : hier.classes()) {
|
||||
if (hier.inherits(i, j)) {
|
||||
if (first) {
|
||||
sb.append(" extends C" + j);
|
||||
} else {
|
||||
sb.append(", C" + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
first = true;
|
||||
for(final int j : hier.interfaces()) {
|
||||
if (hier.inherits(i, j)) {
|
||||
if (first) {
|
||||
sb.append(" implements I" + j);
|
||||
} else {
|
||||
sb.append(", I" + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sb.append(cd);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package selectionresolution;
|
||||
|
||||
import jdk.internal.org.objectweb.asm.Opcodes;
|
||||
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC;
|
||||
|
||||
class TestBuilder extends Builder {
|
||||
private final ClassConstruct testClass;
|
||||
private final Method mainMethod;
|
||||
|
||||
public TestBuilder(int classId, SelectionResolutionTestCase testcase) {
|
||||
super(testcase);
|
||||
|
||||
// Make a public class Test that contains all our test methods
|
||||
testClass = new Clazz("Test", null, -1, ACC_PUBLIC);
|
||||
|
||||
// Add a main method
|
||||
mainMethod = testClass.addMethod("main", "([Ljava/lang/String;)V", ACC_PUBLIC + ACC_STATIC);
|
||||
|
||||
}
|
||||
|
||||
public ClassConstruct getMainTestClass() {
|
||||
mainMethod.done();
|
||||
return testClass;
|
||||
}
|
||||
|
||||
public void addTest(ClassConstruct clazz, ClassBuilder.ExecutionMode execMode) {
|
||||
Method m = clazz.addMethod("test", "()Ljava/lang/Integer;", ACC_PUBLIC + ACC_STATIC, execMode);
|
||||
m.defaultInvoke(getInvokeInstruction(testcase.invoke),
|
||||
getName(testcase.methodref),
|
||||
getName(testcase.objectref));
|
||||
|
||||
mainMethod.makeStaticCall(clazz.getName(), "test", "()Ljava/lang/Integer;").done();
|
||||
}
|
||||
|
||||
private static int getInvokeInstruction(SelectionResolutionTestCase.InvokeInstruction instr) {
|
||||
switch (instr) {
|
||||
case INVOKESTATIC:
|
||||
return Opcodes.INVOKESTATIC;
|
||||
case INVOKESPECIAL:
|
||||
return Opcodes.INVOKESPECIAL;
|
||||
case INVOKEINTERFACE:
|
||||
return Opcodes.INVOKEINTERFACE;
|
||||
case INVOKEVIRTUAL:
|
||||
return Opcodes.INVOKEVIRTUAL;
|
||||
default:
|
||||
throw new AssertionError(instr.name());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user