8208237: Re-examine defmeth tests and update as needed
Reviewed-by: hseigel, lfoltan, dholmes
This commit is contained in:
parent
ac0287fd73
commit
acf02ed553
test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -26,7 +26,6 @@ package vm.runtime.defmeth;
|
||||
import nsk.share.TestFailure;
|
||||
import nsk.share.test.TestBase;
|
||||
import vm.runtime.defmeth.shared.MemoryClassLoader;
|
||||
import vm.runtime.defmeth.shared.annotation.KnownFailure;
|
||||
import vm.runtime.defmeth.shared.annotation.NotApplicableFor;
|
||||
import vm.runtime.defmeth.shared.builder.TestBuilder;
|
||||
import vm.runtime.defmeth.shared.data.*;
|
||||
@ -64,9 +63,6 @@ public class BasicTest extends DefMethTest {
|
||||
* objectref does not implement the resolved interface, invokevirtual throws
|
||||
* an IncompatibleClassChangeError.
|
||||
*/
|
||||
@KnownFailure(modes = {
|
||||
REFLECTION, // throws IAE
|
||||
INVOKE_GENERIC, INVOKE_WITH_ARGS}) // throws ClassCastException
|
||||
public void testInterfaceNotImplemented() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
@ -90,7 +86,7 @@ public class BasicTest extends DefMethTest {
|
||||
// code must run, and that is where the ClassCastException occurs.
|
||||
// This exception can be thrown from code that is cleanly
|
||||
// compiled and does no bytecode generation, so an ICCE would
|
||||
// be inappropriate since no classes are changed.
|
||||
// be inappropriate since no classes are changed.
|
||||
expectedClass = ClassCastException.class;
|
||||
} else {
|
||||
expectedClass = IncompatibleClassChangeError.class;
|
||||
@ -109,9 +105,6 @@ public class BasicTest extends DefMethTest {
|
||||
*
|
||||
* ...
|
||||
*/
|
||||
@KnownFailure(modes = {
|
||||
DIRECT, REFLECTION, INVOKE_WITH_ARGS, // NSME, instead of AME
|
||||
INVOKE_EXACT, INVOKE_GENERIC, INDY}) // IncompatibleClassChangeError, instead of AME
|
||||
public void testNoMatch() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
@ -196,13 +189,13 @@ public class BasicTest extends DefMethTest {
|
||||
|
||||
/**
|
||||
* interface I {
|
||||
* static { throw new RE()}
|
||||
* static { throw new RE(); }
|
||||
* public default void m() {}
|
||||
* }
|
||||
*
|
||||
* class C implements I {}
|
||||
*
|
||||
* TEST: C c = new C(); ==> LinkageError
|
||||
* TEST: C c = new C(); ==> ExceptionInInitializerError
|
||||
* Static initialization of class C will trigger
|
||||
* I's static initialization due to I's default method.
|
||||
*/
|
||||
@ -221,20 +214,24 @@ public class BasicTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I).build();
|
||||
|
||||
b.test().callSite(I, C, "m", "()V").throws_(LinkageError.class).done()
|
||||
boolean isReflectionMode = factory.getExecutionMode().equals("REFLECTION");
|
||||
Class expectedError = isReflectionMode ? RuntimeException.class
|
||||
: ExceptionInInitializerError.class;
|
||||
|
||||
b.test().new_(C).throws_(expectedError).done()
|
||||
|
||||
.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* interface I {
|
||||
* static { throw new RE()}
|
||||
* static { throw new RE(); }
|
||||
* private default void m() {}
|
||||
* }
|
||||
*
|
||||
* class C implements I {}
|
||||
*
|
||||
* TEST: C c = new C(); ==> LinkageError
|
||||
* TEST: C c = new C(); ==> ExceptionInInitializerError
|
||||
* Static initialization of class C will trigger
|
||||
* I's static initialization due to I's private concrete method.
|
||||
*/
|
||||
@ -254,13 +251,11 @@ public class BasicTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I).build();
|
||||
|
||||
Class expectedClass;
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
expectedClass = NoSuchMethodException.class;
|
||||
} else {
|
||||
expectedClass = LinkageError.class;
|
||||
}
|
||||
b.test().callSite(I, C, "m", "()V").throws_(expectedClass).done()
|
||||
boolean isReflectionMode = factory.getExecutionMode().equals("REFLECTION");
|
||||
Class expectedError = isReflectionMode ? RuntimeException.class
|
||||
: ExceptionInInitializerError.class;
|
||||
|
||||
b.test().new_(C).throws_(expectedError).done()
|
||||
|
||||
.run();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -25,7 +25,6 @@ package vm.runtime.defmeth;
|
||||
|
||||
import nsk.share.test.TestBase;
|
||||
import vm.runtime.defmeth.shared.DefMethTest;
|
||||
import vm.runtime.defmeth.shared.annotation.KnownFailure;
|
||||
import vm.runtime.defmeth.shared.annotation.NotApplicableFor;
|
||||
import vm.runtime.defmeth.shared.data.*;
|
||||
import static vm.runtime.defmeth.shared.data.method.body.CallMethod.Invoke.*;
|
||||
@ -486,7 +485,6 @@ public class ConflictingDefaultsTest extends DefMethTest {
|
||||
* TEST: J j = new C(); j.m() ==> NSME; j.m(0) == 2
|
||||
* TEST: C c = new C(); c.m() == 1; c.m(0) == 2
|
||||
*/
|
||||
@KnownFailure(modes = { INVOKE_EXACT, INVOKE_GENERIC, INDY }) // IncompatibleClassChangeError instead of NoSuchMethodError
|
||||
public void testMixedArity1() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -25,7 +25,6 @@ package vm.runtime.defmeth;
|
||||
|
||||
import nsk.share.test.TestBase;
|
||||
import vm.runtime.defmeth.shared.DefMethTest;
|
||||
import vm.runtime.defmeth.shared.annotation.KnownFailure;
|
||||
import vm.runtime.defmeth.shared.data.*;
|
||||
import vm.runtime.defmeth.shared.data.method.param.NewInstanceParam;
|
||||
import vm.runtime.defmeth.shared.builder.TestBuilder;
|
||||
@ -87,8 +86,6 @@ public class DefaultVsAbstractTest extends DefMethTest {
|
||||
* TEST: C c = new D(); c.m() ==> AME
|
||||
* TEST: D d = new D(); d.m() ==> AME
|
||||
*/
|
||||
@KnownFailure(modes = {INVOKE_EXACT, INVOKE_GENERIC, INVOKE_WITH_ARGS, INDY }) // Test1_I_D_m: NPE instead of AME
|
||||
// Test3_D_D_m: AME => IAE => ICCE instead of AME
|
||||
public void test1() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
@ -130,8 +127,6 @@ public class DefaultVsAbstractTest extends DefMethTest {
|
||||
* TEST: C o = new D(); o.m()I throws AME
|
||||
* TEST: D o = new D(); o.m()I throws AME
|
||||
*/
|
||||
@KnownFailure(modes = { INVOKE_EXACT, INVOKE_GENERIC, INVOKE_WITH_ARGS, INDY }) // Test1_I_D_m: NPE instead of AME
|
||||
// Test3_D_D_m: AME => IAE => ICCE instead of AME
|
||||
public void test2() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
@ -218,11 +213,6 @@ public class DefaultVsAbstractTest extends DefMethTest {
|
||||
* TEST: D o = new C(); o.m()I throws AME
|
||||
* TEST: C o = new C(); o.m()I throws AME
|
||||
*/
|
||||
@KnownFailure(modes = {
|
||||
INVOKE_EXACT, INVOKE_GENERIC, INVOKE_WITH_ARGS, INDY // Test1_I_C_m: NPE instead of AME
|
||||
// Test3_D_C_m: AME => IAE => ICCE instead of AME
|
||||
// Test4_C_C_m: AME => IAE => ICCE instead of AME
|
||||
})
|
||||
public void test4() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
@ -445,10 +435,7 @@ public class DefaultVsAbstractTest extends DefMethTest {
|
||||
*
|
||||
* class B extends A implements J;
|
||||
*
|
||||
* TEST: A o = new B(); o.m()I
|
||||
* ICCE for DIRECT mode
|
||||
* AME for REFLECTION and INVOKE_WITH_ARGS modes
|
||||
* IAE for other modes
|
||||
* TEST: A o = new B(); o.m()I throws ICCE
|
||||
*/
|
||||
public void testInvokeInterfaceClassAbstractMethod() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
@ -465,16 +452,11 @@ public class DefaultVsAbstractTest extends DefMethTest {
|
||||
|
||||
ConcreteClass B = b.clazz("B").extend(A).implement(J).build();
|
||||
|
||||
String exeMode = factory.getExecutionMode();
|
||||
|
||||
// ICCE in direct mode due to
|
||||
// JVMS-5.4.3.4. Interface Method Resolution
|
||||
// When resolving an interface method reference:
|
||||
// If C is not an interface, interface method resolution throws an IncompatibleClassChangeError.
|
||||
Class expectedError = IncompatibleClassChangeError.class;;
|
||||
|
||||
b.test().interfaceCallSite(A, B, "m", "()I")
|
||||
.throws_(expectedError).done()
|
||||
.throws_(IncompatibleClassChangeError.class).done()
|
||||
.run();
|
||||
|
||||
}
|
||||
@ -492,8 +474,7 @@ public class DefaultVsAbstractTest extends DefMethTest {
|
||||
*
|
||||
* class B extends A implements J;
|
||||
*
|
||||
* TEST: A o = new B(); o.m()I
|
||||
* ICCE for all modes
|
||||
* TEST: A o = new B(); o.m()I throws ICCE
|
||||
*/
|
||||
public void testInvokeInterfaceMultipleDefinedClassDefaultMethod() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
@ -510,16 +491,11 @@ public class DefaultVsAbstractTest extends DefMethTest {
|
||||
|
||||
ConcreteClass B = b.clazz("B").extend(A).implement(J).build();
|
||||
|
||||
String exeMode = factory.getExecutionMode();
|
||||
|
||||
// ICCE in direct mode due to
|
||||
// JVMS-5.4.3.4. Interface Method Resolution
|
||||
// When resolving an interface method reference:
|
||||
// If C is not an interface, interface method resolution throws an IncompatibleClassChangeError.
|
||||
Class expectedError = IncompatibleClassChangeError.class;
|
||||
|
||||
b.test().interfaceCallSite(A, B, "m", "()I")
|
||||
.throws_(expectedError).done()
|
||||
.throws_(IncompatibleClassChangeError.class).done()
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -24,7 +24,6 @@
|
||||
package vm.runtime.defmeth;
|
||||
|
||||
import nsk.share.test.TestBase;
|
||||
import vm.runtime.defmeth.shared.annotation.KnownFailure;
|
||||
import vm.runtime.defmeth.shared.data.*;
|
||||
import vm.runtime.defmeth.shared.data.method.param.*;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
@ -148,7 +147,6 @@ public class MethodResolutionTest extends DefMethTest {
|
||||
*
|
||||
* TEST: [I|J|K|C] i = new C(); i.m() == 1;
|
||||
*/
|
||||
@KnownFailure(modes = { INVOKE_EXACT, INVOKE_GENERIC, INVOKE_WITH_ARGS, INDY }) // Test2_J_C_m, Test3_K_C_m: AME => IAE => ICCE instead of successful call
|
||||
public void testFarDefault() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
@ -193,7 +191,6 @@ public class MethodResolutionTest extends DefMethTest {
|
||||
* TEST: C c = new C(); c.m() == 1;
|
||||
* TEST: K k = new C(); k.m() == 1;
|
||||
*/
|
||||
@KnownFailure(modes = { INVOKE_EXACT, INVOKE_GENERIC, INVOKE_WITH_ARGS, INDY }) // Test3_K_C_m: AME => IAE => ICCE instead of successful call
|
||||
public void testOverrideAbstract() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
@ -516,7 +513,6 @@ public class MethodResolutionTest extends DefMethTest {
|
||||
*
|
||||
* TEST: [I|J|K|C] c = new C(); c.m() == 99
|
||||
*/
|
||||
@KnownFailure(modes = { INVOKE_EXACT, INVOKE_GENERIC, INVOKE_WITH_ARGS, INDY }) // Test2_J_C_m, Test3_K_C_m: AME => IAE => ICCE instead of successful call
|
||||
public void testDiamond() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
@ -562,8 +558,6 @@ public class MethodResolutionTest extends DefMethTest {
|
||||
*
|
||||
* TEST: [I|J|K|L|M|C] c = new C(); c.m() == 1
|
||||
*/
|
||||
@KnownFailure(modes = { INVOKE_EXACT, INVOKE_GENERIC, INVOKE_WITH_ARGS, INDY }) // Test2_J_C_m, Test3_K_C_m, Test4_L_C_m, Test5_M_C_m:
|
||||
// AME => IAE => ICCE instead of successful call
|
||||
public void testExpandedDiamond() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
@ -708,7 +702,6 @@ public class MethodResolutionTest extends DefMethTest {
|
||||
* TEST: J j = new C(); j.m() ==> NSME; j.m(0) == 2
|
||||
* TEST: C c = new C(); c.m() == 1; c.m(0) == 2
|
||||
*/
|
||||
@KnownFailure(modes = { INVOKE_EXACT, INVOKE_GENERIC, INDY }) //Test2_I_C_m, Test3_J_C_m: NSMError => NSMException => ICCE instead of NSME
|
||||
public void testConflictingDefaultMixedArity1() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
@ -763,8 +756,6 @@ public class MethodResolutionTest extends DefMethTest {
|
||||
* TEST: J j = new C(); j.m(0) ==> ICCE
|
||||
* TEST: C c = new C(); c.m() ==> ICCE; c.m(0) == 3
|
||||
*/
|
||||
@KnownFailure(modes = { INVOKE_EXACT, INVOKE_GENERIC, INDY })
|
||||
//Test2_I_C_m, Test3_J_C_m: NSMError => NSMException => ICCE instead of NSME
|
||||
public void testConflictingDefaultMixedArity2() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -25,8 +25,6 @@ package vm.runtime.defmeth;
|
||||
|
||||
import nsk.share.test.TestBase;
|
||||
import vm.runtime.defmeth.shared.DefMethTest;
|
||||
import vm.runtime.defmeth.shared.annotation.Crash;
|
||||
import vm.runtime.defmeth.shared.annotation.KnownFailure;
|
||||
import vm.runtime.defmeth.shared.annotation.NotApplicableFor;
|
||||
import vm.runtime.defmeth.shared.data.*;
|
||||
import static vm.runtime.defmeth.shared.data.method.body.CallMethod.Invoke.*;
|
||||
@ -60,10 +58,6 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
// the private interface method privateM(). It is the latter call we are
|
||||
// really testing, but it is the call of the default method that occurs
|
||||
// via reflection.
|
||||
// In private cases reflection triggers a NoSuchMethodException instead of the
|
||||
// expected IllegalAccessError. This indicates it is getDeclaredMethod() that is
|
||||
// failing rather than the actual invoke(). Which in turn suggests the wrong class
|
||||
// is being used, or that getMethod() is being used instead of getDeclaredMethod().
|
||||
|
||||
/*
|
||||
* testPrivateInvokeVirtual
|
||||
@ -336,7 +330,6 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
* class C implements I {}
|
||||
*
|
||||
* TEST: { I o = new C(); o.m()I throws IllegalAccessError; }
|
||||
* -mode reflect throws NoSuchMethodException
|
||||
* TEST: { C o = new C(); o.m()I throws NoSuchMethodError; }
|
||||
*/
|
||||
public void testPrivate() {
|
||||
@ -349,15 +342,8 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I).build();
|
||||
|
||||
Class expectedClass;
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
expectedClass = NoSuchMethodException.class;
|
||||
} else {
|
||||
expectedClass = IllegalAccessError.class;
|
||||
}
|
||||
|
||||
b.test().callSite(I, C, "m", "()I").throws_(expectedClass).done()
|
||||
.test().callSite(C, C, "m", "()I").throws_(NoSuchMethodError.class).done()
|
||||
b.test().privateCallSite(I, C, "m", "()I").throws_(IllegalAccessError.class).done()
|
||||
.test(). callSite(C, C, "m", "()I").throws_(NoSuchMethodError.class).done()
|
||||
|
||||
.run();
|
||||
}
|
||||
@ -373,7 +359,6 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
* }
|
||||
*
|
||||
* TEST: { I o = new C(); o.m()I == IllegalAccessError; }
|
||||
* -mode reflect throws NoSuchMethodException
|
||||
* TEST: { C o = new C(); o.m()I == 2; }
|
||||
*/
|
||||
public void testPrivateVsConcrete() {
|
||||
@ -388,15 +373,8 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
.concreteMethod("m", "()I").returns(2).build()
|
||||
.build();
|
||||
|
||||
Class expectedClass;
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
expectedClass = NoSuchMethodException.class;
|
||||
} else {
|
||||
expectedClass = IllegalAccessError.class;
|
||||
}
|
||||
|
||||
b.test().callSite(I, C, "m", "()I").throws_(expectedClass).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(2).done()
|
||||
b.test().privateCallSite(I, C, "m", "()I").throws_(IllegalAccessError.class).done()
|
||||
.test(). callSite(C, C, "m", "()I").returns(2).done()
|
||||
|
||||
.run();
|
||||
}
|
||||
@ -413,7 +391,6 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
* class C implements J {}
|
||||
*
|
||||
* TEST: { I o = new C(); o.m()I throws IllegalAccessError; }
|
||||
* -mode reflect throws NoSuchMethodException
|
||||
* TEST: { J o = new C(); o.m()I == 2; }
|
||||
* TEST: { C o = new C(); o.m()I == 2; }
|
||||
*/
|
||||
@ -432,16 +409,9 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(J).build();
|
||||
|
||||
Class expectedClass;
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
expectedClass = NoSuchMethodException.class;
|
||||
} else {
|
||||
expectedClass = IllegalAccessError.class;
|
||||
}
|
||||
|
||||
b.test().callSite(I, C, "m", "()I").throws_(expectedClass).done()
|
||||
.test().callSite(J, C, "m", "()I").returns(2).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(2).done()
|
||||
b.test().privateCallSite(I, C, "m", "()I").throws_(IllegalAccessError.class).done()
|
||||
.test(). callSite(J, C, "m", "()I").returns(2).done()
|
||||
.test(). callSite(C, C, "m", "()I").returns(2).done()
|
||||
|
||||
.run();
|
||||
}
|
||||
@ -495,7 +465,6 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
* class C implements J {}
|
||||
*
|
||||
* TEST: { I o = new C(); o.m()I throws IllegalAccessError; } II I.m
|
||||
* -mode reflect throws NoSuchMethodException
|
||||
* TEST: { J o = new C(); o.m()I throws java/lang/AbstractMethodError; }
|
||||
* TEST: { C o = new C(); o.m()I throws java/lang/AbstractMethodError; }
|
||||
*/
|
||||
@ -513,16 +482,9 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(J).build();
|
||||
|
||||
Class expectedClass;
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
expectedClass = NoSuchMethodException.class;
|
||||
} else {
|
||||
expectedClass = IllegalAccessError.class;
|
||||
}
|
||||
|
||||
b.test().callSite(I, C, "m", "()I").throws_(expectedClass).done()
|
||||
.test().callSite(J, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
.test().callSite(C, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
b.test().privateCallSite(I, C, "m", "()I").throws_(IllegalAccessError.class).done()
|
||||
.test(). callSite(J, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
.test(). callSite(C, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
|
||||
.run();
|
||||
}
|
||||
@ -572,7 +534,6 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
* class C extends B {}
|
||||
*
|
||||
* TEST: { I o = new C(); o.m()I throws IllegalAccessError } II I.m
|
||||
* -mode reflect throws NoSuchMethodException
|
||||
* TEST: { B o = new C(); o.m()I throws NoSuchMethodError }
|
||||
* TEST: { C o = new C(); o.m()I throws NoSuchMethodError }
|
||||
*/
|
||||
@ -587,16 +548,9 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
ConcreteClass B = b.clazz("B").implement(I).build();
|
||||
ConcreteClass C = b.clazz("C").extend(B).build();
|
||||
|
||||
Class expectedClass;
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
expectedClass = NoSuchMethodException.class;
|
||||
} else {
|
||||
expectedClass = IllegalAccessError.class;
|
||||
}
|
||||
|
||||
b.test().callSite(I, C, "m","()I").throws_(expectedClass).done()
|
||||
.test().callSite(B, C, "m","()I").throws_(NoSuchMethodError.class).done()
|
||||
.test().callSite(C, C, "m","()I").throws_(NoSuchMethodError.class).done()
|
||||
b.test().privateCallSite(I, C, "m","()I").throws_(IllegalAccessError.class).done()
|
||||
.test(). callSite(B, C, "m","()I").throws_(NoSuchMethodError.class).done()
|
||||
.test(). callSite(C, C, "m","()I").throws_(NoSuchMethodError.class).done()
|
||||
|
||||
.run();
|
||||
|
||||
@ -614,7 +568,6 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
* class C extends B implements I {}
|
||||
*
|
||||
* TEST: { I o = new C(); o.m()I == throws IllegalAccessError; }
|
||||
* -mode reflect throws NoSuchMethodException
|
||||
* TEST: { B o = new C(); o.m()I == 2; }
|
||||
* TEST: { C o = new C(); o.m()I == 2; }
|
||||
*/
|
||||
@ -632,16 +585,9 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").extend(B).implement(I).build();
|
||||
|
||||
Class expectedClass;
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
expectedClass = NoSuchMethodException.class;
|
||||
} else {
|
||||
expectedClass = IllegalAccessError.class;
|
||||
}
|
||||
|
||||
b.test().callSite(I, C, "m","()I").throws_(expectedClass).done()
|
||||
.test().callSite(B, C, "m","()I").returns(2).done()
|
||||
.test().callSite(C, C, "m","()I").returns(2).done()
|
||||
b.test().privateCallSite(I, C, "m","()I").throws_(IllegalAccessError.class).done()
|
||||
.test(). callSite(B, C, "m","()I").returns(2).done()
|
||||
.test(). callSite(C, C, "m","()I").returns(2).done()
|
||||
|
||||
.run();
|
||||
}
|
||||
@ -660,7 +606,6 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
* class C implements I, J {}
|
||||
*
|
||||
* TEST: { I o = new C(); o.m()I throws IllegalAccessError; }
|
||||
* -mode reflect throws NoSuchMethodException
|
||||
* TEST: { J o = new C(); o.m()I == 2; }
|
||||
* TEST: { C o = new C(); o.m()I == 2; }
|
||||
*/
|
||||
@ -677,16 +622,9 @@ public class PrivateMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I,J).build();
|
||||
|
||||
Class expectedClass;
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
expectedClass = NoSuchMethodException.class;
|
||||
} else {
|
||||
expectedClass = IllegalAccessError.class;
|
||||
}
|
||||
|
||||
b.test().callSite(I, C, "m", "()I").throws_(expectedClass).done()
|
||||
.test().callSite(J, C, "m", "()I").returns(2).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(2).done()
|
||||
b.test().privateCallSite(I, C, "m", "()I").throws_(IllegalAccessError.class).done()
|
||||
.test(). callSite(J, C, "m", "()I").returns(2).done()
|
||||
.test(). callSite(C, C, "m", "()I").returns(2).done()
|
||||
|
||||
.run();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -55,7 +55,7 @@ public class RedefineTest extends DefMethTest {
|
||||
// There are no testers being generated for reflection-based scenarios,
|
||||
// so scenarios on class redefinition don't work
|
||||
String mode = factory.getExecutionMode();
|
||||
if ( "REFLECTION".equals(mode) || "INVOKE_WITH_ARGS".equals(mode)) {
|
||||
if ("REFLECTION".equals(mode) || "INVOKE_WITH_ARGS".equals(mode)) {
|
||||
throw new TestFailure("RedefineTest isn't applicable to reflection-based execution scenario " +
|
||||
"(REDEFINE & INVOKE_WITH_ARGS).");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -25,10 +25,13 @@ package vm.runtime.defmeth;
|
||||
|
||||
import nsk.share.test.TestBase;
|
||||
import vm.runtime.defmeth.shared.DefMethTest;
|
||||
import vm.runtime.defmeth.shared.annotation.Crash;
|
||||
import vm.runtime.defmeth.shared.builder.TesterBuilder;
|
||||
import vm.runtime.defmeth.shared.data.*;
|
||||
import vm.runtime.defmeth.shared.builder.TestBuilder;
|
||||
import vm.runtime.defmeth.shared.annotation.NotApplicableFor;
|
||||
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PRIVATE;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC;
|
||||
import static vm.runtime.defmeth.shared.data.method.body.CallMethod.Invoke.*;
|
||||
import static vm.runtime.defmeth.shared.data.method.body.CallMethod.IndexbyteOp.*;
|
||||
import static vm.runtime.defmeth.shared.ExecutionMode.*;
|
||||
@ -226,16 +229,10 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I).build();
|
||||
|
||||
Class expectedClass;
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
expectedClass = NoSuchMethodException.class;
|
||||
} else {
|
||||
expectedClass = IllegalAccessError.class;
|
||||
}
|
||||
|
||||
// call static method from another class
|
||||
b.test().staticCallSite(I, "staticPublicM", "()I").returns(1).done()
|
||||
.test().staticCallSite(I, "staticPrivateM", "()I").throws_(expectedClass).done()
|
||||
|
||||
.test().callSite(I, "staticPrivateM", "()I", ACC_STATIC | ACC_PRIVATE).throws_(IllegalAccessError.class).done()
|
||||
|
||||
// call public static method from default method
|
||||
.test().callSite(I, C, "invokePublic", "()I").returns(1).done()
|
||||
@ -287,36 +284,20 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
.invokeStatic(b.intfByName("I"), "staticPrivateM", "()I").build()
|
||||
.build();
|
||||
|
||||
Class expectedError1;
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
expectedError1 = NoSuchMethodException.class;
|
||||
} else {
|
||||
expectedError1 = IllegalAccessError.class;
|
||||
}
|
||||
// call static method from another class
|
||||
b.test().staticCallSite(I, "staticPublicM", "()I").returns(1).done()
|
||||
.test().callSite(I, "staticPrivateM", "()I", ACC_STATIC | ACC_PRIVATE).throws_(IllegalAccessError.class).done();
|
||||
|
||||
// Adjust for -ver < 52
|
||||
// call static method from implementing subclass
|
||||
if (factory.getVer() >=52) {
|
||||
// call static method from another class
|
||||
b.test().staticCallSite(I, "staticPublicM", "()I").returns(1).done()
|
||||
.test().staticCallSite(I, "staticPrivateM", "()I").throws_(expectedError1).done()
|
||||
|
||||
// call static method from implementing subclass
|
||||
.test().callSite(C, C, "invokePublic", "()I").returns(1).done()
|
||||
.test().callSite(C, C, "invokePrivate", "()I").throws_(IllegalAccessError.class).done()
|
||||
|
||||
.run();
|
||||
b.test().callSite(C, C, "invokePublic", "()I").returns(1).done()
|
||||
.test().callSite(C, C, "invokePrivate", "()I").throws_(IllegalAccessError.class).done();
|
||||
} else {
|
||||
// call static method from another class
|
||||
b.test().staticCallSite(I, "staticPublicM", "()I").returns(1).done()
|
||||
.test().staticCallSite(I, "staticPrivateM", "()I").throws_(expectedError1).done()
|
||||
|
||||
// call static method from implementing subclass
|
||||
// invokestatic IMR - not supported for ver < 52
|
||||
.test().callSite(C, C, "invokePublic", "()I").throws_(VerifyError.class).done()
|
||||
.test().callSite(C, C, "invokePrivate", "()I").throws_(VerifyError.class).done()
|
||||
|
||||
.run();
|
||||
b.test().callSite(C, C, "invokePublic", "()I").throws_(VerifyError.class).done()
|
||||
.test().callSite(C, C, "invokePrivate", "()I").throws_(VerifyError.class).done();
|
||||
}
|
||||
b.run();
|
||||
}
|
||||
|
||||
// static method doesn't participate in default method analysis:
|
||||
@ -340,18 +321,17 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I).build();
|
||||
|
||||
if (!factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().staticCallSite(I, "m", "()I").returns(1).done()
|
||||
// invokeinterface to static method ==> ICCE
|
||||
.test().callSite(I, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done()
|
||||
.test().callSite(C, C, "m", "()I").throws_(NoSuchMethodError.class).done()
|
||||
.run();
|
||||
b.test().staticCallSite(I, "m", "()I").returns(1).done();
|
||||
|
||||
b.test().callSite(C, C, "m", "()I").throws_(NoSuchMethodError.class).done();
|
||||
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done();
|
||||
} else {
|
||||
b.test().staticCallSite(I, "m", "()I").returns(1).done()
|
||||
.test().callSite(I, C, "m", "()I").returns(1).done()
|
||||
.test().callSite(C, C, "m", "()I").throws_(NoSuchMethodError.class).done()
|
||||
.run();
|
||||
// invokeinterface to static method ==> ICCE
|
||||
b.test().callSite(I, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
}
|
||||
b.run();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -379,15 +359,16 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
.concreteMethod("m", "()I").returns(2).build()
|
||||
.build();
|
||||
|
||||
if (!factory.getExecutionMode().equals("REFLECTION")) {
|
||||
// invokeinterface to static method ==> ICCE
|
||||
b.test().callSite(I, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(2).done().run();
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done();
|
||||
} else {
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(2).done().run();
|
||||
// invokeinterface to static method ==> ICCE
|
||||
b.test().callSite(I, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
}
|
||||
|
||||
b.test().callSite(C, C, "m", "()I").returns(2).done();
|
||||
|
||||
b.run();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -419,20 +400,18 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(J).build();
|
||||
|
||||
if (!factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().staticCallSite(I, "m", "()I").returns(1).done()
|
||||
.test().callSite(I, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done()
|
||||
.test().callSite(J, C, "m", "()I").returns(2).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(2).done()
|
||||
.run();
|
||||
b.test().staticCallSite(I, "m", "()I").returns(1).done()
|
||||
|
||||
.test().callSite(J, C, "m", "()I").returns(2).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(2).done();
|
||||
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done();
|
||||
} else {
|
||||
b.test().staticCallSite(I, "m", "()I").returns(1).done()
|
||||
.test().callSite(I, C, "m", "()I").returns(1).done()
|
||||
.test().callSite(J, C, "m", "()I").returns(2).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(2).done()
|
||||
.run();
|
||||
b.test().callSite(I, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
}
|
||||
|
||||
b.run();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -467,23 +446,18 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(J).build();
|
||||
|
||||
if (!factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done()
|
||||
.test().callSite(J, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(1).done()
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(1).done();
|
||||
|
||||
.run();
|
||||
|
||||
} else {
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
// Reflection correctly finds the static method defined in J and
|
||||
// calls it with invokestatic.
|
||||
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done()
|
||||
.test().callSite(J, C, "m", "()I").returns(2).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(1).done()
|
||||
|
||||
.run();
|
||||
b.test().callSite(J, C, "m", "()I").returns(2).done();
|
||||
} else {
|
||||
b.test().callSite(J, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
}
|
||||
|
||||
b.run();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -518,17 +492,16 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(J).build();
|
||||
|
||||
if (!factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done()
|
||||
.test().callSite(J, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
.test().callSite(C, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
.run();
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done();
|
||||
} else {
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done()
|
||||
.test().callSite(J, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
.test().callSite(C, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
.run();
|
||||
b.test().callSite(I, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
}
|
||||
|
||||
b.test().callSite(J, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
.test().callSite(C, C, "m", "()I").throws_(AbstractMethodError.class).done();
|
||||
|
||||
b.run();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -563,19 +536,16 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(J).build();
|
||||
|
||||
if (!factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
.test().callSite(J, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done()
|
||||
.test().callSite(C, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
b.test().callSite(I, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
.test().callSite(C, C, "m", "()I").throws_(AbstractMethodError.class).done();
|
||||
|
||||
.run();
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(J, C, "m", "()I").returns(1).done();
|
||||
} else {
|
||||
b.test().callSite(I, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
.test().callSite(J, C, "m", "()I").returns(1).done()
|
||||
.test().callSite(C, C, "m", "()I").throws_(AbstractMethodError.class).done()
|
||||
|
||||
.run();
|
||||
b.test().callSite(J, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
}
|
||||
|
||||
b.run();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -605,18 +575,16 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
ConcreteClass B = b.clazz("B").implement(I).build();
|
||||
ConcreteClass C = b.clazz("C").extend(B).build();
|
||||
|
||||
if (!factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m","()I").throws_(IncompatibleClassChangeError.class).done()
|
||||
.test().callSite(B, C, "m","()I").throws_(NoSuchMethodError.class).done()
|
||||
.test().callSite(C, C, "m","()I").throws_(NoSuchMethodError.class).done()
|
||||
.run();
|
||||
b.test().callSite(B, C, "m","()I").throws_(NoSuchMethodError.class).done()
|
||||
.test().callSite(C, C, "m","()I").throws_(NoSuchMethodError.class).done();
|
||||
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m","()I").returns(1).done();
|
||||
} else {
|
||||
b.test().callSite(I, C, "m","()I").returns(1).done()
|
||||
.test().callSite(B, C, "m","()I").throws_(NoSuchMethodError.class).done()
|
||||
.test().callSite(C, C, "m","()I").throws_(NoSuchMethodError.class).done()
|
||||
.run();
|
||||
b.test().callSite(I, C, "m","()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
}
|
||||
|
||||
b.run();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -647,20 +615,18 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").extend(B).implement(I).build();
|
||||
|
||||
if (!factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().staticCallSite(I, "m","()I").returns(1).done()
|
||||
.test().callSite(I, C, "m","()I").throws_(IncompatibleClassChangeError.class).done()
|
||||
.test().callSite(B, C, "m","()I").returns(2).done()
|
||||
.test().callSite(C, C, "m","()I").returns(2).done()
|
||||
.run();
|
||||
b.test().staticCallSite(I, "m","()I").returns(1).done()
|
||||
|
||||
.test().callSite(B, C, "m","()I").returns(2).done()
|
||||
.test().callSite(C, C, "m","()I").returns(2).done();
|
||||
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m","()I").returns(1).done();
|
||||
} else {
|
||||
b.test().staticCallSite(I, "m","()I").returns(1).done()
|
||||
.test().callSite(I, C, "m","()I").returns(1).done()
|
||||
.test().callSite(B, C, "m","()I").returns(2).done()
|
||||
.test().callSite(C, C, "m","()I").returns(2).done()
|
||||
.run();
|
||||
b.test().callSite(I, C, "m","()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
}
|
||||
|
||||
b.run();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -695,19 +661,18 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").implement(I,J).build();
|
||||
|
||||
if (!factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done()
|
||||
.test().callSite(J, C, "m", "()I").returns(2).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(2).done()
|
||||
.run();
|
||||
b.test().callSite(J, C, "m", "()I").returns(2).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(2).done();
|
||||
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done();
|
||||
} else {
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done()
|
||||
.test().callSite(J, C, "m", "()I").returns(2).done()
|
||||
.test().callSite(C, C, "m", "()I").returns(2).done()
|
||||
.run();
|
||||
b.test().callSite(I, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
}
|
||||
|
||||
b.run();
|
||||
}
|
||||
|
||||
/*
|
||||
* testStaticSuperClassVsDefaultSuperInterface
|
||||
*
|
||||
@ -740,15 +705,15 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").extend(A).implement(I).build();
|
||||
|
||||
if (!factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(C, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done()
|
||||
.test().callSite(I, C, "m", "()I").returns(1).done()
|
||||
.run();
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done();
|
||||
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(C, C, "m", "()I").returns(2).done();
|
||||
} else {
|
||||
b.test().callSite(C, C, "m", "()I").returns(2).done()
|
||||
.test().callSite(I, C, "m", "()I").returns(1).done()
|
||||
.run();
|
||||
b.test().callSite(C, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
}
|
||||
|
||||
b.run();
|
||||
}
|
||||
/*
|
||||
* testStaticLocalVsDefaultSuperInterface
|
||||
@ -782,15 +747,18 @@ public class StaticMethodsTest extends DefMethTest {
|
||||
|
||||
ConcreteClass C = b.clazz("C").extend(A).implement(I).build();
|
||||
|
||||
if (!factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(A, A, "m", "()I").throws_(IncompatibleClassChangeError.class).done()
|
||||
.test().callSite(I, A, "m", "()I").returns(1).done()
|
||||
.run();
|
||||
b.test().callSite(I, A, "m", "()I").returns(1).done();
|
||||
b.test().callSite(I, C, "m", "()I").returns(1).done();
|
||||
|
||||
if (factory.getExecutionMode().equals("REFLECTION")) {
|
||||
b.test().callSite(A, A, "m", "()I").returns(2).done();
|
||||
b.test().callSite(C, C, "m", "()I").returns(2).done();
|
||||
} else {
|
||||
b.test().callSite(A, A, "m", "()I").returns(2).done()
|
||||
.test().callSite(I, A, "m", "()I").returns(1).done()
|
||||
.run();
|
||||
b.test().callSite(C, C, "m", "()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
b.test().callSite(A, A, "m", "()I").throws_(IncompatibleClassChangeError.class).done();
|
||||
}
|
||||
|
||||
b.run();
|
||||
}
|
||||
/*
|
||||
* testConflictingDefaultsandStaticMethod
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -195,8 +195,6 @@ public class StressTest implements Runnable {
|
||||
"-ver", Integer.toString(majorVer),
|
||||
"-flags", Integer.toString(flags),
|
||||
"-redefine", Boolean.toString(redefine),
|
||||
"-ignoreCrashes",
|
||||
"-ignoreKnownFailures",
|
||||
"-silent",
|
||||
"-failfast"});
|
||||
|
||||
@ -222,20 +220,6 @@ public class StressTest implements Runnable {
|
||||
System.out.printf("Seed: %d\n", seed);
|
||||
rand = new Random(seed);
|
||||
|
||||
//Workaround for the deadlock caused by
|
||||
// JDK-7122142: "(ann) Race condition between isAnnotationPresent and getAnnotations"
|
||||
try {
|
||||
// Do a warm-up cycle
|
||||
for (Class<? extends DefMethTest> testClass : DefMethTest.getTests()) {
|
||||
DefMethTest test = testClass.newInstance();
|
||||
|
||||
OptionSupport.setupAndRun(test,
|
||||
new String[] { "-silent", "-ignoreKnownFailures"});
|
||||
}
|
||||
} catch(InstantiationException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
int threadsCount = opts.getThreadsFactor();
|
||||
if (threadsCount == 1) {
|
||||
threadsCount = 5;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -25,7 +25,6 @@ package vm.runtime.defmeth;
|
||||
|
||||
import nsk.share.test.TestBase;
|
||||
import vm.runtime.defmeth.shared.DefMethTest;
|
||||
import vm.runtime.defmeth.shared.annotation.KnownFailure;
|
||||
import vm.runtime.defmeth.shared.annotation.NotApplicableFor;
|
||||
import vm.runtime.defmeth.shared.data.*;
|
||||
import vm.runtime.defmeth.shared.builder.TestBuilder;
|
||||
@ -352,7 +351,6 @@ public class SuperCallTest extends DefMethTest {
|
||||
* TEST: C c = new C(); c.m(new Object()) == 1;
|
||||
* TEST: C c = new C(); c.m("") == 1;
|
||||
*/
|
||||
@KnownFailure(modes = { INVOKE_EXACT, INVOKE_GENERIC, INVOKE_WITH_ARGS, INDY }) // Test2_J_C_m: AME => IAE => ICCE instead of successful call
|
||||
public void testSuperGeneric() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
@ -394,7 +392,6 @@ public class SuperCallTest extends DefMethTest {
|
||||
*
|
||||
* TEST: C c = new C(); c.m("string") == 1
|
||||
*/
|
||||
@KnownFailure(modes = { INVOKE_EXACT, INVOKE_GENERIC, INVOKE_WITH_ARGS, INDY }) // Test2_J_C_m: AME => IAE => ICCE instead of successful call
|
||||
public void testSuperGenericDisqual() {
|
||||
TestBuilder b = factory.getBuilder();
|
||||
|
||||
|
@ -30,6 +30,8 @@ import nsk.share.TestFailure;
|
||||
import nsk.share.test.TestUtils;
|
||||
import jdk.internal.org.objectweb.asm.Label;
|
||||
import jdk.internal.org.objectweb.asm.MethodVisitor;
|
||||
|
||||
import static java.lang.invoke.MethodHandleInfo.REF_newInvokeSpecial;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||
import static jdk.internal.org.objectweb.asm.ClassWriter.*;
|
||||
@ -290,11 +292,12 @@ public class ClassFileGenerator implements Visitor {
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareParams(CallMethod callSite) {
|
||||
// Prepare receiver
|
||||
private void prepareReceiver(CallMethod callSite) {
|
||||
switch(callSite.invokeInsn()) {
|
||||
case SPECIAL: // Put receiver (this) on stack
|
||||
mv.visitVarInsn(ALOAD,0);
|
||||
if (!callSite.isConstructorCall()) {
|
||||
mv.visitVarInsn(ALOAD, 0);
|
||||
}
|
||||
break;
|
||||
case VIRTUAL:
|
||||
case INTERFACE: // Construct receiver
|
||||
@ -304,7 +307,7 @@ public class ClassFileGenerator implements Visitor {
|
||||
mv.visitTypeInsn(NEW, receiver);
|
||||
mv.visitInsn(DUP);
|
||||
mv.visitMethodInsn(INVOKESPECIAL, receiver,
|
||||
"<init>", "()V", false);
|
||||
"<init>", "()V", false);
|
||||
} else {
|
||||
// Use "this"
|
||||
mv.visitVarInsn(ALOAD, 0);
|
||||
@ -314,7 +317,10 @@ public class ClassFileGenerator implements Visitor {
|
||||
break;
|
||||
case STATIC: break;
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareParams(CallMethod callSite) {
|
||||
prepareReceiver(callSite);
|
||||
// Push parameters on stack
|
||||
for (Param p : callSite.params()) {
|
||||
p.visit(this);
|
||||
@ -323,12 +329,21 @@ public class ClassFileGenerator implements Visitor {
|
||||
}
|
||||
|
||||
private static Handle convertToHandle(CallMethod callSite) {
|
||||
return new Handle(
|
||||
/* tag */ callSite.invokeInsn().tag(),
|
||||
/* owner */ callSite.staticClass().intlName(),
|
||||
/* name */ callSite.methodName(),
|
||||
/* desc */ callSite.methodDesc(),
|
||||
/* interface */ callSite.isInterface());
|
||||
if (callSite.isConstructorCall()) {
|
||||
return new Handle(
|
||||
/* tag */ REF_newInvokeSpecial,
|
||||
/* owner */ callSite.staticClass().intlName(),
|
||||
/* name */ callSite.methodName(),
|
||||
/* desc */ callSite.methodDesc(),
|
||||
/* interface */ false);
|
||||
} else {
|
||||
return new Handle(
|
||||
/* tag */ callSite.invokeInsn().tag(),
|
||||
/* owner */ callSite.staticClass().intlName(),
|
||||
/* name */ callSite.methodName(),
|
||||
/* desc */ callSite.methodDesc(),
|
||||
/* interface */ callSite.isInterface());
|
||||
}
|
||||
}
|
||||
|
||||
private Handle generateBootstrapMethod(CallMethod callSite) {
|
||||
@ -356,9 +371,13 @@ public class ClassFileGenerator implements Visitor {
|
||||
}
|
||||
|
||||
private static String mhCallSiteDesc(CallMethod callSite) {
|
||||
return (callSite.invokeInsn() != CallMethod.Invoke.STATIC) ?
|
||||
prependType(callSite.methodDesc(), callSite.staticClass().intlName()) :
|
||||
callSite.methodDesc(); // ignore receiver for static call
|
||||
if (callSite.isConstructorCall()) {
|
||||
return String.format("()L%s;", callSite.staticClass().intlName());
|
||||
}
|
||||
if (callSite.invokeInsn() == CallMethod.Invoke.STATIC) {
|
||||
return callSite.methodDesc(); // ignore receiver
|
||||
}
|
||||
return prependType(callSite.methodDesc(), callSite.staticClass().intlName());
|
||||
}
|
||||
|
||||
private void generateIndyCall(CallMethod callSite) {
|
||||
@ -368,7 +387,8 @@ public class ClassFileGenerator implements Visitor {
|
||||
prepareParams(callSite);
|
||||
|
||||
// Call method
|
||||
mv.visitInvokeDynamicInsn(callSite.methodName(), callSiteDesc, bootstrap);
|
||||
String name = callSite.isConstructorCall() ? "init" : callSite.methodName();
|
||||
mv.visitInvokeDynamicInsn(name, callSiteDesc, bootstrap);
|
||||
|
||||
// Pop method result, if necessary
|
||||
if (callSite.popReturnValue()) {
|
||||
@ -402,18 +422,26 @@ public class ClassFileGenerator implements Visitor {
|
||||
}
|
||||
|
||||
private void generateDirectCall(CallMethod callSite) {
|
||||
prepareParams(callSite);
|
||||
if (callSite.isConstructorCall()) {
|
||||
String receiver = callSite.receiverClass().intlName();
|
||||
// Construct new instance
|
||||
mv.visitTypeInsn(NEW, receiver);
|
||||
mv.visitMethodInsn(INVOKESPECIAL, receiver,
|
||||
"<init>", "()V", false);
|
||||
} else {
|
||||
prepareParams(callSite);
|
||||
|
||||
// Call method
|
||||
mv.visitMethodInsn(
|
||||
callSite.invokeInsn().opcode(),
|
||||
callSite.staticClass().intlName(),
|
||||
callSite.methodName(), callSite.methodDesc(),
|
||||
callSite.isInterface());
|
||||
// Call method
|
||||
mv.visitMethodInsn(
|
||||
callSite.invokeInsn().opcode(),
|
||||
callSite.staticClass().intlName(),
|
||||
callSite.methodName(), callSite.methodDesc(),
|
||||
callSite.isInterface());
|
||||
|
||||
// Pop method result, if necessary
|
||||
if (callSite.popReturnValue()) {
|
||||
mv.visitInsn(POP);
|
||||
// Pop method result, if necessary
|
||||
if (callSite.popReturnValue()) {
|
||||
mv.visitInsn(POP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -42,8 +42,6 @@ import vm.runtime.defmeth.ObjectMethodOverridesTest;
|
||||
import vm.runtime.defmeth.PrivateMethodsTest;
|
||||
import vm.runtime.defmeth.StaticMethodsTest;
|
||||
import vm.runtime.defmeth.SuperCallTest;
|
||||
import vm.runtime.defmeth.shared.annotation.Crash;
|
||||
import vm.runtime.defmeth.shared.annotation.KnownFailure;
|
||||
import vm.runtime.defmeth.shared.annotation.NotApplicableFor;
|
||||
import vm.runtime.defmeth.shared.builder.TestBuilderFactory;
|
||||
import vm.share.options.Option;
|
||||
@ -52,7 +50,6 @@ import vm.share.options.Options;
|
||||
import static java.lang.String.format;
|
||||
import java.util.Collections;
|
||||
import vm.runtime.defmeth.RedefineTest;
|
||||
import vm.runtime.defmeth.shared.annotation.NotTest;
|
||||
|
||||
/**
|
||||
* Parent class for all default method tests.
|
||||
@ -98,15 +95,6 @@ public abstract class DefMethTest extends TestBase {
|
||||
@Option(name="filter", default_value="", description="filter executed tests")
|
||||
String filterString;
|
||||
|
||||
@Option(name="ignoreKnownFailures", default_value="false", description="ignore tests with known failures")
|
||||
boolean ignoreKnownFailures;
|
||||
|
||||
@Option(name="runOnlyFailingTests", default_value="false", description="run only failing tests")
|
||||
boolean runOnlyFailingTests;
|
||||
|
||||
@Option(name="ignoreCrashes", default_value="false", description="don't run tests with crash VM")
|
||||
boolean ignoreCrashes;
|
||||
|
||||
@Option(name="silent", default_value="false", description="silent mode - don't print anything")
|
||||
boolean isSilent;
|
||||
|
||||
@ -117,7 +105,7 @@ public abstract class DefMethTest extends TestBase {
|
||||
boolean testAllModes;
|
||||
|
||||
@Option(name="mode", description="invocation mode (direct, reflect, invoke)", default_value="direct")
|
||||
private String mode;
|
||||
String mode;
|
||||
|
||||
private Pattern filter; // Precompiled pattern for filterString
|
||||
|
||||
@ -204,12 +192,7 @@ public abstract class DefMethTest extends TestBase {
|
||||
Class<? extends DefMethTest> test = this.getClass();
|
||||
|
||||
int acc = m.getModifiers();
|
||||
if (m.isAnnotationPresent(NotTest.class)
|
||||
|| (ignoreCrashes && m.isAnnotationPresent(Crash.class))
|
||||
|| !Modifier.isPublic(acc) || Modifier.isStatic(acc)
|
||||
//|| m.getReturnType() != Void.class
|
||||
|| m.getParameterTypes().length != 0)
|
||||
{
|
||||
if (!Modifier.isPublic(acc) || Modifier.isStatic(acc) || m.getParameterTypes().length != 0) {
|
||||
return false; // not a test
|
||||
}
|
||||
|
||||
@ -230,19 +213,6 @@ public abstract class DefMethTest extends TestBase {
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreKnownFailures &&
|
||||
m.isAnnotationPresent(KnownFailure.class)) {
|
||||
ExecutionMode[] modes = m.getAnnotation(KnownFailure.class).modes();
|
||||
|
||||
if (modes.length == 0) return false; // by default, matches all modes
|
||||
|
||||
for (ExecutionMode knownFailingMode : modes) {
|
||||
if (mode == knownFailingMode) {
|
||||
return false; // known failure in current mode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -274,22 +244,14 @@ public abstract class DefMethTest extends TestBase {
|
||||
*
|
||||
* The following execution customization is supported:
|
||||
* - filter tests by name using regex
|
||||
* - ignore tests marked as @KnownFailure
|
||||
* - ignore tests marked as @Crash
|
||||
* - only run tests marked as @KnownFailure
|
||||
*
|
||||
* @return any failures occurred?
|
||||
*/
|
||||
public final boolean runTest() {
|
||||
if (ignoreKnownFailures && runOnlyFailingTests) {
|
||||
throw new IllegalArgumentException("conflicting parameters");
|
||||
}
|
||||
|
||||
ExecutionMode[] invocationModes = getInvocationModes();
|
||||
|
||||
try {
|
||||
int totalTests = 0;
|
||||
int passedTests = 0;
|
||||
|
||||
Class<? extends DefMethTest> test = this.getClass();
|
||||
|
||||
@ -340,7 +302,7 @@ public abstract class DefMethTest extends TestBase {
|
||||
}
|
||||
}
|
||||
|
||||
passedTests = totalTests - numFailures;
|
||||
int passedTests = totalTests - numFailures;
|
||||
getLog().info(format("%d test run: %d passed, %d failed", totalTests, passedTests, numFailures));
|
||||
if (numFailures == 0) {
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -29,6 +29,8 @@ import vm.runtime.defmeth.shared.executor.MHInvokeWithArgsTest;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Executable;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@ -44,6 +46,11 @@ public class TestContext {
|
||||
return m.invoke(obj, args);
|
||||
}
|
||||
|
||||
public static Object invoke(Constructor m, Object... args)
|
||||
throws InvocationTargetException, IllegalAccessException, InstantiationException {
|
||||
return m.newInstance(args);
|
||||
}
|
||||
|
||||
public static Object invokeWithArguments(CallMethod.Invoke invokeType, Class<?> declaringClass,
|
||||
String methodName, MethodType type, Object... arguments) throws Throwable {
|
||||
// Need to do method lookup in the right context
|
||||
@ -56,7 +63,11 @@ public class TestContext {
|
||||
if (invokeType == CallMethod.Invoke.VIRTUAL || invokeType == CallMethod.Invoke.INTERFACE) {
|
||||
mh = LOOKUP.findVirtual(declaringClass, methodName, type);
|
||||
} else if (invokeType == CallMethod.Invoke.SPECIAL) {
|
||||
mh = LOOKUP.findSpecial(declaringClass, methodName, type, declaringClass);
|
||||
if (methodName.equals("<init>") && type.returnType() == void.class) {
|
||||
mh = LOOKUP.findConstructor(declaringClass, type);
|
||||
} else {
|
||||
mh = LOOKUP.findSpecial(declaringClass, methodName, type, declaringClass);
|
||||
}
|
||||
} else if (invokeType == CallMethod.Invoke.STATIC) {
|
||||
mh = LOOKUP.findStatic(declaringClass, methodName, type);
|
||||
} else {
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, 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 vm.runtime.defmeth.shared.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Mark a test that it may crash VM.
|
||||
* Allows to exclude all such tests when crashes are undesirable
|
||||
* (e.g. same VM execution mode).
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface Crash {}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, 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 vm.runtime.defmeth.shared.annotation;
|
||||
|
||||
import vm.runtime.defmeth.shared.ExecutionMode;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Mark a test that it may fail (due to a test or product bug).
|
||||
* Allows to exclude all failing tests when failures are undesirable.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface KnownFailure {
|
||||
ExecutionMode[] modes() default {};
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, 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 vm.runtime.defmeth.shared.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/*
|
||||
* Explicitly marks a method as not a test, thus ensuring that it won't be
|
||||
* executed as part of a test run.
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface NotTest {
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -137,9 +137,16 @@ public class TesterBuilder implements Builder<Tester> {
|
||||
return static_(I).callee(methodName, methodDesc, ACC_STATIC);
|
||||
}
|
||||
|
||||
public TesterBuilder callSite(Clazz I, String methodName, String methodDesc, int acc) {
|
||||
if ((acc & ACC_PRIVATE) != 0) {
|
||||
testPrivateMethod = true;
|
||||
}
|
||||
return static_(I).callee(methodName, methodDesc, acc);
|
||||
}
|
||||
|
||||
public TesterBuilder privateCallSite(Clazz staticReceiver, ConcreteClass receiver,
|
||||
String methodName, String methodDesc) {
|
||||
this.testPrivateMethod = true;
|
||||
testPrivateMethod = true;
|
||||
return static_(staticReceiver)
|
||||
.dynamic(receiver)
|
||||
.callee(methodName, methodDesc);
|
||||
@ -153,6 +160,10 @@ public class TesterBuilder implements Builder<Tester> {
|
||||
.cpEntryType(CallMethod.IndexbyteOp.INTERFACEMETHODREF);
|
||||
}
|
||||
|
||||
public TesterBuilder new_(ConcreteClass receiver) {
|
||||
return callSite(receiver, receiver,"<init>", "()V");
|
||||
}
|
||||
|
||||
public TesterBuilder params(int... intParams) {
|
||||
this.params = new Param[intParams.length];
|
||||
for (int i = 0; i < intParams.length; i++) {
|
||||
@ -217,18 +228,18 @@ public class TesterBuilder implements Builder<Tester> {
|
||||
private CallMethod.Invoke getCallInsn() {
|
||||
if ((m.acc() & Opcodes.ACC_STATIC) != 0) {
|
||||
return Invoke.STATIC;
|
||||
} else {
|
||||
if (staticReceiver instanceof Interface) {
|
||||
return Invoke.INTERFACE;
|
||||
} else if (staticReceiver instanceof ConcreteClass) {
|
||||
if ((m.acc() & Opcodes.ACC_INTERFACE) == 0) {
|
||||
return Invoke.VIRTUAL;
|
||||
} else {
|
||||
return Invoke.INTERFACE;
|
||||
}
|
||||
} else if (staticReceiver instanceof Interface) {
|
||||
return Invoke.INTERFACE;
|
||||
} else if (staticReceiver instanceof ConcreteClass) {
|
||||
if (m.isConstructor()) {
|
||||
return Invoke.SPECIAL;
|
||||
} else if ((m.acc() & Opcodes.ACC_INTERFACE) == 0) {
|
||||
return Invoke.VIRTUAL;
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Can't detect invoke instruction");
|
||||
return Invoke.INTERFACE;
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Can't detect invoke instruction");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -66,6 +66,10 @@ public class Method implements Element {
|
||||
return !desc.matches(".*V");
|
||||
}
|
||||
|
||||
public boolean isConstructor() {
|
||||
return name.equals("<init>") &&
|
||||
desc.equals("()V");
|
||||
}
|
||||
@Override
|
||||
public void visit(Visitor v) {
|
||||
v.visitMethod(this);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -171,6 +171,12 @@ public class CallMethod implements MethodBody {
|
||||
staticClass() instanceof Interface);
|
||||
}
|
||||
|
||||
public boolean isConstructorCall() {
|
||||
return invokeInsn() == Invoke.SPECIAL &&
|
||||
methodName().equals("<init>") &&
|
||||
methodDesc().equals("()V");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(Visitor v) {
|
||||
v.visitCallMethod(this);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -108,15 +108,14 @@ public class MHInvokeWithArgsTest extends AbstractReflectionTest {
|
||||
|
||||
Object[] values = values(params);
|
||||
|
||||
if (call.invokeInsn() != CallMethod.Invoke.STATIC) {
|
||||
if (!call.isConstructorCall() && call.invokeInsn() != CallMethod.Invoke.STATIC) {
|
||||
// Prepare receiver for non-static call
|
||||
args = new Object[params.length+1];
|
||||
Class recClass = resolve(receiverClass);
|
||||
args[0] = recClass.newInstance();
|
||||
System.arraycopy(values, 0, args, 1, values.length);
|
||||
} else {
|
||||
// No need for a receiver for static call
|
||||
args = values;
|
||||
args = values; // no receiver
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2021, 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
|
||||
@ -45,9 +45,7 @@ import vm.runtime.defmeth.shared.data.method.result.IntResult;
|
||||
import vm.runtime.defmeth.shared.data.method.result.ThrowExResult;
|
||||
import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -75,7 +73,7 @@ public class ReflectionTest extends AbstractReflectionTest {
|
||||
private CallMethod call;
|
||||
private Object receiver;
|
||||
|
||||
private Method targetMethod;
|
||||
private Executable targetMethod;
|
||||
private Object[] values;
|
||||
|
||||
private Tester tester;
|
||||
@ -106,42 +104,47 @@ public class ReflectionTest extends AbstractReflectionTest {
|
||||
throws IllegalAccessException, InstantiationException, ClassNotFoundException, NoSuchMethodException {
|
||||
Class<?> staticClass = resolve(call.staticClass());
|
||||
|
||||
String methodName = call.methodName();
|
||||
Class[] paramTypes = paramType(call.methodDesc());
|
||||
|
||||
if (tester.getTestPrivateMethod() != true) {
|
||||
targetMethod = staticClass.getMethod(methodName, paramTypes);
|
||||
if (call.isConstructorCall()) {
|
||||
targetMethod = staticClass.getDeclaredConstructor();
|
||||
} else {
|
||||
try {
|
||||
targetMethod = staticClass.getDeclaredMethod(methodName, paramTypes);
|
||||
} catch (NoSuchMethodException nsme) {}
|
||||
String methodName = call.methodName();
|
||||
Class[] paramTypes = paramType(call.methodDesc());
|
||||
|
||||
Class clazz = staticClass.getSuperclass();
|
||||
while ((targetMethod == null) && (clazz != null)) {
|
||||
if (tester.getTestPrivateMethod() != true) {
|
||||
targetMethod = staticClass.getMethod(methodName, paramTypes);
|
||||
} else {
|
||||
try {
|
||||
targetMethod = clazz.getDeclaredMethod(methodName, paramTypes);
|
||||
targetMethod = staticClass.getDeclaredMethod(methodName, paramTypes);
|
||||
} catch (NoSuchMethodException nsme) {}
|
||||
clazz = clazz.getSuperclass();
|
||||
|
||||
Class clazz = staticClass.getSuperclass();
|
||||
while ((targetMethod == null) && (clazz != null)) {
|
||||
try {
|
||||
targetMethod = clazz.getDeclaredMethod(methodName, paramTypes);
|
||||
} catch (NoSuchMethodException nsme) {}
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
}
|
||||
|
||||
// Check reflection info for Class.getMethod(...)
|
||||
checkReflectionInfo((Method)targetMethod);
|
||||
|
||||
// Prepare receiver after resolving target method, because it can throw instantiation exception
|
||||
if (call.invokeInsn() != CallMethod.Invoke.STATIC) {
|
||||
Class<?> receiverClass = resolve(call.receiverClass());
|
||||
receiver = receiverClass.newInstance();
|
||||
} else {
|
||||
// receiver == null; Method.invoke ignores first argument when static method is called
|
||||
}
|
||||
|
||||
// Check reflection info for Class.getDeclaredMethod(...)
|
||||
try {
|
||||
Method m = staticClass.getDeclaredMethod(methodName, paramTypes);
|
||||
checkReflectionInfo(m);
|
||||
} catch (NoSuchMethodException e) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check reflection info for Class.getMethod(...)
|
||||
checkReflectionInfo(targetMethod);
|
||||
|
||||
// Prepare receiver after resolving target method, because it can throw instantiation exception
|
||||
if (call.invokeInsn() != CallMethod.Invoke.STATIC) {
|
||||
Class<?> receiverClass = resolve(call.receiverClass());
|
||||
receiver = receiverClass.newInstance();
|
||||
} else {
|
||||
// receiver == null; Method.invoke ignores first argument when static method is called
|
||||
}
|
||||
|
||||
// Check reflection info for Class.getDeclaredMethod(...)
|
||||
try {
|
||||
Method m = staticClass.getDeclaredMethod(methodName, paramTypes);
|
||||
checkReflectionInfo(m);
|
||||
} catch (NoSuchMethodException e) {}
|
||||
|
||||
values = values(call.params());
|
||||
}
|
||||
|
||||
@ -237,11 +240,23 @@ public class ReflectionTest extends AbstractReflectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
private Object invokeInTestContext(Constructor m, Object... args)
|
||||
throws InvocationTargetException {
|
||||
Class<?> context = cl.getTestContext();
|
||||
try {
|
||||
// Invoke target method from TestContext using TestContext.invoke(Constructor, Object...)
|
||||
Method invoker = context.getDeclaredMethod("invoke", Constructor.class, Object[].class);
|
||||
return invoker.invoke(null, m, args);
|
||||
} catch (NoSuchMethodException | IllegalAccessException e) {
|
||||
throw new TestFailure("Exception during reflection invocation", e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitResultInt(IntResult res) {
|
||||
try {
|
||||
prepareForInvocation();
|
||||
int result = (int) invokeInTestContext(targetMethod, receiver, values);
|
||||
int result = (int) invokeInTestContext((Method)targetMethod, receiver, values);
|
||||
TestUtils.assertEquals(res.getExpected(), result);
|
||||
} catch (TestFailure e) {
|
||||
throw e; // no need to wrap test exception
|
||||
@ -293,8 +308,13 @@ public class ReflectionTest extends AbstractReflectionTest {
|
||||
String expectedExcName = res.getExc().name();
|
||||
try {
|
||||
prepareForInvocation(); // can throw an exception expected by a test
|
||||
invokeInTestContext(targetMethod, receiver, values);
|
||||
|
||||
if (targetMethod instanceof Method) {
|
||||
invokeInTestContext((Method)targetMethod, receiver, values);
|
||||
} else if (targetMethod instanceof Constructor) {
|
||||
invokeInTestContext((Constructor)targetMethod, receiver, values);
|
||||
} else {
|
||||
throw new InternalError("Unknown target: " + targetMethod);
|
||||
}
|
||||
throw new TestFailure("No exception was thrown: " + expectedExcName);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | ClassNotFoundException e) {
|
||||
throw new TestFailure("Exception during reflection invocation", e.getCause());
|
||||
@ -309,7 +329,13 @@ public class ReflectionTest extends AbstractReflectionTest {
|
||||
public void visitResultIgnore() {
|
||||
try {
|
||||
prepareForInvocation();
|
||||
invokeInTestContext(targetMethod, receiver, values);
|
||||
if (targetMethod instanceof Method) {
|
||||
invokeInTestContext((Method)targetMethod, receiver, values);
|
||||
} else if (targetMethod instanceof Constructor) {
|
||||
invokeInTestContext((Constructor)targetMethod, receiver, values);
|
||||
} else {
|
||||
throw new InternalError("Unknown target: " + targetMethod);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new TestFailure("Unexpected exception", e);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user