8156485: MethodHandles.varHandleExactInvoker should perform exact checks

Reviewed-by: vlivanov
This commit is contained in:
Paul Sandoz 2016-05-17 12:06:41 +02:00
parent c594c87387
commit 44afe20e99
40 changed files with 1190 additions and 1080 deletions

View File

@ -95,12 +95,12 @@ class Invokers {
/*non-public*/ MethodHandle varHandleMethodInvoker(VarHandle.AccessMode ak) { /*non-public*/ MethodHandle varHandleMethodInvoker(VarHandle.AccessMode ak) {
// TODO cache invoker // TODO cache invoker
return makeVarHandleMethodInvoker(ak); return makeVarHandleMethodInvoker(ak, false);
} }
/*non-public*/ MethodHandle varHandleMethodExactInvoker(VarHandle.AccessMode ak) { /*non-public*/ MethodHandle varHandleMethodExactInvoker(VarHandle.AccessMode ak) {
// TODO cache invoker // TODO cache invoker
return makeVarHandleMethodExactInvoker(ak); return makeVarHandleMethodInvoker(ak, true);
} }
private MethodHandle cachedInvoker(int idx) { private MethodHandle cachedInvoker(int idx) {
@ -127,26 +127,11 @@ class Invokers {
return invoker; return invoker;
} }
private MethodHandle makeVarHandleMethodInvoker(VarHandle.AccessMode ak) { private MethodHandle makeVarHandleMethodInvoker(VarHandle.AccessMode ak, boolean isExact) {
MethodType mtype = targetType; MethodType mtype = targetType;
MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class); MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class);
LambdaForm lform = varHandleMethodGenericInvokerHandleForm(ak.methodName(), mtype); LambdaForm lform = varHandleMethodInvokerHandleForm(ak.methodName(), mtype, isExact);
VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal());
MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad);
invoker = invoker.withInternalMemberName(MemberName.makeVarHandleMethodInvoke(ak.methodName(), mtype), false);
assert(checkVarHandleInvoker(invoker));
maybeCompileToBytecode(invoker);
return invoker;
}
private MethodHandle makeVarHandleMethodExactInvoker(VarHandle.AccessMode ak) {
MethodType mtype = targetType;
MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class);
LambdaForm lform = varHandleMethodExactInvokerHandleForm(ak.methodName(), mtype);
VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal()); VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal());
MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad); MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad);
@ -400,59 +385,7 @@ class Invokers {
return lform; return lform;
} }
private static LambdaForm varHandleMethodExactInvokerHandleForm(String name, MethodType mtype) { private static LambdaForm varHandleMethodInvokerHandleForm(String name, MethodType mtype, boolean isExact) {
// TODO Cache form?
final int THIS_MH = 0;
final int CALL_VH = THIS_MH + 1;
final int ARG_BASE = CALL_VH + 1;
final int ARG_LIMIT = ARG_BASE + mtype.parameterCount();
int nameCursor = ARG_LIMIT;
final int VAD_ARG = nameCursor++;
final int CHECK_TYPE = nameCursor++;
final int GET_MEMBER = nameCursor++;
final int LINKER_CALL = nameCursor++;
MethodType invokerFormType = mtype.insertParameterTypes(0, VarHandle.class)
.basicType()
.appendParameterTypes(MemberName.class);
MemberName linker = new MemberName(MethodHandle.class, "linkToStatic", invokerFormType, REF_invokeStatic);
try {
linker = MemberName.getFactory().resolveOrFail(REF_invokeStatic, linker, null, NoSuchMethodException.class);
} catch (ReflectiveOperationException ex) {
throw newInternalError(ex);
}
Name[] names = new Name[LINKER_CALL + 1];
names[THIS_MH] = argument(THIS_MH, BasicType.basicType(Object.class));
names[CALL_VH] = argument(CALL_VH, BasicType.basicType(Object.class));
for (int i = 0; i < mtype.parameterCount(); i++) {
names[ARG_BASE + i] = argument(ARG_BASE + i, BasicType.basicType(mtype.parameterType(i)));
}
BoundMethodHandle.SpeciesData speciesData = BoundMethodHandle.speciesData_L();
names[THIS_MH] = names[THIS_MH].withConstraint(speciesData);
NamedFunction getter = speciesData.getterFunction(0);
names[VAD_ARG] = new Name(getter, names[THIS_MH]);
Object[] outArgs = Arrays.copyOfRange(names, CALL_VH, ARG_LIMIT + 1, Object[].class);
names[CHECK_TYPE] = new Name(NF_checkVarHandleExactType, names[CALL_VH], names[VAD_ARG]);
names[GET_MEMBER] = new Name(NF_getVarHandleMemberName, names[CALL_VH], names[VAD_ARG]);
outArgs[outArgs.length - 1] = names[GET_MEMBER];
names[LINKER_CALL] = new Name(linker, outArgs);
LambdaForm lform = new LambdaForm(name + ":VarHandle_exactInvoker" + shortenSignature(basicTypeSignature(mtype)),
ARG_LIMIT, names);
lform.compileToBytecode();
return lform;
}
private static LambdaForm varHandleMethodGenericInvokerHandleForm(String name, MethodType mtype) {
// TODO Cache form? // TODO Cache form?
final int THIS_MH = 0; final int THIS_MH = 0;
@ -477,8 +410,11 @@ class Invokers {
NamedFunction getter = speciesData.getterFunction(0); NamedFunction getter = speciesData.getterFunction(0);
names[VAD_ARG] = new Name(getter, names[THIS_MH]); names[VAD_ARG] = new Name(getter, names[THIS_MH]);
names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[CALL_VH], names[VAD_ARG]); if (isExact) {
names[CHECK_TYPE] = new Name(NF_checkVarHandleExactType, names[CALL_VH], names[VAD_ARG]);
} else {
names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[CALL_VH], names[VAD_ARG]);
}
Object[] outArgs = new Object[ARG_LIMIT]; Object[] outArgs = new Object[ARG_LIMIT];
outArgs[0] = names[CHECK_TYPE]; outArgs[0] = names[CHECK_TYPE];
for (int i = 1; i < ARG_LIMIT; i++) { for (int i = 1; i < ARG_LIMIT; i++) {
@ -488,7 +424,8 @@ class Invokers {
MethodType outCallType = mtype.insertParameterTypes(0, VarHandle.class) MethodType outCallType = mtype.insertParameterTypes(0, VarHandle.class)
.basicType(); .basicType();
names[LINKER_CALL] = new Name(outCallType, outArgs); names[LINKER_CALL] = new Name(outCallType, outArgs);
LambdaForm lform = new LambdaForm(name + ":VarHandle_invoker" + shortenSignature(basicTypeSignature(mtype)), String debugName = isExact ? ":VarHandle_exactInvoker" : ":VarHandle_invoker";
LambdaForm lform = new LambdaForm(name + debugName + shortenSignature(basicTypeSignature(mtype)),
ARG_LIMIT, names); ARG_LIMIT, names);
lform.prepare(); lform.prepare();
@ -511,21 +448,13 @@ class Invokers {
/*non-public*/ static /*non-public*/ static
@ForceInline @ForceInline
void checkVarHandleExactType(VarHandle handle, VarHandle.AccessDescriptor ad) { MethodHandle checkVarHandleExactType(VarHandle handle, VarHandle.AccessDescriptor ad) {
MethodType erasedTarget = handle.vform.methodType_table[ad.type]; MethodHandle mh = handle.getMethodHandle(ad.mode);
MethodType erasedSymbolic = ad.symbolicMethodTypeErased; MethodType mt = mh.type();
if (erasedTarget != erasedSymbolic) if (mt != ad.symbolicMethodTypeInvoker) {
throw newWrongMethodTypeException(erasedTarget, erasedSymbolic); throw newWrongMethodTypeException(mt, ad.symbolicMethodTypeInvoker);
}
/*non-public*/ static
@ForceInline
MemberName getVarHandleMemberName(VarHandle handle, VarHandle.AccessDescriptor ad) {
MemberName mn = handle.vform.memberName_table[ad.mode];
if (mn == null) {
throw handle.unsupported();
} }
return mn; return mh;
} }
/*non-public*/ static /*non-public*/ static
@ -649,8 +578,7 @@ class Invokers {
NF_getCallSiteTarget, NF_getCallSiteTarget,
NF_checkCustomized, NF_checkCustomized,
NF_checkVarHandleGenericType, NF_checkVarHandleGenericType,
NF_checkVarHandleExactType, NF_checkVarHandleExactType;
NF_getVarHandleMemberName;
static { static {
try { try {
NamedFunction nfs[] = { NamedFunction nfs[] = {
@ -666,8 +594,6 @@ class Invokers {
.getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class)), .getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class)),
NF_checkVarHandleExactType = new NamedFunction(Invokers.class NF_checkVarHandleExactType = new NamedFunction(Invokers.class
.getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class)), .getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class)),
NF_getVarHandleMemberName = new NamedFunction(Invokers.class
.getDeclaredMethod("getVarHandleMemberName", VarHandle.class, VarHandle.AccessDescriptor.class))
}; };
// Each nf must be statically invocable or we get tied up in our bootstraps. // Each nf must be statically invocable or we get tied up in our bootstraps.
assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs)); assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs));

View File

@ -1475,11 +1475,11 @@ public abstract class VarHandle {
TypesAndInvokers tis = getTypesAndInvokers(); TypesAndInvokers tis = getTypesAndInvokers();
MethodHandle mh = tis.methodHandle_table[mode]; MethodHandle mh = tis.methodHandle_table[mode];
if (mh == null) { if (mh == null) {
mh = tis.methodHandle_table[mode] = getMethodHandleUncached(tis, mode); mh = tis.methodHandle_table[mode] = getMethodHandleUncached(mode);
} }
return mh; return mh;
} }
private final MethodHandle getMethodHandleUncached(TypesAndInvokers tis, int mode) { private final MethodHandle getMethodHandleUncached(int mode) {
MethodType mt = accessModeType(AccessMode.values()[mode]). MethodType mt = accessModeType(AccessMode.values()[mode]).
insertParameterTypes(0, VarHandle.class); insertParameterTypes(0, VarHandle.class);
MemberName mn = vform.getMemberName(mode); MemberName mn = vform.getMemberName(mode);

View File

@ -211,7 +211,6 @@ abstract class VarHandleBaseTest {
} }
static MethodHandle findVirtual(VarHandle vh, TestAccessMode tam, MethodType mt) { static MethodHandle findVirtual(VarHandle vh, TestAccessMode tam, MethodType mt) {
mt = vh.accessModeType(tam.toAccessMode());
MethodHandle mh; MethodHandle mh;
try { try {
mh = MethodHandles.publicLookup(). mh = MethodHandles.publicLookup().
@ -221,36 +220,26 @@ abstract class VarHandleBaseTest {
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return bind(vh, tam, mh, mt); return bind(vh, mh, mt);
} }
static MethodHandle varHandleInvokerWithAccessModeType(VarHandle vh, TestAccessMode tam, MethodType mt) { static MethodHandle varHandleInvoker(VarHandle vh, TestAccessMode tam, MethodType mt) {
mt = vh.accessModeType(tam.toAccessMode());
MethodHandle mh = MethodHandles.varHandleInvoker( MethodHandle mh = MethodHandles.varHandleInvoker(
tam.toAccessMode(), tam.toAccessMode(),
mt); mt);
return bind(vh, tam, mh, mt); return bind(vh, mh, mt);
} }
static MethodHandle varHandleInvokerWithSymbolicTypeDescriptor(VarHandle vh, TestAccessMode tam, MethodType mt) { static MethodHandle varHandleExactInvoker(VarHandle vh, TestAccessMode tam, MethodType mt) {
MethodHandle mh = MethodHandles.varHandleInvoker(
tam.toAccessMode(),
mt);
return bind(vh, tam, mh, mt);
}
static MethodHandle varHandleExactInvokerWithAccessModeType(VarHandle vh, TestAccessMode tam, MethodType mt) {
mt = vh.accessModeType(tam.toAccessMode());
MethodHandle mh = MethodHandles.varHandleExactInvoker( MethodHandle mh = MethodHandles.varHandleExactInvoker(
tam.toAccessMode(), tam.toAccessMode(),
mt); mt);
return bind(vh, tam, mh, mt); return bind(vh, mh, mt);
} }
private static MethodHandle bind(VarHandle vh, TestAccessMode testAccessMode, MethodHandle mh, MethodType emt) { private static MethodHandle bind(VarHandle vh, MethodHandle mh, MethodType emt) {
assertEquals(mh.type(), emt.insertParameterTypes(0, VarHandle.class), assertEquals(mh.type(), emt.insertParameterTypes(0, VarHandle.class),
"MethodHandle type differs from access mode type"); "MethodHandle type differs from access mode type");
@ -268,33 +257,30 @@ abstract class VarHandleBaseTest {
enum VarHandleToMethodHandle { enum VarHandleToMethodHandle {
VAR_HANDLE_TO_METHOD_HANDLE( VAR_HANDLE_TO_METHOD_HANDLE(
"VarHandle.toMethodHandle", "VarHandle.toMethodHandle",
true,
VarHandleBaseTest::toMethodHandle), VarHandleBaseTest::toMethodHandle),
METHOD_HANDLES_LOOKUP_FIND_VIRTUAL( METHOD_HANDLES_LOOKUP_FIND_VIRTUAL(
"Lookup.findVirtual", "Lookup.findVirtual",
false,
VarHandleBaseTest::findVirtual), VarHandleBaseTest::findVirtual),
METHOD_HANDLES_VAR_HANDLE_INVOKER_WITH_ACCESS_MODE_TYPE( METHOD_HANDLES_VAR_HANDLE_INVOKER(
"MethodHandles.varHandleInvoker(accessModeType)", "MethodHandles.varHandleInvoker",
VarHandleBaseTest::varHandleInvokerWithAccessModeType), false,
METHOD_HANDLES_VAR_HANDLE_INVOKER_WITH_SYMBOLIC_TYPE_DESCRIPTOR( VarHandleBaseTest::varHandleInvoker),
"MethodHandles.varHandleInvoker(symbolicTypeDescriptor)", METHOD_HANDLES_VAR_HANDLE_EXACT_INVOKER(
VarHandleBaseTest::varHandleInvokerWithSymbolicTypeDescriptor), "MethodHandles.varHandleExactInvoker",
METHOD_HANDLES_VAR_HANDLE_EXACT_INVOKER_WITH_ACCESS_MODE_TYPE( true,
"MethodHandles.varHandleExactInvoker(accessModeType)", VarHandleBaseTest::varHandleExactInvoker);
VarHandleBaseTest::varHandleExactInvokerWithAccessModeType);
final String desc; final String desc;
final boolean isExact;
final TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f; final TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f;
final boolean exact;
VarHandleToMethodHandle(String desc, TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f) { VarHandleToMethodHandle(String desc, boolean isExact,
this(desc, f, false); TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f) {
}
VarHandleToMethodHandle(String desc, TriFunction<VarHandle, TestAccessMode, MethodType, MethodHandle> f,
boolean exact) {
this.desc = desc; this.desc = desc;
this.f = f; this.f = f;
this.exact = exact; this.isExact = isExact;
} }
MethodHandle apply(VarHandle vh, TestAccessMode am, MethodType mt) { MethodHandle apply(VarHandle vh, TestAccessMode am, MethodType mt) {
@ -363,6 +349,15 @@ abstract class VarHandleBaseTest {
return amToHandle.computeIfAbsent( return amToHandle.computeIfAbsent(
amt, k -> f.apply(vh, am, mt)); amt, k -> f.apply(vh, am, mt));
} }
Class<? extends Throwable> getWMTEOOrOther(Class<? extends Throwable> c) {
return f.isExact ? WrongMethodTypeException.class : c;
}
void checkWMTEOrCCE(ThrowingRunnable r) {
checkWithThrowable(getWMTEOOrOther(ClassCastException.class), null, r);
}
} }
interface AccessTestAction<T> { interface AccessTestAction<T> {

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessBoolean * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessBoolean
* @run testng/othervm -Diters=20000 VarHandleTestAccessBoolean * @run testng/othervm -Diters=20000 VarHandleTestAccessBoolean
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessBoolean * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessBoolean
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessBoolean
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@ -292,6 +293,10 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, true, false); boolean r = vh.weakCompareAndSetRelease(recv, true, false);
}); });
checkUOE(() -> {
boolean r = (boolean) vh.getAndSet(recv, true);
});
checkUOE(() -> { checkUOE(() -> {
boolean o = (boolean) vh.getAndAdd(recv, true); boolean o = (boolean) vh.getAndAdd(recv, true);
}); });
@ -378,6 +383,10 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(true, false); boolean r = vh.weakCompareAndSetRelease(true, false);
}); });
checkUOE(() -> {
boolean r = (boolean) vh.getAndSet(true);
});
checkUOE(() -> { checkUOE(() -> {
boolean o = (boolean) vh.getAndAdd(true); boolean o = (boolean) vh.getAndAdd(true);
}); });
@ -454,6 +463,10 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, true, false); boolean r = vh.weakCompareAndSetRelease(recv, true, false);
}); });
checkUOE(() -> {
boolean r = (boolean) vh.getAndSet(recv, true);
});
checkUOE(() -> { checkUOE(() -> {
boolean o = (boolean) vh.getAndAdd(recv, true); boolean o = (boolean) vh.getAndAdd(recv, true);
}); });
@ -530,6 +543,10 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(true, false); boolean r = vh.weakCompareAndSetRelease(true, false);
}); });
checkUOE(() -> {
boolean r = (boolean) vh.getAndSet(true);
});
checkUOE(() -> { checkUOE(() -> {
boolean o = (boolean) vh.getAndAdd(true); boolean o = (boolean) vh.getAndAdd(true);
}); });
@ -613,6 +630,10 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(array, i, true, false); boolean r = vh.weakCompareAndSetRelease(array, i, true, false);
}); });
checkUOE(() -> {
boolean r = (boolean) vh.getAndSet(array, i, true);
});
checkUOE(() -> { checkUOE(() -> {
boolean o = (boolean) vh.getAndAdd(array, i, true); boolean o = (boolean) vh.getAndAdd(array, i, true);
}); });

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessByte * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessByte
* @run testng/othervm -Diters=20000 VarHandleTestAccessByte * @run testng/othervm -Diters=20000 VarHandleTestAccessByte
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessByte * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessByte
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessByte
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@ -292,6 +293,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, (byte)1, (byte)2); boolean r = vh.weakCompareAndSetRelease(recv, (byte)1, (byte)2);
}); });
checkUOE(() -> {
byte r = (byte) vh.getAndSet(recv, (byte)1);
});
checkUOE(() -> { checkUOE(() -> {
byte o = (byte) vh.getAndAdd(recv, (byte)1); byte o = (byte) vh.getAndAdd(recv, (byte)1);
}); });
@ -378,6 +383,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease((byte)1, (byte)2); boolean r = vh.weakCompareAndSetRelease((byte)1, (byte)2);
}); });
checkUOE(() -> {
byte r = (byte) vh.getAndSet((byte)1);
});
checkUOE(() -> { checkUOE(() -> {
byte o = (byte) vh.getAndAdd((byte)1); byte o = (byte) vh.getAndAdd((byte)1);
}); });
@ -454,6 +463,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, (byte)1, (byte)2); boolean r = vh.weakCompareAndSetRelease(recv, (byte)1, (byte)2);
}); });
checkUOE(() -> {
byte r = (byte) vh.getAndSet(recv, (byte)1);
});
checkUOE(() -> { checkUOE(() -> {
byte o = (byte) vh.getAndAdd(recv, (byte)1); byte o = (byte) vh.getAndAdd(recv, (byte)1);
}); });
@ -530,6 +543,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease((byte)1, (byte)2); boolean r = vh.weakCompareAndSetRelease((byte)1, (byte)2);
}); });
checkUOE(() -> {
byte r = (byte) vh.getAndSet((byte)1);
});
checkUOE(() -> { checkUOE(() -> {
byte o = (byte) vh.getAndAdd((byte)1); byte o = (byte) vh.getAndAdd((byte)1);
}); });
@ -613,6 +630,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(array, i, (byte)1, (byte)2); boolean r = vh.weakCompareAndSetRelease(array, i, (byte)1, (byte)2);
}); });
checkUOE(() -> {
byte r = (byte) vh.getAndSet(array, i, (byte)1);
});
checkUOE(() -> { checkUOE(() -> {
byte o = (byte) vh.getAndAdd(array, i, (byte)1); byte o = (byte) vh.getAndAdd(array, i, (byte)1);
}); });

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessChar * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessChar
* @run testng/othervm -Diters=20000 VarHandleTestAccessChar * @run testng/othervm -Diters=20000 VarHandleTestAccessChar
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessChar * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessChar
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessChar
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@ -292,6 +293,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, 'a', 'b'); boolean r = vh.weakCompareAndSetRelease(recv, 'a', 'b');
}); });
checkUOE(() -> {
char r = (char) vh.getAndSet(recv, 'a');
});
checkUOE(() -> { checkUOE(() -> {
char o = (char) vh.getAndAdd(recv, 'a'); char o = (char) vh.getAndAdd(recv, 'a');
}); });
@ -378,6 +383,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease('a', 'b'); boolean r = vh.weakCompareAndSetRelease('a', 'b');
}); });
checkUOE(() -> {
char r = (char) vh.getAndSet('a');
});
checkUOE(() -> { checkUOE(() -> {
char o = (char) vh.getAndAdd('a'); char o = (char) vh.getAndAdd('a');
}); });
@ -454,6 +463,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, 'a', 'b'); boolean r = vh.weakCompareAndSetRelease(recv, 'a', 'b');
}); });
checkUOE(() -> {
char r = (char) vh.getAndSet(recv, 'a');
});
checkUOE(() -> { checkUOE(() -> {
char o = (char) vh.getAndAdd(recv, 'a'); char o = (char) vh.getAndAdd(recv, 'a');
}); });
@ -530,6 +543,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease('a', 'b'); boolean r = vh.weakCompareAndSetRelease('a', 'b');
}); });
checkUOE(() -> {
char r = (char) vh.getAndSet('a');
});
checkUOE(() -> { checkUOE(() -> {
char o = (char) vh.getAndAdd('a'); char o = (char) vh.getAndAdd('a');
}); });
@ -613,6 +630,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(array, i, 'a', 'b'); boolean r = vh.weakCompareAndSetRelease(array, i, 'a', 'b');
}); });
checkUOE(() -> {
char r = (char) vh.getAndSet(array, i, 'a');
});
checkUOE(() -> { checkUOE(() -> {
char o = (char) vh.getAndAdd(array, i, 'a'); char o = (char) vh.getAndAdd(array, i, 'a');
}); });

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessDouble * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessDouble
* @run testng/othervm -Diters=20000 VarHandleTestAccessDouble * @run testng/othervm -Diters=20000 VarHandleTestAccessDouble
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessDouble * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessDouble
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessDouble
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@ -292,6 +293,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, 1.0d, 2.0d); boolean r = vh.weakCompareAndSetRelease(recv, 1.0d, 2.0d);
}); });
checkUOE(() -> {
double r = (double) vh.getAndSet(recv, 1.0d);
});
checkUOE(() -> { checkUOE(() -> {
double o = (double) vh.getAndAdd(recv, 1.0d); double o = (double) vh.getAndAdd(recv, 1.0d);
}); });
@ -378,6 +383,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(1.0d, 2.0d); boolean r = vh.weakCompareAndSetRelease(1.0d, 2.0d);
}); });
checkUOE(() -> {
double r = (double) vh.getAndSet(1.0d);
});
checkUOE(() -> { checkUOE(() -> {
double o = (double) vh.getAndAdd(1.0d); double o = (double) vh.getAndAdd(1.0d);
}); });
@ -454,6 +463,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, 1.0d, 2.0d); boolean r = vh.weakCompareAndSetRelease(recv, 1.0d, 2.0d);
}); });
checkUOE(() -> {
double r = (double) vh.getAndSet(recv, 1.0d);
});
checkUOE(() -> { checkUOE(() -> {
double o = (double) vh.getAndAdd(recv, 1.0d); double o = (double) vh.getAndAdd(recv, 1.0d);
}); });
@ -530,6 +543,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(1.0d, 2.0d); boolean r = vh.weakCompareAndSetRelease(1.0d, 2.0d);
}); });
checkUOE(() -> {
double r = (double) vh.getAndSet(1.0d);
});
checkUOE(() -> { checkUOE(() -> {
double o = (double) vh.getAndAdd(1.0d); double o = (double) vh.getAndAdd(1.0d);
}); });
@ -613,6 +630,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(array, i, 1.0d, 2.0d); boolean r = vh.weakCompareAndSetRelease(array, i, 1.0d, 2.0d);
}); });
checkUOE(() -> {
double r = (double) vh.getAndSet(array, i, 1.0d);
});
checkUOE(() -> { checkUOE(() -> {
double o = (double) vh.getAndAdd(array, i, 1.0d); double o = (double) vh.getAndAdd(array, i, 1.0d);
}); });

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessFloat * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessFloat
* @run testng/othervm -Diters=20000 VarHandleTestAccessFloat * @run testng/othervm -Diters=20000 VarHandleTestAccessFloat
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessFloat * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessFloat
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessFloat
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@ -292,6 +293,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, 1.0f, 2.0f); boolean r = vh.weakCompareAndSetRelease(recv, 1.0f, 2.0f);
}); });
checkUOE(() -> {
float r = (float) vh.getAndSet(recv, 1.0f);
});
checkUOE(() -> { checkUOE(() -> {
float o = (float) vh.getAndAdd(recv, 1.0f); float o = (float) vh.getAndAdd(recv, 1.0f);
}); });
@ -378,6 +383,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(1.0f, 2.0f); boolean r = vh.weakCompareAndSetRelease(1.0f, 2.0f);
}); });
checkUOE(() -> {
float r = (float) vh.getAndSet(1.0f);
});
checkUOE(() -> { checkUOE(() -> {
float o = (float) vh.getAndAdd(1.0f); float o = (float) vh.getAndAdd(1.0f);
}); });
@ -454,6 +463,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, 1.0f, 2.0f); boolean r = vh.weakCompareAndSetRelease(recv, 1.0f, 2.0f);
}); });
checkUOE(() -> {
float r = (float) vh.getAndSet(recv, 1.0f);
});
checkUOE(() -> { checkUOE(() -> {
float o = (float) vh.getAndAdd(recv, 1.0f); float o = (float) vh.getAndAdd(recv, 1.0f);
}); });
@ -530,6 +543,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(1.0f, 2.0f); boolean r = vh.weakCompareAndSetRelease(1.0f, 2.0f);
}); });
checkUOE(() -> {
float r = (float) vh.getAndSet(1.0f);
});
checkUOE(() -> { checkUOE(() -> {
float o = (float) vh.getAndAdd(1.0f); float o = (float) vh.getAndAdd(1.0f);
}); });
@ -613,6 +630,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(array, i, 1.0f, 2.0f); boolean r = vh.weakCompareAndSetRelease(array, i, 1.0f, 2.0f);
}); });
checkUOE(() -> {
float r = (float) vh.getAndSet(array, i, 1.0f);
});
checkUOE(() -> { checkUOE(() -> {
float o = (float) vh.getAndAdd(array, i, 1.0f); float o = (float) vh.getAndAdd(array, i, 1.0f);
}); });

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessInt * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessInt
* @run testng/othervm -Diters=20000 VarHandleTestAccessInt * @run testng/othervm -Diters=20000 VarHandleTestAccessInt
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessInt * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessInt
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessInt
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessLong * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessLong
* @run testng/othervm -Diters=20000 VarHandleTestAccessLong * @run testng/othervm -Diters=20000 VarHandleTestAccessLong
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessLong * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessLong
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessLong
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessShort * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessShort
* @run testng/othervm -Diters=20000 VarHandleTestAccessShort * @run testng/othervm -Diters=20000 VarHandleTestAccessShort
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessShort * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessShort
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessShort
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@ -292,6 +293,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, (short)1, (short)2); boolean r = vh.weakCompareAndSetRelease(recv, (short)1, (short)2);
}); });
checkUOE(() -> {
short r = (short) vh.getAndSet(recv, (short)1);
});
checkUOE(() -> { checkUOE(() -> {
short o = (short) vh.getAndAdd(recv, (short)1); short o = (short) vh.getAndAdd(recv, (short)1);
}); });
@ -378,6 +383,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease((short)1, (short)2); boolean r = vh.weakCompareAndSetRelease((short)1, (short)2);
}); });
checkUOE(() -> {
short r = (short) vh.getAndSet((short)1);
});
checkUOE(() -> { checkUOE(() -> {
short o = (short) vh.getAndAdd((short)1); short o = (short) vh.getAndAdd((short)1);
}); });
@ -454,6 +463,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(recv, (short)1, (short)2); boolean r = vh.weakCompareAndSetRelease(recv, (short)1, (short)2);
}); });
checkUOE(() -> {
short r = (short) vh.getAndSet(recv, (short)1);
});
checkUOE(() -> { checkUOE(() -> {
short o = (short) vh.getAndAdd(recv, (short)1); short o = (short) vh.getAndAdd(recv, (short)1);
}); });
@ -530,6 +543,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease((short)1, (short)2); boolean r = vh.weakCompareAndSetRelease((short)1, (short)2);
}); });
checkUOE(() -> {
short r = (short) vh.getAndSet((short)1);
});
checkUOE(() -> { checkUOE(() -> {
short o = (short) vh.getAndAdd((short)1); short o = (short) vh.getAndAdd((short)1);
}); });
@ -613,6 +630,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest {
boolean r = vh.weakCompareAndSetRelease(array, i, (short)1, (short)2); boolean r = vh.weakCompareAndSetRelease(array, i, (short)1, (short)2);
}); });
checkUOE(() -> {
short r = (short) vh.getAndSet(array, i, (short)1);
});
checkUOE(() -> { checkUOE(() -> {
short o = (short) vh.getAndAdd(array, i, (short)1); short o = (short) vh.getAndAdd(array, i, (short)1);
}); });

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessString * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessString
* @run testng/othervm -Diters=20000 VarHandleTestAccessString * @run testng/othervm -Diters=20000 VarHandleTestAccessString
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessString * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessString
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessString
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsChar * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsChar
* @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsChar * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsChar
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsChar * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsChar
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsChar
*/ */
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
@ -253,6 +254,10 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest {
checkROBE(() -> { checkROBE(() -> {
vh.setOpaque(array, ci, VALUE_1); vh.setOpaque(array, ci, VALUE_1);
}); });
checkUOE(() -> {
boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
});
checkUOE(() -> { checkUOE(() -> {
char r = (char) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1); char r = (char) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1);
}); });

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsDouble * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsDouble
* @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsDouble * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsDouble
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsDouble * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsDouble
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsDouble
*/ */
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
@ -254,9 +255,7 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest {
checkROBE(() -> { checkROBE(() -> {
double o = (double) vh.getAndSet(array, ci, VALUE_1); double o = (double) vh.getAndSet(array, ci, VALUE_1);
}); });
checkUOE(() -> {
boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
});
checkUOE(() -> { checkUOE(() -> {
double o = (double) vh.getAndAdd(array, ci, VALUE_1); double o = (double) vh.getAndAdd(array, ci, VALUE_1);

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsFloat * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsFloat
* @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsFloat * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsFloat
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsFloat * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsFloat
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsFloat
*/ */
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
@ -254,9 +255,7 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest {
checkROBE(() -> { checkROBE(() -> {
float o = (float) vh.getAndSet(array, ci, VALUE_1); float o = (float) vh.getAndSet(array, ci, VALUE_1);
}); });
checkUOE(() -> {
boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
});
checkUOE(() -> { checkUOE(() -> {
float o = (float) vh.getAndAdd(array, ci, VALUE_1); float o = (float) vh.getAndAdd(array, ci, VALUE_1);

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsInt * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsInt
* @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsInt * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsInt
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsInt * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsInt
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsInt
*/ */
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
@ -247,9 +248,7 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest {
checkROBE(() -> { checkROBE(() -> {
int o = (int) vh.getAndSet(array, ci, VALUE_1); int o = (int) vh.getAndSet(array, ci, VALUE_1);
}); });
checkUOE(() -> {
boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
});
checkROBE(() -> { checkROBE(() -> {
int o = (int) vh.getAndAdd(array, ci, VALUE_1); int o = (int) vh.getAndAdd(array, ci, VALUE_1);

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsLong * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsLong
* @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsLong * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsLong
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsLong * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsLong
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsLong
*/ */
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
@ -247,9 +248,7 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest {
checkROBE(() -> { checkROBE(() -> {
long o = (long) vh.getAndSet(array, ci, VALUE_1); long o = (long) vh.getAndSet(array, ci, VALUE_1);
}); });
checkUOE(() -> {
boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
});
checkROBE(() -> { checkROBE(() -> {
long o = (long) vh.getAndAdd(array, ci, VALUE_1); long o = (long) vh.getAndAdd(array, ci, VALUE_1);

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsShort * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsShort
* @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsShort * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsShort
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsShort * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsShort
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsShort
*/ */
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
@ -253,6 +254,10 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest {
checkROBE(() -> { checkROBE(() -> {
vh.setOpaque(array, ci, VALUE_1); vh.setOpaque(array, ci, VALUE_1);
}); });
checkUOE(() -> {
boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
});
checkUOE(() -> { checkUOE(() -> {
short r = (short) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1); short r = (short) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1);
}); });

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessBoolean * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessBoolean
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessBoolean
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessByte * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessByte
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessByte
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessChar * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessChar
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessChar
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessDouble * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessDouble
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessDouble
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessFloat * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessFloat
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessFloat
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessInt * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessInt
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessInt
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessLong * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessLong
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessLong
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessShort * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessShort
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessShort
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessString * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessString
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessString
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 8156486
* @run testng/othervm VarHandleTestMethodTypeBoolean * @run testng/othervm VarHandleTestMethodTypeBoolean
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeBoolean * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeBoolean
*/ */
@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest {
public Object[][] accessTestCaseProvider() throws Exception { public Object[][] accessTestCaseProvider() throws Exception {
List<AccessTestCase<?>> cases = new ArrayList<>(); List<AccessTestCase<?>> cases = new ArrayList<>();
cases.add(new VarHandleAccessTestCase("Instance field wrong method type", cases.add(new VarHandleAccessTestCase("Instance field",
vhField, vh -> testInstanceFieldWrongMethodType(this, vh), vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
false)); false));
cases.add(new VarHandleAccessTestCase("Static field wrong method type", cases.add(new VarHandleAccessTestCase("Static field",
vhStaticField, VarHandleTestMethodTypeBoolean::testStaticFieldWrongMethodType, vhStaticField, VarHandleTestMethodTypeBoolean::testStaticFieldWrongMethodType,
false)); false));
cases.add(new VarHandleAccessTestCase("Array wrong method type", cases.add(new VarHandleAccessTestCase("Array",
vhArray, VarHandleTestMethodTypeBoolean::testArrayWrongMethodType, vhArray, VarHandleTestMethodTypeBoolean::testArrayWrongMethodType,
false)); false));
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", cases.add(new MethodHandleAccessTestCase("Instance field",
vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
false)); false));
cases.add(new MethodHandleAccessTestCase("Static field wrong method type", cases.add(new MethodHandleAccessTestCase("Static field",
vhStaticField, f, VarHandleTestMethodTypeBoolean::testStaticFieldWrongMethodType, vhStaticField, f, VarHandleTestMethodTypeBoolean::testStaticFieldWrongMethodType,
false)); false));
cases.add(new MethodHandleAccessTestCase("Array wrong method type", cases.add(new MethodHandleAccessTestCase("Array",
vhArray, f, VarHandleTestMethodTypeBoolean::testArrayWrongMethodType, vhArray, f, VarHandleTestMethodTypeBoolean::testArrayWrongMethodType,
false)); false));
} }
@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class)).
invoke(null); invokeExact((VarHandleTestMethodTypeBoolean) null);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
invoke(0); invokeExact(0);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class)). Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeBoolean.class)).
invoke(recv); invokeExact(recv);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeBoolean.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeBoolean.class)).
invoke(recv); invokeExact(recv);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean x = (boolean) hs.get(am, methodType(boolean.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, boolean.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, boolean.class)).
invoke(null, true); invokeExact((VarHandleTestMethodTypeBoolean) null, true);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, boolean.class)). hs.get(am, methodType(void.class, Class.class, boolean.class)).
invoke(Void.class, true); invokeExact(Void.class, true);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, boolean.class)). hs.get(am, methodType(void.class, int.class, boolean.class)).
invoke(0, true); invokeExact(0, true);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, boolean.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, boolean.class, Class.class)).
invoke(recv, true, Void.class); invokeExact(recv, true, Void.class);
}); });
} }
@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest {
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)). Void x = (Void) hs.get(am, methodType(Void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean x = (boolean) hs.get(am, methodType(Class.class)). boolean x = (boolean) hs.get(am, methodType(Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)). hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, boolean.class, Class.class)). hs.get(am, methodType(void.class, boolean.class, Class.class)).
invoke(true, Void.class); invokeExact(true, Void.class);
}); });
} }
@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class)).
invoke(null, 0); invokeExact((boolean[]) null, 0);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)).
invoke(Void.class, 0); invokeExact(Void.class, 0);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)).
invoke(0, 0); invokeExact(0, 0);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class)).
invoke(array, Void.class); invokeExact(array, Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class, boolean[].class, int.class)). Void x = (Void) hs.get(am, methodType(Void.class, boolean[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
int x = (int) hs.get(am, methodType(int.class, boolean[].class, int.class)). int x = (int) hs.get(am, methodType(int.class, boolean[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean x = (boolean) hs.get(am, methodType(boolean.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, boolean.class)). hs.get(am, methodType(void.class, boolean[].class, int.class, boolean.class)).
invoke(null, 0, true); invokeExact((boolean[]) null, 0, true);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, boolean.class)). hs.get(am, methodType(void.class, Class.class, int.class, boolean.class)).
invoke(Void.class, 0, true); invokeExact(Void.class, 0, true);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)). hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, boolean.class)). hs.get(am, methodType(void.class, int.class, int.class, boolean.class)).
invoke(0, 0, true); invokeExact(0, 0, true);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, boolean[].class, Class.class, boolean.class)). hs.get(am, methodType(void.class, boolean[].class, Class.class, boolean.class)).
invoke(array, Void.class, true); invokeExact(array, Void.class, true);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)). hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)).
invoke(array, 0, true, Void.class); invokeExact(array, 0, true, Void.class);
}); });
} }

View File

@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 8156486
* @run testng/othervm VarHandleTestMethodTypeByte * @run testng/othervm VarHandleTestMethodTypeByte
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeByte * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeByte
*/ */
@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest {
public Object[][] accessTestCaseProvider() throws Exception { public Object[][] accessTestCaseProvider() throws Exception {
List<AccessTestCase<?>> cases = new ArrayList<>(); List<AccessTestCase<?>> cases = new ArrayList<>();
cases.add(new VarHandleAccessTestCase("Instance field wrong method type", cases.add(new VarHandleAccessTestCase("Instance field",
vhField, vh -> testInstanceFieldWrongMethodType(this, vh), vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
false)); false));
cases.add(new VarHandleAccessTestCase("Static field wrong method type", cases.add(new VarHandleAccessTestCase("Static field",
vhStaticField, VarHandleTestMethodTypeByte::testStaticFieldWrongMethodType, vhStaticField, VarHandleTestMethodTypeByte::testStaticFieldWrongMethodType,
false)); false));
cases.add(new VarHandleAccessTestCase("Array wrong method type", cases.add(new VarHandleAccessTestCase("Array",
vhArray, VarHandleTestMethodTypeByte::testArrayWrongMethodType, vhArray, VarHandleTestMethodTypeByte::testArrayWrongMethodType,
false)); false));
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", cases.add(new MethodHandleAccessTestCase("Instance field",
vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
false)); false));
cases.add(new MethodHandleAccessTestCase("Static field wrong method type", cases.add(new MethodHandleAccessTestCase("Static field",
vhStaticField, f, VarHandleTestMethodTypeByte::testStaticFieldWrongMethodType, vhStaticField, f, VarHandleTestMethodTypeByte::testStaticFieldWrongMethodType,
false)); false));
cases.add(new MethodHandleAccessTestCase("Array wrong method type", cases.add(new MethodHandleAccessTestCase("Array",
vhArray, f, VarHandleTestMethodTypeByte::testArrayWrongMethodType, vhArray, f, VarHandleTestMethodTypeByte::testArrayWrongMethodType,
false)); false));
} }
@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
byte x = (byte) hs.get(am, methodType(byte.class, Void.class)). byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class)).
invoke(null); invokeExact((VarHandleTestMethodTypeByte) null);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
byte x = (byte) hs.get(am, methodType(byte.class, Class.class)). byte x = (byte) hs.get(am, methodType(byte.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
byte x = (byte) hs.get(am, methodType(byte.class, int.class)). byte x = (byte) hs.get(am, methodType(byte.class, int.class)).
invoke(0); invokeExact(0);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class)). Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeByte.class)).
invoke(recv); invokeExact(recv);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class)).
invoke(recv); invokeExact(recv);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
byte x = (byte) hs.get(am, methodType(byte.class)). byte x = (byte) hs.get(am, methodType(byte.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)). byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, byte.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class)).
invoke(null, (byte)1); invokeExact((VarHandleTestMethodTypeByte) null, (byte)1);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, byte.class)). hs.get(am, methodType(void.class, Class.class, byte.class)).
invoke(Void.class, (byte)1); invokeExact(Void.class, (byte)1);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, byte.class)). hs.get(am, methodType(void.class, int.class, byte.class)).
invoke(0, (byte)1); invokeExact(0, (byte)1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)).
invoke(recv, (byte)1, Void.class); invokeExact(recv, (byte)1, Void.class);
}); });
} }
@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest {
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)). Void x = (Void) hs.get(am, methodType(Void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // > checkWMTE(() -> { // >
byte x = (byte) hs.get(am, methodType(Class.class)). byte x = (byte) hs.get(am, methodType(Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)). hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, byte.class, Class.class)). hs.get(am, methodType(void.class, byte.class, Class.class)).
invoke((byte)1, Void.class); invokeExact((byte)1, Void.class);
}); });
} }
@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
byte x = (byte) hs.get(am, methodType(byte.class, Void.class, int.class)). byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class)).
invoke(null, 0); invokeExact((byte[]) null, 0);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class)). byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class)).
invoke(Void.class, 0); invokeExact(Void.class, 0);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class)). byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class)).
invoke(0, 0); invokeExact(0, 0);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class)). byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class)).
invoke(array, Void.class); invokeExact(array, Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class, byte[].class, int.class)). Void x = (Void) hs.get(am, methodType(Void.class, byte[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
byte x = (byte) hs.get(am, methodType(byte.class)). byte x = (byte) hs.get(am, methodType(byte.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class)). byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, byte.class)). hs.get(am, methodType(void.class, byte[].class, int.class, byte.class)).
invoke(null, 0, (byte)1); invokeExact((byte[]) null, 0, (byte)1);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, byte.class)). hs.get(am, methodType(void.class, Class.class, int.class, byte.class)).
invoke(Void.class, 0, (byte)1); invokeExact(Void.class, 0, (byte)1);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)). hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, byte.class)). hs.get(am, methodType(void.class, int.class, int.class, byte.class)).
invoke(0, 0, (byte)1); invokeExact(0, 0, (byte)1);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, byte[].class, Class.class, byte.class)). hs.get(am, methodType(void.class, byte[].class, Class.class, byte.class)).
invoke(array, Void.class, (byte)1); invokeExact(array, Void.class, (byte)1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)). hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)).
invoke(array, 0, (byte)1, Void.class); invokeExact(array, 0, (byte)1, Void.class);
}); });
} }

View File

@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 8156486
* @run testng/othervm VarHandleTestMethodTypeChar * @run testng/othervm VarHandleTestMethodTypeChar
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeChar * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeChar
*/ */
@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest {
public Object[][] accessTestCaseProvider() throws Exception { public Object[][] accessTestCaseProvider() throws Exception {
List<AccessTestCase<?>> cases = new ArrayList<>(); List<AccessTestCase<?>> cases = new ArrayList<>();
cases.add(new VarHandleAccessTestCase("Instance field wrong method type", cases.add(new VarHandleAccessTestCase("Instance field",
vhField, vh -> testInstanceFieldWrongMethodType(this, vh), vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
false)); false));
cases.add(new VarHandleAccessTestCase("Static field wrong method type", cases.add(new VarHandleAccessTestCase("Static field",
vhStaticField, VarHandleTestMethodTypeChar::testStaticFieldWrongMethodType, vhStaticField, VarHandleTestMethodTypeChar::testStaticFieldWrongMethodType,
false)); false));
cases.add(new VarHandleAccessTestCase("Array wrong method type", cases.add(new VarHandleAccessTestCase("Array",
vhArray, VarHandleTestMethodTypeChar::testArrayWrongMethodType, vhArray, VarHandleTestMethodTypeChar::testArrayWrongMethodType,
false)); false));
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", cases.add(new MethodHandleAccessTestCase("Instance field",
vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
false)); false));
cases.add(new MethodHandleAccessTestCase("Static field wrong method type", cases.add(new MethodHandleAccessTestCase("Static field",
vhStaticField, f, VarHandleTestMethodTypeChar::testStaticFieldWrongMethodType, vhStaticField, f, VarHandleTestMethodTypeChar::testStaticFieldWrongMethodType,
false)); false));
cases.add(new MethodHandleAccessTestCase("Array wrong method type", cases.add(new MethodHandleAccessTestCase("Array",
vhArray, f, VarHandleTestMethodTypeChar::testArrayWrongMethodType, vhArray, f, VarHandleTestMethodTypeChar::testArrayWrongMethodType,
false)); false));
} }
@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
char x = (char) hs.get(am, methodType(char.class, Void.class)). char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class)).
invoke(null); invokeExact((VarHandleTestMethodTypeChar) null);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
char x = (char) hs.get(am, methodType(char.class, Class.class)). char x = (char) hs.get(am, methodType(char.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
char x = (char) hs.get(am, methodType(char.class, int.class)). char x = (char) hs.get(am, methodType(char.class, int.class)).
invoke(0); invokeExact(0);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class)). Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeChar.class)).
invoke(recv); invokeExact(recv);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class)).
invoke(recv); invokeExact(recv);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
char x = (char) hs.get(am, methodType(char.class)). char x = (char) hs.get(am, methodType(char.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, Class.class)). char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, char.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, char.class)).
invoke(null, 'a'); invokeExact((VarHandleTestMethodTypeChar) null, 'a');
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, char.class)). hs.get(am, methodType(void.class, Class.class, char.class)).
invoke(Void.class, 'a'); invokeExact(Void.class, 'a');
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, char.class)). hs.get(am, methodType(void.class, int.class, char.class)).
invoke(0, 'a'); invokeExact(0, 'a');
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, char.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, char.class, Class.class)).
invoke(recv, 'a', Void.class); invokeExact(recv, 'a', Void.class);
}); });
} }
@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest {
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)). Void x = (Void) hs.get(am, methodType(Void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // > checkWMTE(() -> { // >
char x = (char) hs.get(am, methodType(Class.class)). char x = (char) hs.get(am, methodType(Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)). hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, char.class, Class.class)). hs.get(am, methodType(void.class, char.class, Class.class)).
invoke('a', Void.class); invokeExact('a', Void.class);
}); });
} }
@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
char x = (char) hs.get(am, methodType(char.class, Void.class, int.class)). char x = (char) hs.get(am, methodType(char.class, char[].class, int.class)).
invoke(null, 0); invokeExact((char[]) null, 0);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
char x = (char) hs.get(am, methodType(char.class, Class.class, int.class)). char x = (char) hs.get(am, methodType(char.class, Class.class, int.class)).
invoke(Void.class, 0); invokeExact(Void.class, 0);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
char x = (char) hs.get(am, methodType(char.class, int.class, int.class)). char x = (char) hs.get(am, methodType(char.class, int.class, int.class)).
invoke(0, 0); invokeExact(0, 0);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
char x = (char) hs.get(am, methodType(char.class, char[].class, Class.class)). char x = (char) hs.get(am, methodType(char.class, char[].class, Class.class)).
invoke(array, Void.class); invokeExact(array, Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class, char[].class, int.class)). Void x = (Void) hs.get(am, methodType(Void.class, char[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
char x = (char) hs.get(am, methodType(char.class)). char x = (char) hs.get(am, methodType(char.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, Class.class)). char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, char.class)). hs.get(am, methodType(void.class, char[].class, int.class, char.class)).
invoke(null, 0, 'a'); invokeExact((char[]) null, 0, 'a');
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, char.class)). hs.get(am, methodType(void.class, Class.class, int.class, char.class)).
invoke(Void.class, 0, 'a'); invokeExact(Void.class, 0, 'a');
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, char[].class, int.class, Class.class)). hs.get(am, methodType(void.class, char[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, char.class)). hs.get(am, methodType(void.class, int.class, int.class, char.class)).
invoke(0, 0, 'a'); invokeExact(0, 0, 'a');
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, char[].class, Class.class, char.class)). hs.get(am, methodType(void.class, char[].class, Class.class, char.class)).
invoke(array, Void.class, 'a'); invokeExact(array, Void.class, 'a');
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, char[].class, int.class, Class.class)). hs.get(am, methodType(void.class, char[].class, int.class, Class.class)).
invoke(array, 0, 'a', Void.class); invokeExact(array, 0, 'a', Void.class);
}); });
} }

View File

@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 8156486
* @run testng/othervm VarHandleTestMethodTypeDouble * @run testng/othervm VarHandleTestMethodTypeDouble
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeDouble * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeDouble
*/ */
@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest {
public Object[][] accessTestCaseProvider() throws Exception { public Object[][] accessTestCaseProvider() throws Exception {
List<AccessTestCase<?>> cases = new ArrayList<>(); List<AccessTestCase<?>> cases = new ArrayList<>();
cases.add(new VarHandleAccessTestCase("Instance field wrong method type", cases.add(new VarHandleAccessTestCase("Instance field",
vhField, vh -> testInstanceFieldWrongMethodType(this, vh), vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
false)); false));
cases.add(new VarHandleAccessTestCase("Static field wrong method type", cases.add(new VarHandleAccessTestCase("Static field",
vhStaticField, VarHandleTestMethodTypeDouble::testStaticFieldWrongMethodType, vhStaticField, VarHandleTestMethodTypeDouble::testStaticFieldWrongMethodType,
false)); false));
cases.add(new VarHandleAccessTestCase("Array wrong method type", cases.add(new VarHandleAccessTestCase("Array",
vhArray, VarHandleTestMethodTypeDouble::testArrayWrongMethodType, vhArray, VarHandleTestMethodTypeDouble::testArrayWrongMethodType,
false)); false));
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", cases.add(new MethodHandleAccessTestCase("Instance field",
vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
false)); false));
cases.add(new MethodHandleAccessTestCase("Static field wrong method type", cases.add(new MethodHandleAccessTestCase("Static field",
vhStaticField, f, VarHandleTestMethodTypeDouble::testStaticFieldWrongMethodType, vhStaticField, f, VarHandleTestMethodTypeDouble::testStaticFieldWrongMethodType,
false)); false));
cases.add(new MethodHandleAccessTestCase("Array wrong method type", cases.add(new MethodHandleAccessTestCase("Array",
vhArray, f, VarHandleTestMethodTypeDouble::testArrayWrongMethodType, vhArray, f, VarHandleTestMethodTypeDouble::testArrayWrongMethodType,
false)); false));
} }
@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
double x = (double) hs.get(am, methodType(double.class, Void.class)). double x = (double) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class)).
invoke(null); invokeExact((VarHandleTestMethodTypeDouble) null);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
double x = (double) hs.get(am, methodType(double.class, Class.class)). double x = (double) hs.get(am, methodType(double.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
double x = (double) hs.get(am, methodType(double.class, int.class)). double x = (double) hs.get(am, methodType(double.class, int.class)).
invoke(0); invokeExact(0);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class)). Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeDouble.class)).
invoke(recv); invokeExact(recv);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeDouble.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeDouble.class)).
invoke(recv); invokeExact(recv);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
double x = (double) hs.get(am, methodType(double.class)). double x = (double) hs.get(am, methodType(double.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
double x = (double) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class, Class.class)). double x = (double) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, double.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, double.class)).
invoke(null, 1.0d); invokeExact((VarHandleTestMethodTypeDouble) null, 1.0d);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, double.class)). hs.get(am, methodType(void.class, Class.class, double.class)).
invoke(Void.class, 1.0d); invokeExact(Void.class, 1.0d);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, double.class)). hs.get(am, methodType(void.class, int.class, double.class)).
invoke(0, 1.0d); invokeExact(0, 1.0d);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, double.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, double.class, Class.class)).
invoke(recv, 1.0d, Void.class); invokeExact(recv, 1.0d, Void.class);
}); });
} }
@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest {
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)). Void x = (Void) hs.get(am, methodType(Void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // > checkWMTE(() -> { // >
double x = (double) hs.get(am, methodType(Class.class)). double x = (double) hs.get(am, methodType(Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)). hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, double.class, Class.class)). hs.get(am, methodType(void.class, double.class, Class.class)).
invoke(1.0d, Void.class); invokeExact(1.0d, Void.class);
}); });
} }
@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
double x = (double) hs.get(am, methodType(double.class, Void.class, int.class)). double x = (double) hs.get(am, methodType(double.class, double[].class, int.class)).
invoke(null, 0); invokeExact((double[]) null, 0);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
double x = (double) hs.get(am, methodType(double.class, Class.class, int.class)). double x = (double) hs.get(am, methodType(double.class, Class.class, int.class)).
invoke(Void.class, 0); invokeExact(Void.class, 0);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
double x = (double) hs.get(am, methodType(double.class, int.class, int.class)). double x = (double) hs.get(am, methodType(double.class, int.class, int.class)).
invoke(0, 0); invokeExact(0, 0);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
double x = (double) hs.get(am, methodType(double.class, double[].class, Class.class)). double x = (double) hs.get(am, methodType(double.class, double[].class, Class.class)).
invoke(array, Void.class); invokeExact(array, Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class, double[].class, int.class)). Void x = (Void) hs.get(am, methodType(Void.class, double[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, double[].class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, double[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
double x = (double) hs.get(am, methodType(double.class)). double x = (double) hs.get(am, methodType(double.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
double x = (double) hs.get(am, methodType(double.class, double[].class, int.class, Class.class)). double x = (double) hs.get(am, methodType(double.class, double[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, double.class)). hs.get(am, methodType(void.class, double[].class, int.class, double.class)).
invoke(null, 0, 1.0d); invokeExact((double[]) null, 0, 1.0d);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, double.class)). hs.get(am, methodType(void.class, Class.class, int.class, double.class)).
invoke(Void.class, 0, 1.0d); invokeExact(Void.class, 0, 1.0d);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, double[].class, int.class, Class.class)). hs.get(am, methodType(void.class, double[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, double.class)). hs.get(am, methodType(void.class, int.class, int.class, double.class)).
invoke(0, 0, 1.0d); invokeExact(0, 0, 1.0d);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, double[].class, Class.class, double.class)). hs.get(am, methodType(void.class, double[].class, Class.class, double.class)).
invoke(array, Void.class, 1.0d); invokeExact(array, Void.class, 1.0d);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, double[].class, int.class, Class.class)). hs.get(am, methodType(void.class, double[].class, int.class, Class.class)).
invoke(array, 0, 1.0d, Void.class); invokeExact(array, 0, 1.0d, Void.class);
}); });
} }

View File

@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 8156486
* @run testng/othervm VarHandleTestMethodTypeFloat * @run testng/othervm VarHandleTestMethodTypeFloat
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeFloat * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeFloat
*/ */
@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest {
public Object[][] accessTestCaseProvider() throws Exception { public Object[][] accessTestCaseProvider() throws Exception {
List<AccessTestCase<?>> cases = new ArrayList<>(); List<AccessTestCase<?>> cases = new ArrayList<>();
cases.add(new VarHandleAccessTestCase("Instance field wrong method type", cases.add(new VarHandleAccessTestCase("Instance field",
vhField, vh -> testInstanceFieldWrongMethodType(this, vh), vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
false)); false));
cases.add(new VarHandleAccessTestCase("Static field wrong method type", cases.add(new VarHandleAccessTestCase("Static field",
vhStaticField, VarHandleTestMethodTypeFloat::testStaticFieldWrongMethodType, vhStaticField, VarHandleTestMethodTypeFloat::testStaticFieldWrongMethodType,
false)); false));
cases.add(new VarHandleAccessTestCase("Array wrong method type", cases.add(new VarHandleAccessTestCase("Array",
vhArray, VarHandleTestMethodTypeFloat::testArrayWrongMethodType, vhArray, VarHandleTestMethodTypeFloat::testArrayWrongMethodType,
false)); false));
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", cases.add(new MethodHandleAccessTestCase("Instance field",
vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
false)); false));
cases.add(new MethodHandleAccessTestCase("Static field wrong method type", cases.add(new MethodHandleAccessTestCase("Static field",
vhStaticField, f, VarHandleTestMethodTypeFloat::testStaticFieldWrongMethodType, vhStaticField, f, VarHandleTestMethodTypeFloat::testStaticFieldWrongMethodType,
false)); false));
cases.add(new MethodHandleAccessTestCase("Array wrong method type", cases.add(new MethodHandleAccessTestCase("Array",
vhArray, f, VarHandleTestMethodTypeFloat::testArrayWrongMethodType, vhArray, f, VarHandleTestMethodTypeFloat::testArrayWrongMethodType,
false)); false));
} }
@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
float x = (float) hs.get(am, methodType(float.class, Void.class)). float x = (float) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class)).
invoke(null); invokeExact((VarHandleTestMethodTypeFloat) null);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
float x = (float) hs.get(am, methodType(float.class, Class.class)). float x = (float) hs.get(am, methodType(float.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
float x = (float) hs.get(am, methodType(float.class, int.class)). float x = (float) hs.get(am, methodType(float.class, int.class)).
invoke(0); invokeExact(0);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class)). Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeFloat.class)).
invoke(recv); invokeExact(recv);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeFloat.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeFloat.class)).
invoke(recv); invokeExact(recv);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
float x = (float) hs.get(am, methodType(float.class)). float x = (float) hs.get(am, methodType(float.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
float x = (float) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class, Class.class)). float x = (float) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, float.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, float.class)).
invoke(null, 1.0f); invokeExact((VarHandleTestMethodTypeFloat) null, 1.0f);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, float.class)). hs.get(am, methodType(void.class, Class.class, float.class)).
invoke(Void.class, 1.0f); invokeExact(Void.class, 1.0f);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, float.class)). hs.get(am, methodType(void.class, int.class, float.class)).
invoke(0, 1.0f); invokeExact(0, 1.0f);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, float.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, float.class, Class.class)).
invoke(recv, 1.0f, Void.class); invokeExact(recv, 1.0f, Void.class);
}); });
} }
@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest {
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)). Void x = (Void) hs.get(am, methodType(Void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // > checkWMTE(() -> { // >
float x = (float) hs.get(am, methodType(Class.class)). float x = (float) hs.get(am, methodType(Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)). hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, float.class, Class.class)). hs.get(am, methodType(void.class, float.class, Class.class)).
invoke(1.0f, Void.class); invokeExact(1.0f, Void.class);
}); });
} }
@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
float x = (float) hs.get(am, methodType(float.class, Void.class, int.class)). float x = (float) hs.get(am, methodType(float.class, float[].class, int.class)).
invoke(null, 0); invokeExact((float[]) null, 0);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
float x = (float) hs.get(am, methodType(float.class, Class.class, int.class)). float x = (float) hs.get(am, methodType(float.class, Class.class, int.class)).
invoke(Void.class, 0); invokeExact(Void.class, 0);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
float x = (float) hs.get(am, methodType(float.class, int.class, int.class)). float x = (float) hs.get(am, methodType(float.class, int.class, int.class)).
invoke(0, 0); invokeExact(0, 0);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
float x = (float) hs.get(am, methodType(float.class, float[].class, Class.class)). float x = (float) hs.get(am, methodType(float.class, float[].class, Class.class)).
invoke(array, Void.class); invokeExact(array, Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class, float[].class, int.class)). Void x = (Void) hs.get(am, methodType(Void.class, float[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, float[].class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, float[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
float x = (float) hs.get(am, methodType(float.class)). float x = (float) hs.get(am, methodType(float.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
float x = (float) hs.get(am, methodType(float.class, float[].class, int.class, Class.class)). float x = (float) hs.get(am, methodType(float.class, float[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, float.class)). hs.get(am, methodType(void.class, float[].class, int.class, float.class)).
invoke(null, 0, 1.0f); invokeExact((float[]) null, 0, 1.0f);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, float.class)). hs.get(am, methodType(void.class, Class.class, int.class, float.class)).
invoke(Void.class, 0, 1.0f); invokeExact(Void.class, 0, 1.0f);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, float[].class, int.class, Class.class)). hs.get(am, methodType(void.class, float[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, float.class)). hs.get(am, methodType(void.class, int.class, int.class, float.class)).
invoke(0, 0, 1.0f); invokeExact(0, 0, 1.0f);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, float[].class, Class.class, float.class)). hs.get(am, methodType(void.class, float[].class, Class.class, float.class)).
invoke(array, Void.class, 1.0f); invokeExact(array, Void.class, 1.0f);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, float[].class, int.class, Class.class)). hs.get(am, methodType(void.class, float[].class, int.class, Class.class)).
invoke(array, 0, 1.0f, Void.class); invokeExact(array, 0, 1.0f, Void.class);
}); });
} }

View File

@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 8156486
* @run testng/othervm VarHandleTestMethodTypeInt * @run testng/othervm VarHandleTestMethodTypeInt
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeInt * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeInt
*/ */
@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest {
public Object[][] accessTestCaseProvider() throws Exception { public Object[][] accessTestCaseProvider() throws Exception {
List<AccessTestCase<?>> cases = new ArrayList<>(); List<AccessTestCase<?>> cases = new ArrayList<>();
cases.add(new VarHandleAccessTestCase("Instance field wrong method type", cases.add(new VarHandleAccessTestCase("Instance field",
vhField, vh -> testInstanceFieldWrongMethodType(this, vh), vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
false)); false));
cases.add(new VarHandleAccessTestCase("Static field wrong method type", cases.add(new VarHandleAccessTestCase("Static field",
vhStaticField, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType, vhStaticField, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType,
false)); false));
cases.add(new VarHandleAccessTestCase("Array wrong method type", cases.add(new VarHandleAccessTestCase("Array",
vhArray, VarHandleTestMethodTypeInt::testArrayWrongMethodType, vhArray, VarHandleTestMethodTypeInt::testArrayWrongMethodType,
false)); false));
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", cases.add(new MethodHandleAccessTestCase("Instance field",
vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
false)); false));
cases.add(new MethodHandleAccessTestCase("Static field wrong method type", cases.add(new MethodHandleAccessTestCase("Static field",
vhStaticField, f, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType, vhStaticField, f, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType,
false)); false));
cases.add(new MethodHandleAccessTestCase("Array wrong method type", cases.add(new MethodHandleAccessTestCase("Array",
vhArray, f, VarHandleTestMethodTypeInt::testArrayWrongMethodType, vhArray, f, VarHandleTestMethodTypeInt::testArrayWrongMethodType,
false)); false));
} }
@ -644,211 +646,211 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, Void.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class)).
invoke(null); invokeExact((VarHandleTestMethodTypeInt) null);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
int x = (int) hs.get(am, methodType(int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
int x = (int) hs.get(am, methodType(int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int.class)).
invoke(0); invokeExact(0);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class)). Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class)).
invoke(recv); invokeExact(recv);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class)).
invoke(recv); invokeExact(recv);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, int.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class)).
invoke(null, 1); invokeExact((VarHandleTestMethodTypeInt) null, 1);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, int.class)). hs.get(am, methodType(void.class, Class.class, int.class)).
invoke(Void.class, 1); invokeExact(Void.class, 1);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class)). hs.get(am, methodType(void.class, int.class, int.class)).
invoke(0, 1); invokeExact(0, 1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
invoke(recv, 1, Void.class); invokeExact(recv, 1, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, int.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class)).
invoke(null, 1, 1); invokeExact((VarHandleTestMethodTypeInt) null, 1, 1);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class)).
invoke(Void.class, 1, 1); invokeExact(Void.class, 1, 1);
}); });
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)).
invoke(recv, Void.class, 1); invokeExact(recv, Void.class, 1);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
invoke(recv, 1, Void.class); invokeExact(recv, 1, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , int.class, int.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , int.class, int.class)).
invoke(0, 1, 1); invokeExact(0, 1, 1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)).
invoke(recv, 1, 1, Void.class); invokeExact(recv, 1, 1, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class)).
invoke(null, 1, 1); invokeExact((VarHandleTestMethodTypeInt) null, 1, 1);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
invoke(Void.class, 1, 1); invokeExact(Void.class, 1, 1);
}); });
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)).
invoke(recv, Void.class, 1); invokeExact(recv, Void.class, 1);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
invoke(recv, 1, Void.class); invokeExact(recv, 1, Void.class);
}); });
checkWMTE(() -> { // reciever primitive class checkWMTE(() -> { // reciever primitive class
int x = (int) hs.get(am, methodType(int.class, int.class , int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int.class , int.class, int.class)).
invoke(0, 1, 1); invokeExact(0, 1, 1);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class , int.class, int.class)). Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class , int.class, int.class)).
invoke(recv, 1, 1); invokeExact(recv, 1, 1);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class , int.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class , int.class, int.class)).
invoke(recv, 1, 1); invokeExact(recv, 1, 1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)).
invoke(recv, 1, 1, Void.class); invokeExact(recv, 1, 1, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
invoke(null, 1); invokeExact((VarHandleTestMethodTypeInt) null, 1);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)). int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
invoke(Void.class, 1); invokeExact(Void.class, 1);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // reciever primitive class checkWMTE(() -> { // reciever primitive class
int x = (int) hs.get(am, methodType(int.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
invoke(0, 1); invokeExact(0, 1);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)). Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)).
invoke(recv, 1); invokeExact(recv, 1);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)).
invoke(recv, 1); invokeExact(recv, 1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
invoke(recv, 1, Void.class); invokeExact(recv, 1, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
invoke(null, 1); invokeExact((VarHandleTestMethodTypeInt) null, 1);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)). int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
invoke(Void.class, 1); invokeExact(Void.class, 1);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // reciever primitive class checkWMTE(() -> { // reciever primitive class
int x = (int) hs.get(am, methodType(int.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
invoke(0, 1); invokeExact(0, 1);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)). Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)).
invoke(recv, 1); invokeExact(recv, 1);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)).
invoke(recv, 1); invokeExact(recv, 1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)). int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
invoke(recv, 1, Void.class); invokeExact(recv, 1, Void.class);
}); });
} }
} }
@ -1190,52 +1192,52 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest {
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)). Void x = (Void) hs.get(am, methodType(Void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(Class.class)). int x = (int) hs.get(am, methodType(Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)). hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, int.class, Class.class)). hs.get(am, methodType(void.class, int.class, Class.class)).
invoke(1, Void.class); invokeExact(1, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)).
invoke(Void.class, 1); invokeExact(Void.class, 1);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, Class.class)).
invoke(1, Void.class); invokeExact(1, Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, Class.class)).
invoke(1, 1, Void.class); invokeExact(1, 1, Void.class);
}); });
} }
@ -1243,29 +1245,29 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest {
// Incorrect argument types // Incorrect argument types
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)). int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
invoke(Void.class, 1); invokeExact(Void.class, 1);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
invoke(1, Void.class); invokeExact(1, Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int.class, int.class)). Void r = (Void) hs.get(am, methodType(Void.class, int.class, int.class)).
invoke(1, 1); invokeExact(1, 1);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)).
invoke(1, 1); invokeExact(1, 1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int.class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int.class, int.class, Class.class)).
invoke(1, 1, Void.class); invokeExact(1, 1, Void.class);
}); });
} }
@ -1273,25 +1275,25 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest {
// Incorrect argument types // Incorrect argument types
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int.class)). Void r = (Void) hs.get(am, methodType(Void.class, int.class)).
invoke(1); invokeExact(1);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
invoke(1); invokeExact(1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
invoke(1, Void.class); invokeExact(1, Void.class);
}); });
} }
@ -1299,25 +1301,25 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest {
// Incorrect argument types // Incorrect argument types
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int.class)). Void r = (Void) hs.get(am, methodType(Void.class, int.class)).
invoke(1); invokeExact(1);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
invoke(1); invokeExact(1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
invoke(1, Void.class); invokeExact(1, Void.class);
}); });
} }
} }
@ -1909,237 +1911,237 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class)).
invoke(null, 0); invokeExact((int[]) null, 0);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)). int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
invoke(Void.class, 0); invokeExact(Void.class, 0);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
int x = (int) hs.get(am, methodType(int.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
invoke(0, 0); invokeExact(0, 0);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class)).
invoke(array, Void.class); invokeExact(array, Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class, int[].class, int.class)). Void x = (Void) hs.get(am, methodType(Void.class, int[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, int.class)). hs.get(am, methodType(void.class, int[].class, int.class, int.class)).
invoke(null, 0, 1); invokeExact((int[]) null, 0, 1);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, int.class)). hs.get(am, methodType(void.class, Class.class, int.class, int.class)).
invoke(Void.class, 0, 1); invokeExact(Void.class, 0, 1);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, int[].class, int.class, Class.class)). hs.get(am, methodType(void.class, int[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, int.class)). hs.get(am, methodType(void.class, int.class, int.class, int.class)).
invoke(0, 0, 1); invokeExact(0, 0, 1);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, int[].class, Class.class, int.class)). hs.get(am, methodType(void.class, int[].class, Class.class, int.class)).
invoke(array, Void.class, 1); invokeExact(array, Void.class, 1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, int[].class, int.class, Class.class)). hs.get(am, methodType(void.class, int[].class, int.class, Class.class)).
invoke(array, 0, 1, Void.class); invokeExact(array, 0, 1, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, int.class, int.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)).
invoke(null, 0, 1, 1); invokeExact((int[]) null, 0, 1, 1);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class, int.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class, int.class)).
invoke(Void.class, 0, 1, 1); invokeExact(Void.class, 0, 1, 1);
}); });
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, Class.class, int.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, Class.class, int.class)).
invoke(array, 0, Void.class, 1); invokeExact(array, 0, Void.class, 1);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, Class.class)).
invoke(array, 0, 1, Void.class); invokeExact(array, 0, 1, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, int.class, int.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, int.class, int.class)).
invoke(0, 0, 1, 1); invokeExact(0, 0, 1, 1);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, Class.class, int.class, int.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, Class.class, int.class, int.class)).
invoke(array, Void.class, 1, 1); invokeExact(array, Void.class, 1, 1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class, Class.class)).
invoke(array, 0, 1, 1, Void.class); invokeExact(array, 0, 1, 1, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class)).
invoke(null, 0, 1, 1); invokeExact((int[]) null, 0, 1, 1);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class, int.class)).
invoke(Void.class, 0, 1, 1); invokeExact(Void.class, 0, 1, 1);
}); });
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class, int.class)).
invoke(array, 0, Void.class, 1); invokeExact(array, 0, Void.class, 1);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
invoke(array, 0, 1, Void.class); invokeExact(array, 0, 1, Void.class);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class, int.class)).
invoke(0, 0, 1, 1); invokeExact(0, 0, 1, 1);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class, int.class)).
invoke(array, Void.class, 1, 1); invokeExact(array, Void.class, 1, 1);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class, int.class)). Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class, int.class)).
invoke(array, 0, 1, 1); invokeExact(array, 0, 1, 1);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)).
invoke(array, 0, 1, 1); invokeExact(array, 0, 1, 1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class, Class.class)).
invoke(array, 0, 1, 1, Void.class); invokeExact(array, 0, 1, 1, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)).
invoke(null, 0, 1); invokeExact((int[]) null, 0, 1);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
invoke(Void.class, 0, 1); invokeExact(Void.class, 0, 1);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)).
invoke(0, 0, 1); invokeExact(0, 0, 1);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)).
invoke(array, Void.class, 1); invokeExact(array, Void.class, 1);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)). Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)).
invoke(array, 0, 1); invokeExact(array, 0, 1);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)).
invoke(array, 0, 1); invokeExact(array, 0, 1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
invoke(array, 0, 1, Void.class); invokeExact(array, 0, 1, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)).
invoke(null, 0, 1); invokeExact((int[]) null, 0, 1);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
invoke(Void.class, 0, 1); invokeExact(Void.class, 0, 1);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)).
invoke(0, 0, 1); invokeExact(0, 0, 1);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)).
invoke(array, Void.class, 1); invokeExact(array, Void.class, 1);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)). Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)).
invoke(array, 0, 1); invokeExact(array, 0, 1);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)).
invoke(array, 0, 1); invokeExact(array, 0, 1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
int x = (int) hs.get(am, methodType(int.class)). int x = (int) hs.get(am, methodType(int.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)). int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
invoke(array, 0, 1, Void.class); invokeExact(array, 0, 1, Void.class);
}); });
} }
} }

View File

@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 8156486
* @run testng/othervm VarHandleTestMethodTypeLong * @run testng/othervm VarHandleTestMethodTypeLong
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeLong * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeLong
*/ */
@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest {
public Object[][] accessTestCaseProvider() throws Exception { public Object[][] accessTestCaseProvider() throws Exception {
List<AccessTestCase<?>> cases = new ArrayList<>(); List<AccessTestCase<?>> cases = new ArrayList<>();
cases.add(new VarHandleAccessTestCase("Instance field wrong method type", cases.add(new VarHandleAccessTestCase("Instance field",
vhField, vh -> testInstanceFieldWrongMethodType(this, vh), vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
false)); false));
cases.add(new VarHandleAccessTestCase("Static field wrong method type", cases.add(new VarHandleAccessTestCase("Static field",
vhStaticField, VarHandleTestMethodTypeLong::testStaticFieldWrongMethodType, vhStaticField, VarHandleTestMethodTypeLong::testStaticFieldWrongMethodType,
false)); false));
cases.add(new VarHandleAccessTestCase("Array wrong method type", cases.add(new VarHandleAccessTestCase("Array",
vhArray, VarHandleTestMethodTypeLong::testArrayWrongMethodType, vhArray, VarHandleTestMethodTypeLong::testArrayWrongMethodType,
false)); false));
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", cases.add(new MethodHandleAccessTestCase("Instance field",
vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
false)); false));
cases.add(new MethodHandleAccessTestCase("Static field wrong method type", cases.add(new MethodHandleAccessTestCase("Static field",
vhStaticField, f, VarHandleTestMethodTypeLong::testStaticFieldWrongMethodType, vhStaticField, f, VarHandleTestMethodTypeLong::testStaticFieldWrongMethodType,
false)); false));
cases.add(new MethodHandleAccessTestCase("Array wrong method type", cases.add(new MethodHandleAccessTestCase("Array",
vhArray, f, VarHandleTestMethodTypeLong::testArrayWrongMethodType, vhArray, f, VarHandleTestMethodTypeLong::testArrayWrongMethodType,
false)); false));
} }
@ -644,211 +646,211 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, Void.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class)).
invoke(null); invokeExact((VarHandleTestMethodTypeLong) null);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
long x = (long) hs.get(am, methodType(long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
long x = (long) hs.get(am, methodType(long.class, int.class)). long x = (long) hs.get(am, methodType(long.class, int.class)).
invoke(0); invokeExact(0);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class)). Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class)).
invoke(recv); invokeExact(recv);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class)).
invoke(recv); invokeExact(recv);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
long x = (long) hs.get(am, methodType(long.class)). long x = (long) hs.get(am, methodType(long.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, long.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, long.class)).
invoke(null, 1L); invokeExact((VarHandleTestMethodTypeLong) null, 1L);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, long.class)). hs.get(am, methodType(void.class, Class.class, long.class)).
invoke(Void.class, 1L); invokeExact(Void.class, 1L);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, long.class)). hs.get(am, methodType(void.class, int.class, long.class)).
invoke(0, 1L); invokeExact(0, 1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
invoke(recv, 1L, Void.class); invokeExact(recv, 1L, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, long.class, long.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, long.class)).
invoke(null, 1L, 1L); invokeExact((VarHandleTestMethodTypeLong) null, 1L, 1L);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class, long.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class, long.class)).
invoke(Void.class, 1L, 1L); invokeExact(Void.class, 1L, 1L);
}); });
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)).
invoke(recv, Void.class, 1L); invokeExact(recv, Void.class, 1L);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
invoke(recv, 1L, Void.class); invokeExact(recv, 1L, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , long.class, long.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , long.class, long.class)).
invoke(0, 1L, 1L); invokeExact(0, 1L, 1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)).
invoke(recv, 1L, 1L, Void.class); invokeExact(recv, 1L, 1L, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, Void.class, long.class, long.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, long.class)).
invoke(null, 1L, 1L); invokeExact((VarHandleTestMethodTypeLong) null, 1L, 1L);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, long.class, long.class)). long x = (long) hs.get(am, methodType(long.class, Class.class, long.class, long.class)).
invoke(Void.class, 1L, 1L); invokeExact(Void.class, 1L, 1L);
}); });
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)).
invoke(recv, Void.class, 1L); invokeExact(recv, Void.class, 1L);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
invoke(recv, 1L, Void.class); invokeExact(recv, 1L, Void.class);
}); });
checkWMTE(() -> { // reciever primitive class checkWMTE(() -> { // reciever primitive class
long x = (long) hs.get(am, methodType(long.class, int.class , long.class, long.class)). long x = (long) hs.get(am, methodType(long.class, int.class , long.class, long.class)).
invoke(0, 1L, 1L); invokeExact(0, 1L, 1L);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class , long.class, long.class)). Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class , long.class, long.class)).
invoke(recv, 1L, 1L); invokeExact(recv, 1L, 1L);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class , long.class, long.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class , long.class, long.class)).
invoke(recv, 1L, 1L); invokeExact(recv, 1L, 1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
long x = (long) hs.get(am, methodType(long.class)). long x = (long) hs.get(am, methodType(long.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)).
invoke(recv, 1L, 1L, Void.class); invokeExact(recv, 1L, 1L, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, Void.class, long.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
invoke(null, 1L); invokeExact((VarHandleTestMethodTypeLong) null, 1L);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)). long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
invoke(Void.class, 1L); invokeExact(Void.class, 1L);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // reciever primitive class checkWMTE(() -> { // reciever primitive class
long x = (long) hs.get(am, methodType(long.class, int.class, long.class)). long x = (long) hs.get(am, methodType(long.class, int.class, long.class)).
invoke(0, 1L); invokeExact(0, 1L);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)). Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)).
invoke(recv, 1L); invokeExact(recv, 1L);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)).
invoke(recv, 1L); invokeExact(recv, 1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
long x = (long) hs.get(am, methodType(long.class)). long x = (long) hs.get(am, methodType(long.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
invoke(recv, 1L, Void.class); invokeExact(recv, 1L, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, Void.class, long.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
invoke(null, 1L); invokeExact((VarHandleTestMethodTypeLong) null, 1L);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)). long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
invoke(Void.class, 1L); invokeExact(Void.class, 1L);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // reciever primitive class checkWMTE(() -> { // reciever primitive class
long x = (long) hs.get(am, methodType(long.class, int.class, long.class)). long x = (long) hs.get(am, methodType(long.class, int.class, long.class)).
invoke(0, 1L); invokeExact(0, 1L);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)). Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)).
invoke(recv, 1L); invokeExact(recv, 1L);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)).
invoke(recv, 1L); invokeExact(recv, 1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
long x = (long) hs.get(am, methodType(long.class)). long x = (long) hs.get(am, methodType(long.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)). long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
invoke(recv, 1L, Void.class); invokeExact(recv, 1L, Void.class);
}); });
} }
} }
@ -1190,52 +1192,52 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest {
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)). Void x = (Void) hs.get(am, methodType(Void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(Class.class)). long x = (long) hs.get(am, methodType(Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)). hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, long.class, Class.class)). hs.get(am, methodType(void.class, long.class, Class.class)).
invoke(1L, Void.class); invokeExact(1L, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class)).
invoke(Void.class, 1L); invokeExact(Void.class, 1L);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, Class.class)).
invoke(1L, Void.class); invokeExact(1L, Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class, Class.class)).
invoke(1L, 1L, Void.class); invokeExact(1L, 1L, Void.class);
}); });
} }
@ -1243,29 +1245,29 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest {
// Incorrect argument types // Incorrect argument types
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)). long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
invoke(Void.class, 1L); invokeExact(Void.class, 1L);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
invoke(1L, Void.class); invokeExact(1L, Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long.class, long.class)). Void r = (Void) hs.get(am, methodType(Void.class, long.class, long.class)).
invoke(1L, 1L); invokeExact(1L, 1L);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class)).
invoke(1L, 1L); invokeExact(1L, 1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
long x = (long) hs.get(am, methodType(long.class)). long x = (long) hs.get(am, methodType(long.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long.class, long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long.class, long.class, Class.class)).
invoke(1L, 1L, Void.class); invokeExact(1L, 1L, Void.class);
}); });
} }
@ -1273,25 +1275,25 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest {
// Incorrect argument types // Incorrect argument types
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long.class)). Void r = (Void) hs.get(am, methodType(Void.class, long.class)).
invoke(1L); invokeExact(1L);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)).
invoke(1L); invokeExact(1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
long x = (long) hs.get(am, methodType(long.class)). long x = (long) hs.get(am, methodType(long.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
invoke(1L, Void.class); invokeExact(1L, Void.class);
}); });
} }
@ -1299,25 +1301,25 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest {
// Incorrect argument types // Incorrect argument types
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long.class)). Void r = (Void) hs.get(am, methodType(Void.class, long.class)).
invoke(1L); invokeExact(1L);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)).
invoke(1L); invokeExact(1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
long x = (long) hs.get(am, methodType(long.class)). long x = (long) hs.get(am, methodType(long.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
invoke(1L, Void.class); invokeExact(1L, Void.class);
}); });
} }
} }
@ -1909,237 +1911,237 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
long x = (long) hs.get(am, methodType(long.class, Void.class, int.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class)).
invoke(null, 0); invokeExact((long[]) null, 0);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, int.class)). long x = (long) hs.get(am, methodType(long.class, Class.class, int.class)).
invoke(Void.class, 0); invokeExact(Void.class, 0);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
long x = (long) hs.get(am, methodType(long.class, int.class, int.class)). long x = (long) hs.get(am, methodType(long.class, int.class, int.class)).
invoke(0, 0); invokeExact(0, 0);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class)).
invoke(array, Void.class); invokeExact(array, Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class, long[].class, int.class)). Void x = (Void) hs.get(am, methodType(Void.class, long[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
long x = (long) hs.get(am, methodType(long.class)). long x = (long) hs.get(am, methodType(long.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, long.class)). hs.get(am, methodType(void.class, long[].class, int.class, long.class)).
invoke(null, 0, 1L); invokeExact((long[]) null, 0, 1L);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, long.class)). hs.get(am, methodType(void.class, Class.class, int.class, long.class)).
invoke(Void.class, 0, 1L); invokeExact(Void.class, 0, 1L);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, long[].class, int.class, Class.class)). hs.get(am, methodType(void.class, long[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, long.class)). hs.get(am, methodType(void.class, int.class, int.class, long.class)).
invoke(0, 0, 1L); invokeExact(0, 0, 1L);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, long[].class, Class.class, long.class)). hs.get(am, methodType(void.class, long[].class, Class.class, long.class)).
invoke(array, Void.class, 1L); invokeExact(array, Void.class, 1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, long[].class, int.class, Class.class)). hs.get(am, methodType(void.class, long[].class, int.class, Class.class)).
invoke(array, 0, 1L, Void.class); invokeExact(array, 0, 1L, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, long.class, long.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class)).
invoke(null, 0, 1L, 1L); invokeExact((long[]) null, 0, 1L, 1L);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, long.class, long.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, long.class, long.class)).
invoke(Void.class, 0, 1L, 1L); invokeExact(Void.class, 0, 1L, 1L);
}); });
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, Class.class, long.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, Class.class, long.class)).
invoke(array, 0, Void.class, 1L); invokeExact(array, 0, Void.class, 1L);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, Class.class)).
invoke(array, 0, 1L, Void.class); invokeExact(array, 0, 1L, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, long.class, long.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, long.class, long.class)).
invoke(0, 0, 1L, 1L); invokeExact(0, 0, 1L, 1L);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, Class.class, long.class, long.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, Class.class, long.class, long.class)).
invoke(array, Void.class, 1L, 1L); invokeExact(array, Void.class, 1L, 1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class, Class.class)).
invoke(array, 0, 1L, 1L, Void.class); invokeExact(array, 0, 1L, 1L, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class, long.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, long.class)).
invoke(null, 0, 1L, 1L); invokeExact((long[]) null, 0, 1L, 1L);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class, long.class)). long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class, long.class)).
invoke(Void.class, 0, 1L, 1L); invokeExact(Void.class, 0, 1L, 1L);
}); });
checkWMTE(() -> { // expected reference class checkWMTE(() -> { // expected reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class, long.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class, long.class)).
invoke(array, 0, Void.class, 1L); invokeExact(array, 0, Void.class, 1L);
}); });
checkWMTE(() -> { // actual reference class checkWMTE(() -> { // actual reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
invoke(array, 0, 1L, Void.class); invokeExact(array, 0, 1L, Void.class);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class, long.class)). long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class, long.class)).
invoke(0, 0, 1L, 1L); invokeExact(0, 0, 1L, 1L);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class, long.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class, long.class)).
invoke(array, Void.class, 1L, 1L); invokeExact(array, Void.class, 1L, 1L);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class, long.class)). Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class, long.class)).
invoke(array, 0, 1L, 1L); invokeExact(array, 0, 1L, 1L);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class)).
invoke(array, 0, 1L, 1L); invokeExact(array, 0, 1L, 1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
long x = (long) hs.get(am, methodType(long.class)). long x = (long) hs.get(am, methodType(long.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, long.class, Class.class)).
invoke(array, 0, 1L, 1L, Void.class); invokeExact(array, 0, 1L, 1L, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)).
invoke(null, 0, 1L); invokeExact((long[]) null, 0, 1L);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)). long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)).
invoke(Void.class, 0, 1L); invokeExact(Void.class, 0, 1L);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)). long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)).
invoke(0, 0, 1L); invokeExact(0, 0, 1L);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)).
invoke(array, Void.class, 1L); invokeExact(array, Void.class, 1L);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)). Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)).
invoke(array, 0, 1L); invokeExact(array, 0, 1L);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)).
invoke(array, 0, 1L); invokeExact(array, 0, 1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
long x = (long) hs.get(am, methodType(long.class)). long x = (long) hs.get(am, methodType(long.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
invoke(array, 0, 1L, Void.class); invokeExact(array, 0, 1L, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)).
invoke(null, 0, 1L); invokeExact((long[]) null, 0, 1L);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)). long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)).
invoke(Void.class, 0, 1L); invokeExact(Void.class, 0, 1L);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)). long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)).
invoke(0, 0, 1L); invokeExact(0, 0, 1L);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)).
invoke(array, Void.class, 1L); invokeExact(array, Void.class, 1L);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)). Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)).
invoke(array, 0, 1L); invokeExact(array, 0, 1L);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)).
invoke(array, 0, 1L); invokeExact(array, 0, 1L);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
long x = (long) hs.get(am, methodType(long.class)). long x = (long) hs.get(am, methodType(long.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)). long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
invoke(array, 0, 1L, Void.class); invokeExact(array, 0, 1L, Void.class);
}); });
} }
} }

View File

@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 8156486
* @run testng/othervm VarHandleTestMethodTypeShort * @run testng/othervm VarHandleTestMethodTypeShort
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeShort * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeShort
*/ */
@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest {
public Object[][] accessTestCaseProvider() throws Exception { public Object[][] accessTestCaseProvider() throws Exception {
List<AccessTestCase<?>> cases = new ArrayList<>(); List<AccessTestCase<?>> cases = new ArrayList<>();
cases.add(new VarHandleAccessTestCase("Instance field wrong method type", cases.add(new VarHandleAccessTestCase("Instance field",
vhField, vh -> testInstanceFieldWrongMethodType(this, vh), vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
false)); false));
cases.add(new VarHandleAccessTestCase("Static field wrong method type", cases.add(new VarHandleAccessTestCase("Static field",
vhStaticField, VarHandleTestMethodTypeShort::testStaticFieldWrongMethodType, vhStaticField, VarHandleTestMethodTypeShort::testStaticFieldWrongMethodType,
false)); false));
cases.add(new VarHandleAccessTestCase("Array wrong method type", cases.add(new VarHandleAccessTestCase("Array",
vhArray, VarHandleTestMethodTypeShort::testArrayWrongMethodType, vhArray, VarHandleTestMethodTypeShort::testArrayWrongMethodType,
false)); false));
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", cases.add(new MethodHandleAccessTestCase("Instance field",
vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
false)); false));
cases.add(new MethodHandleAccessTestCase("Static field wrong method type", cases.add(new MethodHandleAccessTestCase("Static field",
vhStaticField, f, VarHandleTestMethodTypeShort::testStaticFieldWrongMethodType, vhStaticField, f, VarHandleTestMethodTypeShort::testStaticFieldWrongMethodType,
false)); false));
cases.add(new MethodHandleAccessTestCase("Array wrong method type", cases.add(new MethodHandleAccessTestCase("Array",
vhArray, f, VarHandleTestMethodTypeShort::testArrayWrongMethodType, vhArray, f, VarHandleTestMethodTypeShort::testArrayWrongMethodType,
false)); false));
} }
@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
short x = (short) hs.get(am, methodType(short.class, Void.class)). short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class)).
invoke(null); invokeExact((VarHandleTestMethodTypeShort) null);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
short x = (short) hs.get(am, methodType(short.class, Class.class)). short x = (short) hs.get(am, methodType(short.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
short x = (short) hs.get(am, methodType(short.class, int.class)). short x = (short) hs.get(am, methodType(short.class, int.class)).
invoke(0); invokeExact(0);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class)). Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeShort.class)).
invoke(recv); invokeExact(recv);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class)).
invoke(recv); invokeExact(recv);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
short x = (short) hs.get(am, methodType(short.class)). short x = (short) hs.get(am, methodType(short.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, Class.class)). short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, short.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, short.class)).
invoke(null, (short)1); invokeExact((VarHandleTestMethodTypeShort) null, (short)1);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, short.class)). hs.get(am, methodType(void.class, Class.class, short.class)).
invoke(Void.class, (short)1); invokeExact(Void.class, (short)1);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, short.class)). hs.get(am, methodType(void.class, int.class, short.class)).
invoke(0, (short)1); invokeExact(0, (short)1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, short.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, short.class, Class.class)).
invoke(recv, (short)1, Void.class); invokeExact(recv, (short)1, Void.class);
}); });
} }
@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest {
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)). Void x = (Void) hs.get(am, methodType(Void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // > checkWMTE(() -> { // >
short x = (short) hs.get(am, methodType(Class.class)). short x = (short) hs.get(am, methodType(Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)). hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, short.class, Class.class)). hs.get(am, methodType(void.class, short.class, Class.class)).
invoke((short)1, Void.class); invokeExact((short)1, Void.class);
}); });
} }
@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
short x = (short) hs.get(am, methodType(short.class, Void.class, int.class)). short x = (short) hs.get(am, methodType(short.class, short[].class, int.class)).
invoke(null, 0); invokeExact((short[]) null, 0);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
short x = (short) hs.get(am, methodType(short.class, Class.class, int.class)). short x = (short) hs.get(am, methodType(short.class, Class.class, int.class)).
invoke(Void.class, 0); invokeExact(Void.class, 0);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
short x = (short) hs.get(am, methodType(short.class, int.class, int.class)). short x = (short) hs.get(am, methodType(short.class, int.class, int.class)).
invoke(0, 0); invokeExact(0, 0);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
short x = (short) hs.get(am, methodType(short.class, short[].class, Class.class)). short x = (short) hs.get(am, methodType(short.class, short[].class, Class.class)).
invoke(array, Void.class); invokeExact(array, Void.class);
}); });
// Incorrect return type // Incorrect return type
checkWMTE(() -> { // reference class checkWMTE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class, short[].class, int.class)). Void x = (Void) hs.get(am, methodType(Void.class, short[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
short x = (short) hs.get(am, methodType(short.class)). short x = (short) hs.get(am, methodType(short.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, Class.class)). short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, short.class)). hs.get(am, methodType(void.class, short[].class, int.class, short.class)).
invoke(null, 0, (short)1); invokeExact((short[]) null, 0, (short)1);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, short.class)). hs.get(am, methodType(void.class, Class.class, int.class, short.class)).
invoke(Void.class, 0, (short)1); invokeExact(Void.class, 0, (short)1);
}); });
checkWMTE(() -> { // value reference class checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, short[].class, int.class, Class.class)). hs.get(am, methodType(void.class, short[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, short.class)). hs.get(am, methodType(void.class, int.class, int.class, short.class)).
invoke(0, 0, (short)1); invokeExact(0, 0, (short)1);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, short[].class, Class.class, short.class)). hs.get(am, methodType(void.class, short[].class, Class.class, short.class)).
invoke(array, Void.class, (short)1); invokeExact(array, Void.class, (short)1);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, short[].class, int.class, Class.class)). hs.get(am, methodType(void.class, short[].class, int.class, Class.class)).
invoke(array, 0, (short)1, Void.class); invokeExact(array, 0, (short)1, Void.class);
}); });
} }

View File

@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 8156486
* @run testng/othervm VarHandleTestMethodTypeString * @run testng/othervm VarHandleTestMethodTypeString
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeString * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeString
*/ */
@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest {
public Object[][] accessTestCaseProvider() throws Exception { public Object[][] accessTestCaseProvider() throws Exception {
List<AccessTestCase<?>> cases = new ArrayList<>(); List<AccessTestCase<?>> cases = new ArrayList<>();
cases.add(new VarHandleAccessTestCase("Instance field wrong method type", cases.add(new VarHandleAccessTestCase("Instance field",
vhField, vh -> testInstanceFieldWrongMethodType(this, vh), vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
false)); false));
cases.add(new VarHandleAccessTestCase("Static field wrong method type", cases.add(new VarHandleAccessTestCase("Static field",
vhStaticField, VarHandleTestMethodTypeString::testStaticFieldWrongMethodType, vhStaticField, VarHandleTestMethodTypeString::testStaticFieldWrongMethodType,
false)); false));
cases.add(new VarHandleAccessTestCase("Array wrong method type", cases.add(new VarHandleAccessTestCase("Array",
vhArray, VarHandleTestMethodTypeString::testArrayWrongMethodType, vhArray, VarHandleTestMethodTypeString::testArrayWrongMethodType,
false)); false));
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", cases.add(new MethodHandleAccessTestCase("Instance field",
vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
false)); false));
cases.add(new MethodHandleAccessTestCase("Static field wrong method type", cases.add(new MethodHandleAccessTestCase("Static field",
vhStaticField, f, VarHandleTestMethodTypeString::testStaticFieldWrongMethodType, vhStaticField, f, VarHandleTestMethodTypeString::testStaticFieldWrongMethodType,
false)); false));
cases.add(new MethodHandleAccessTestCase("Array wrong method type", cases.add(new MethodHandleAccessTestCase("Array",
vhArray, f, VarHandleTestMethodTypeString::testArrayWrongMethodType, vhArray, f, VarHandleTestMethodTypeString::testArrayWrongMethodType,
false)); false));
} }
@ -586,174 +588,174 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
String x = (String) hs.get(am, methodType(String.class, Void.class)). String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class)).
invoke(null); invokeExact((VarHandleTestMethodTypeString) null);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
String x = (String) hs.get(am, methodType(String.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
String x = (String) hs.get(am, methodType(String.class, int.class)). String x = (String) hs.get(am, methodType(String.class, int.class)).
invoke(0); invokeExact(0);
}); });
// Incorrect return type // Incorrect return type
checkCCE(() -> { // reference class hs.checkWMTEOrCCE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class)). Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class)).
invoke(recv); invokeExact(recv);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class)).
invoke(recv); invokeExact(recv);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
String x = (String) hs.get(am, methodType(String.class)). String x = (String) hs.get(am, methodType(String.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, String.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, String.class)).
invoke(null, "foo"); invokeExact((VarHandleTestMethodTypeString) null, "foo");
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, String.class)). hs.get(am, methodType(void.class, Class.class, String.class)).
invoke(Void.class, "foo"); invokeExact(Void.class, "foo");
}); });
checkCCE(() -> { // value reference class hs.checkWMTEOrCCE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, String.class)). hs.get(am, methodType(void.class, int.class, String.class)).
invoke(0, "foo"); invokeExact(0, "foo");
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, String.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, String.class, Class.class)).
invoke(recv, "foo", Void.class); invokeExact(recv, "foo", Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, String.class, String.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, String.class)).
invoke(null, "foo", "foo"); invokeExact((VarHandleTestMethodTypeString) null, "foo", "foo");
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, String.class, String.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, String.class, String.class)).
invoke(Void.class, "foo", "foo"); invokeExact(Void.class, "foo", "foo");
}); });
checkCCE(() -> { // expected reference class hs.checkWMTEOrCCE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, Class.class, String.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, Class.class, String.class)).
invoke(recv, Void.class, "foo"); invokeExact(recv, Void.class, "foo");
}); });
checkCCE(() -> { // actual reference class hs.checkWMTEOrCCE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, Class.class)).
invoke(recv, "foo", Void.class); invokeExact(recv, "foo", Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , String.class, String.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , String.class, String.class)).
invoke(0, "foo", "foo"); invokeExact(0, "foo", "foo");
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, String.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, String.class, Class.class)).
invoke(recv, "foo", "foo", Void.class); invokeExact(recv, "foo", "foo", Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
String x = (String) hs.get(am, methodType(String.class, Void.class, String.class, String.class)). String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, String.class)).
invoke(null, "foo", "foo"); invokeExact((VarHandleTestMethodTypeString) null, "foo", "foo");
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
String x = (String) hs.get(am, methodType(String.class, Class.class, String.class, String.class)). String x = (String) hs.get(am, methodType(String.class, Class.class, String.class, String.class)).
invoke(Void.class, "foo", "foo"); invokeExact(Void.class, "foo", "foo");
}); });
checkCCE(() -> { // expected reference class hs.checkWMTEOrCCE(() -> { // expected reference class
String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class, String.class)). String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class, String.class)).
invoke(recv, Void.class, "foo"); invokeExact(recv, Void.class, "foo");
}); });
checkCCE(() -> { // actual reference class hs.checkWMTEOrCCE(() -> { // actual reference class
String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, Class.class)).
invoke(recv, "foo", Void.class); invokeExact(recv, "foo", Void.class);
}); });
checkWMTE(() -> { // reciever primitive class checkWMTE(() -> { // reciever primitive class
String x = (String) hs.get(am, methodType(String.class, int.class , String.class, String.class)). String x = (String) hs.get(am, methodType(String.class, int.class , String.class, String.class)).
invoke(0, "foo", "foo"); invokeExact(0, "foo", "foo");
}); });
// Incorrect return type // Incorrect return type
checkCCE(() -> { // reference class hs.checkWMTEOrCCE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class , String.class, String.class)). Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class , String.class, String.class)).
invoke(recv, "foo", "foo"); invokeExact(recv, "foo", "foo");
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class , String.class, String.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class , String.class, String.class)).
invoke(recv, "foo", "foo"); invokeExact(recv, "foo", "foo");
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
String x = (String) hs.get(am, methodType(String.class)). String x = (String) hs.get(am, methodType(String.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, String.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, String.class, Class.class)).
invoke(recv, "foo", "foo", Void.class); invokeExact(recv, "foo", "foo", Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
String x = (String) hs.get(am, methodType(String.class, Void.class, String.class)). String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class)).
invoke(null, "foo"); invokeExact((VarHandleTestMethodTypeString) null, "foo");
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
String x = (String) hs.get(am, methodType(String.class, Class.class, String.class)). String x = (String) hs.get(am, methodType(String.class, Class.class, String.class)).
invoke(Void.class, "foo"); invokeExact(Void.class, "foo");
}); });
checkCCE(() -> { // value reference class hs.checkWMTEOrCCE(() -> { // value reference class
String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // reciever primitive class checkWMTE(() -> { // reciever primitive class
String x = (String) hs.get(am, methodType(String.class, int.class, String.class)). String x = (String) hs.get(am, methodType(String.class, int.class, String.class)).
invoke(0, "foo"); invokeExact(0, "foo");
}); });
// Incorrect return type // Incorrect return type
checkCCE(() -> { // reference class hs.checkWMTEOrCCE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class, String.class)). Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class, String.class)).
invoke(recv, "foo"); invokeExact(recv, "foo");
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class)).
invoke(recv, "foo"); invokeExact(recv, "foo");
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
String x = (String) hs.get(am, methodType(String.class)). String x = (String) hs.get(am, methodType(String.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class)). String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class)).
invoke(recv, "foo", Void.class); invokeExact(recv, "foo", Void.class);
}); });
} }
@ -1054,110 +1056,110 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type // Incorrect return type
checkCCE(() -> { // reference class hs.checkWMTEOrCCE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)). Void x = (Void) hs.get(am, methodType(Void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // > checkWMTE(() -> { // >
String x = (String) hs.get(am, methodType(Class.class)). String x = (String) hs.get(am, methodType(Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkCCE(() -> { // value reference class hs.checkWMTEOrCCE(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)). hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, String.class, Class.class)). hs.get(am, methodType(void.class, String.class, Class.class)).
invoke("foo", Void.class); invokeExact("foo", Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkCCE(() -> { // expected reference class hs.checkWMTEOrCCE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, String.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, String.class)).
invoke(Void.class, "foo"); invokeExact(Void.class, "foo");
}); });
checkCCE(() -> { // actual reference class hs.checkWMTEOrCCE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, String.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, String.class, Class.class)).
invoke("foo", Void.class); invokeExact("foo", Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, String.class, String.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, String.class, String.class, Class.class)).
invoke("foo", "foo", Void.class); invokeExact("foo", "foo", Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types // Incorrect argument types
checkCCE(() -> { // expected reference class hs.checkWMTEOrCCE(() -> { // expected reference class
String x = (String) hs.get(am, methodType(String.class, Class.class, String.class)). String x = (String) hs.get(am, methodType(String.class, Class.class, String.class)).
invoke(Void.class, "foo"); invokeExact(Void.class, "foo");
}); });
checkCCE(() -> { // actual reference class hs.checkWMTEOrCCE(() -> { // actual reference class
String x = (String) hs.get(am, methodType(String.class, String.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, String.class, Class.class)).
invoke("foo", Void.class); invokeExact("foo", Void.class);
}); });
// Incorrect return type // Incorrect return type
checkCCE(() -> { // reference class hs.checkWMTEOrCCE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, String.class, String.class)). Void r = (Void) hs.get(am, methodType(Void.class, String.class, String.class)).
invoke("foo", "foo"); invokeExact("foo", "foo");
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, String.class, String.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, String.class, String.class)).
invoke("foo", "foo"); invokeExact("foo", "foo");
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
String x = (String) hs.get(am, methodType(String.class)). String x = (String) hs.get(am, methodType(String.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
String x = (String) hs.get(am, methodType(String.class, String.class, String.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, String.class, String.class, Class.class)).
invoke("foo", "foo", Void.class); invokeExact("foo", "foo", Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkCCE(() -> { // value reference class hs.checkWMTEOrCCE(() -> { // value reference class
String x = (String) hs.get(am, methodType(String.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect return type // Incorrect return type
checkCCE(() -> { // reference class hs.checkWMTEOrCCE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, String.class)). Void r = (Void) hs.get(am, methodType(Void.class, String.class)).
invoke("foo"); invokeExact("foo");
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, String.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, String.class)).
invoke("foo"); invokeExact("foo");
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
String x = (String) hs.get(am, methodType(String.class)). String x = (String) hs.get(am, methodType(String.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
String x = (String) hs.get(am, methodType(String.class, String.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, String.class, Class.class)).
invoke("foo", Void.class); invokeExact("foo", Void.class);
}); });
} }
@ -1686,195 +1688,195 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
String x = (String) hs.get(am, methodType(String.class, Void.class, int.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, int.class)).
invoke(null, 0); invokeExact((String[]) null, 0);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
String x = (String) hs.get(am, methodType(String.class, Class.class, int.class)). String x = (String) hs.get(am, methodType(String.class, Class.class, int.class)).
invoke(Void.class, 0); invokeExact(Void.class, 0);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
String x = (String) hs.get(am, methodType(String.class, int.class, int.class)). String x = (String) hs.get(am, methodType(String.class, int.class, int.class)).
invoke(0, 0); invokeExact(0, 0);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class)).
invoke(array, Void.class); invokeExact(array, Void.class);
}); });
// Incorrect return type // Incorrect return type
checkCCE(() -> { // reference class hs.checkWMTEOrCCE(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class, String[].class, int.class)). Void x = (Void) hs.get(am, methodType(Void.class, String[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
String x = (String) hs.get(am, methodType(String.class)). String x = (String) hs.get(am, methodType(String.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, String.class)). hs.get(am, methodType(void.class, String[].class, int.class, String.class)).
invoke(null, 0, "foo"); invokeExact((String[]) null, 0, "foo");
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, String.class)). hs.get(am, methodType(void.class, Class.class, int.class, String.class)).
invoke(Void.class, 0, "foo"); invokeExact(Void.class, 0, "foo");
}); });
checkCCE(() -> { // value reference class hs.checkWMTEOrCCE(() -> { // value reference class
hs.get(am, methodType(void.class, String[].class, int.class, Class.class)). hs.get(am, methodType(void.class, String[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, String.class)). hs.get(am, methodType(void.class, int.class, int.class, String.class)).
invoke(0, 0, "foo"); invokeExact(0, 0, "foo");
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, String[].class, Class.class, String.class)). hs.get(am, methodType(void.class, String[].class, Class.class, String.class)).
invoke(array, Void.class, "foo"); invokeExact(array, Void.class, "foo");
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, String[].class, int.class, Class.class)). hs.get(am, methodType(void.class, String[].class, int.class, Class.class)).
invoke(array, 0, "foo", Void.class); invokeExact(array, 0, "foo", Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, String.class, String.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class)).
invoke(null, 0, "foo", "foo"); invokeExact((String[]) null, 0, "foo", "foo");
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, String.class, String.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, String.class, String.class)).
invoke(Void.class, 0, "foo", "foo"); invokeExact(Void.class, 0, "foo", "foo");
}); });
checkCCE(() -> { // expected reference class hs.checkWMTEOrCCE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, Class.class, String.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, Class.class, String.class)).
invoke(array, 0, Void.class, "foo"); invokeExact(array, 0, Void.class, "foo");
}); });
checkCCE(() -> { // actual reference class hs.checkWMTEOrCCE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, Class.class)).
invoke(array, 0, "foo", Void.class); invokeExact(array, 0, "foo", Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, String.class, String.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, String.class, String.class)).
invoke(0, 0, "foo", "foo"); invokeExact(0, 0, "foo", "foo");
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, Class.class, String.class, String.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, Class.class, String.class, String.class)).
invoke(array, Void.class, "foo", "foo"); invokeExact(array, Void.class, "foo", "foo");
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class, Class.class)).
invoke(array, 0, "foo", "foo", Void.class); invokeExact(array, 0, "foo", "foo", Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
String x = (String) hs.get(am, methodType(String.class, Void.class, int.class, String.class, String.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, String.class)).
invoke(null, 0, "foo", "foo"); invokeExact((String[]) null, 0, "foo", "foo");
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
String x = (String) hs.get(am, methodType(String.class, Class.class, int.class, String.class, String.class)). String x = (String) hs.get(am, methodType(String.class, Class.class, int.class, String.class, String.class)).
invoke(Void.class, 0, "foo", "foo"); invokeExact(Void.class, 0, "foo", "foo");
}); });
checkCCE(() -> { // expected reference class hs.checkWMTEOrCCE(() -> { // expected reference class
String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class, String.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class, String.class)).
invoke(array, 0, Void.class, "foo"); invokeExact(array, 0, Void.class, "foo");
}); });
checkCCE(() -> { // actual reference class hs.checkWMTEOrCCE(() -> { // actual reference class
String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, Class.class)).
invoke(array, 0, "foo", Void.class); invokeExact(array, 0, "foo", Void.class);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
String x = (String) hs.get(am, methodType(String.class, int.class, int.class, String.class, String.class)). String x = (String) hs.get(am, methodType(String.class, int.class, int.class, String.class, String.class)).
invoke(0, 0, "foo", "foo"); invokeExact(0, 0, "foo", "foo");
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class, String.class, String.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class, String.class, String.class)).
invoke(array, Void.class, "foo", "foo"); invokeExact(array, Void.class, "foo", "foo");
}); });
// Incorrect return type // Incorrect return type
checkCCE(() -> { // reference class hs.checkWMTEOrCCE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, String[].class, int.class, String.class, String.class)). Void r = (Void) hs.get(am, methodType(Void.class, String[].class, int.class, String.class, String.class)).
invoke(array, 0, "foo", "foo"); invokeExact(array, 0, "foo", "foo");
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class)).
invoke(array, 0, "foo", "foo"); invokeExact(array, 0, "foo", "foo");
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
String x = (String) hs.get(am, methodType(String.class)). String x = (String) hs.get(am, methodType(String.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, String.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, String.class, Class.class)).
invoke(array, 0, "foo", "foo", Void.class); invokeExact(array, 0, "foo", "foo", Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
String x = (String) hs.get(am, methodType(String.class, Void.class, int.class, String.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class)).
invoke(null, 0, "foo"); invokeExact((String[]) null, 0, "foo");
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
String x = (String) hs.get(am, methodType(String.class, Class.class, int.class, String.class)). String x = (String) hs.get(am, methodType(String.class, Class.class, int.class, String.class)).
invoke(Void.class, 0, "foo"); invokeExact(Void.class, 0, "foo");
}); });
checkCCE(() -> { // value reference class hs.checkWMTEOrCCE(() -> { // value reference class
String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
String x = (String) hs.get(am, methodType(String.class, int.class, int.class, String.class)). String x = (String) hs.get(am, methodType(String.class, int.class, int.class, String.class)).
invoke(0, 0, "foo"); invokeExact(0, 0, "foo");
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class, String.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class, String.class)).
invoke(array, Void.class, "foo"); invokeExact(array, Void.class, "foo");
}); });
// Incorrect return type // Incorrect return type
checkCCE(() -> { // reference class hs.checkWMTEOrCCE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, String[].class, int.class, String.class)). Void r = (Void) hs.get(am, methodType(Void.class, String[].class, int.class, String.class)).
invoke(array, 0, "foo"); invokeExact(array, 0, "foo");
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class)). boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class)).
invoke(array, 0, "foo"); invokeExact(array, 0, "foo");
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
String x = (String) hs.get(am, methodType(String.class)). String x = (String) hs.get(am, methodType(String.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, Class.class)). String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, Class.class)).
invoke(array, 0, "foo", Void.class); invokeExact(array, 0, "foo", Void.class);
}); });
} }

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccess$Type$ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccess$Type$
* @run testng/othervm -Diters=20000 VarHandleTestAccess$Type$ * @run testng/othervm -Diters=20000 VarHandleTestAccess$Type$
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccess$Type$ * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccess$Type$
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccess$Type$
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@ -309,6 +310,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest {
checkUOE(() -> { checkUOE(() -> {
boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$); boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$);
}); });
checkUOE(() -> {
$type$ r = ($type$) vh.getAndSet(recv, $value1$);
});
#end[CAS] #end[CAS]
#if[!AtomicAdd] #if[!AtomicAdd]
@ -399,6 +404,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest {
checkUOE(() -> { checkUOE(() -> {
boolean r = vh.weakCompareAndSetRelease($value1$, $value2$); boolean r = vh.weakCompareAndSetRelease($value1$, $value2$);
}); });
checkUOE(() -> {
$type$ r = ($type$) vh.getAndSet($value1$);
});
#end[CAS] #end[CAS]
#if[!AtomicAdd] #if[!AtomicAdd]
@ -586,6 +595,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest {
checkUOE(() -> { checkUOE(() -> {
boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$); boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$);
}); });
checkUOE(() -> {
$type$ r = ($type$) vh.getAndSet(recv, $value1$);
});
#end[CAS] #end[CAS]
#if[!AtomicAdd] #if[!AtomicAdd]
@ -773,6 +786,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest {
checkUOE(() -> { checkUOE(() -> {
boolean r = vh.weakCompareAndSetRelease($value1$, $value2$); boolean r = vh.weakCompareAndSetRelease($value1$, $value2$);
}); });
checkUOE(() -> {
$type$ r = ($type$) vh.getAndSet($value1$);
});
#end[CAS] #end[CAS]
#if[!AtomicAdd] #if[!AtomicAdd]
@ -967,6 +984,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest {
checkUOE(() -> { checkUOE(() -> {
boolean r = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$); boolean r = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$);
}); });
checkUOE(() -> {
$type$ r = ($type$) vh.getAndSet(array, i, $value1$);
});
#end[CAS] #end[CAS]
#if[!AtomicAdd] #if[!AtomicAdd]

View File

@ -27,6 +27,7 @@
* @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAs$Type$ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAs$Type$
* @run testng/othervm -Diters=20000 VarHandleTestByteArrayAs$Type$ * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAs$Type$
* @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAs$Type$ * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAs$Type$
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAs$Type$
*/ */
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
@ -311,10 +312,12 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest {
checkROBE(() -> { checkROBE(() -> {
$type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1);
}); });
#else[CAS]
checkUOE(() -> { checkUOE(() -> {
boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2); boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2);
}); });
#else[CAS]
checkUOE(() -> { checkUOE(() -> {
$type$ r = ($type$) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1); $type$ r = ($type$) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1);
}); });

View File

@ -24,6 +24,7 @@
/* /*
* @test * @test
* @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccess$Type$ * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccess$Type$
* @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccess$Type$
*/ */
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;

View File

@ -23,6 +23,7 @@
/* /*
* @test * @test
* @bug 8156486
* @run testng/othervm VarHandleTestMethodType$Type$ * @run testng/othervm VarHandleTestMethodType$Type$
* @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodType$Type$ * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodType$Type$
*/ */
@ -81,27 +82,28 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest {
public Object[][] accessTestCaseProvider() throws Exception { public Object[][] accessTestCaseProvider() throws Exception {
List<AccessTestCase<?>> cases = new ArrayList<>(); List<AccessTestCase<?>> cases = new ArrayList<>();
cases.add(new VarHandleAccessTestCase("Instance field wrong method type", cases.add(new VarHandleAccessTestCase("Instance field",
vhField, vh -> testInstanceFieldWrongMethodType(this, vh), vhField, vh -> testInstanceFieldWrongMethodType(this, vh),
false)); false));
cases.add(new VarHandleAccessTestCase("Static field wrong method type", cases.add(new VarHandleAccessTestCase("Static field",
vhStaticField, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType, vhStaticField, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType,
false)); false));
cases.add(new VarHandleAccessTestCase("Array wrong method type", cases.add(new VarHandleAccessTestCase("Array",
vhArray, VarHandleTestMethodType$Type$::testArrayWrongMethodType, vhArray, VarHandleTestMethodType$Type$::testArrayWrongMethodType,
false)); false));
for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) {
cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", cases.add(new MethodHandleAccessTestCase("Instance field",
vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs),
false)); false));
cases.add(new MethodHandleAccessTestCase("Static field wrong method type", cases.add(new MethodHandleAccessTestCase("Static field",
vhStaticField, f, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType, vhStaticField, f, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType,
false)); false));
cases.add(new MethodHandleAccessTestCase("Array wrong method type", cases.add(new MethodHandleAccessTestCase("Array",
vhArray, f, VarHandleTestMethodType$Type$::testArrayWrongMethodType, vhArray, f, VarHandleTestMethodType$Type$::testArrayWrongMethodType,
false)); false));
} }
@ -648,63 +650,63 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class)).
invoke(null); invokeExact((VarHandleTestMethodType$Type$) null);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class)).
invoke(0); invokeExact(0);
}); });
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
Void x = (Void) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class)). Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class)).
invoke(recv); invokeExact(recv);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class)).
invoke(recv); invokeExact(recv);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
$type$ x = ($type$) hs.get(am, methodType($type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, Void.class, $type$.class)). hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, $type$.class)).
invoke(null, $value1$); invokeExact((VarHandleTestMethodType$Type$) null, $value1$);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, $type$.class)). hs.get(am, methodType(void.class, Class.class, $type$.class)).
invoke(Void.class, $value1$); invokeExact(Void.class, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // value reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, $type$.class)). hs.get(am, methodType(void.class, int.class, $type$.class)).
invoke(0, $value1$); invokeExact(0, $value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)). hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)).
invoke(recv, $value1$, Void.class); invokeExact(recv, $value1$, Void.class);
}); });
} }
@ -712,111 +714,111 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, $type$.class, $type$.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class)).
invoke(null, $value1$, $value1$); invokeExact((VarHandleTestMethodType$Type$) null, $value1$, $value1$);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class, $type$.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class, $type$.class)).
invoke(Void.class, $value1$, $value1$); invokeExact(Void.class, $value1$, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // expected reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)).
invoke(recv, Void.class, $value1$); invokeExact(recv, Void.class, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // actual reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)).
invoke(recv, $value1$, Void.class); invokeExact(recv, $value1$, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , $type$.class, $type$.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , $type$.class, $type$.class)).
invoke(0, $value1$, $value1$); invokeExact(0, $value1$, $value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)).
invoke(recv, $value1$, $value1$, Void.class); invokeExact(recv, $value1$, $value1$, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class)).
invoke(null, $value1$, $value1$); invokeExact((VarHandleTestMethodType$Type$) null, $value1$, $value1$);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class, $type$.class)).
invoke(Void.class, $value1$, $value1$); invokeExact(Void.class, $value1$, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // expected reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)).
invoke(recv, Void.class, $value1$); invokeExact(recv, Void.class, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // actual reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)).
invoke(recv, $value1$, Void.class); invokeExact(recv, $value1$, Void.class);
}); });
checkWMTE(() -> { // reciever primitive class checkWMTE(() -> { // reciever primitive class
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class , $type$.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class , $type$.class, $type$.class)).
invoke(0, $value1$, $value1$); invokeExact(0, $value1$, $value1$);
}); });
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)). Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)).
invoke(recv, $value1$, $value1$); invokeExact(recv, $value1$, $value1$);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)).
invoke(recv, $value1$, $value1$); invokeExact(recv, $value1$, $value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
$type$ x = ($type$) hs.get(am, methodType($type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)).
invoke(recv, $value1$, $value1$, Void.class); invokeExact(recv, $value1$, $value1$, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
invoke(null, $value1$); invokeExact((VarHandleTestMethodType$Type$) null, $value1$);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)).
invoke(Void.class, $value1$); invokeExact(Void.class, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // value reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // reciever primitive class checkWMTE(() -> { // reciever primitive class
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)).
invoke(0, $value1$); invokeExact(0, $value1$);
}); });
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)). Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)).
invoke(recv, $value1$); invokeExact(recv, $value1$);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
invoke(recv, $value1$); invokeExact(recv, $value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
$type$ x = ($type$) hs.get(am, methodType($type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
invoke(recv, $value1$, Void.class); invokeExact(recv, $value1$, Void.class);
}); });
} }
#end[CAS] #end[CAS]
@ -824,38 +826,38 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest {
#if[AtomicAdd] #if[AtomicAdd]
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
invoke(null, $value1$); invokeExact((VarHandleTestMethodType$Type$) null, $value1$);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)).
invoke(Void.class, $value1$); invokeExact(Void.class, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // value reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)).
invoke(recv, Void.class); invokeExact(recv, Void.class);
}); });
checkWMTE(() -> { // reciever primitive class checkWMTE(() -> { // reciever primitive class
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)).
invoke(0, $value1$); invokeExact(0, $value1$);
}); });
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)). Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)).
invoke(recv, $value1$); invokeExact(recv, $value1$);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
invoke(recv, $value1$); invokeExact(recv, $value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
$type$ x = ($type$) hs.get(am, methodType($type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)).
invoke(recv, $value1$, Void.class); invokeExact(recv, $value1$, Void.class);
}); });
} }
#end[AtomicAdd] #end[AtomicAdd]
@ -1200,111 +1202,111 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class)). Void x = (Void) hs.get(am, methodType(Void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class)).
invoke(); invokeExact();
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType(Class.class)). $type$ x = ($type$) hs.get(am, methodType(Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
check{#if[String]?CCE:WMTE}(() -> { // value reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
hs.get(am, methodType(void.class, Class.class)). hs.get(am, methodType(void.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, $type$.class, Class.class)). hs.get(am, methodType(void.class, $type$.class, Class.class)).
invoke($value1$, Void.class); invokeExact($value1$, Void.class);
}); });
} }
#if[CAS] #if[CAS]
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
check{#if[String]?CCE:WMTE}(() -> { // expected reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class)).
invoke(Void.class, $value1$); invokeExact(Void.class, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // actual reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, Class.class)).
invoke($value1$, Void.class); invokeExact($value1$, Void.class);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, $type$.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, $type$.class, Class.class)).
invoke($value1$, $value1$, Void.class); invokeExact($value1$, $value1$, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types // Incorrect argument types
check{#if[String]?CCE:WMTE}(() -> { // expected reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)).
invoke(Void.class, $value1$); invokeExact(Void.class, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // actual reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)).
invoke($value1$, Void.class); invokeExact($value1$, Void.class);
}); });
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, $type$.class, $type$.class)). Void r = (Void) hs.get(am, methodType(Void.class, $type$.class, $type$.class)).
invoke($value1$, $value1$); invokeExact($value1$, $value1$);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class, $type$.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class, $type$.class)).
invoke($value1$, $value1$); invokeExact($value1$, $value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
$type$ x = ($type$) hs.get(am, methodType($type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, $type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, $type$.class, Class.class)).
invoke($value1$, $value1$, Void.class); invokeExact($value1$, $value1$, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types // Incorrect argument types
check{#if[String]?CCE:WMTE}(() -> { // value reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)). Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)).
invoke($value1$); invokeExact($value1$);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)).
invoke($value1$); invokeExact($value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
$type$ x = ($type$) hs.get(am, methodType($type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)).
invoke($value1$, Void.class); invokeExact($value1$, Void.class);
}); });
} }
#end[CAS] #end[CAS]
@ -1314,25 +1316,25 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest {
// Incorrect argument types // Incorrect argument types
check{#if[String]?CCE:WMTE}(() -> { // value reference class check{#if[String]?CCE:WMTE}(() -> { // value reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)).
invoke(Void.class); invokeExact(Void.class);
}); });
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class check{#if[String]?CCE:WMTE}(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)). Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)).
invoke($value1$); invokeExact($value1$);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)).
invoke($value1$); invokeExact($value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
$type$ x = ($type$) hs.get(am, methodType($type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)).
invoke($value1$, Void.class); invokeExact($value1$, Void.class);
}); });
} }
#end[AtomicAdd] #end[AtomicAdd]
@ -1929,196 +1931,196 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class)).
invoke(null, 0); invokeExact(($type$[]) null, 0);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class)).
invoke(Void.class, 0); invokeExact(Void.class, 0);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class)).
invoke(0, 0); invokeExact(0, 0);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class)).
invoke(array, Void.class); invokeExact(array, Void.class);
}); });
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
Void x = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class)). Void x = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class)).
invoke(array, 0); invokeExact(array, 0);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
$type$ x = ($type$) hs.get(am, methodType($type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
hs.get(am, methodType(void.class, Void.class, int.class, $type$.class)). hs.get(am, methodType(void.class, $type$[].class, int.class, $type$.class)).
invoke(null, 0, $value1$); invokeExact(($type$[]) null, 0, $value1$);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, $type$.class)). hs.get(am, methodType(void.class, Class.class, int.class, $type$.class)).
invoke(Void.class, 0, $value1$); invokeExact(Void.class, 0, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // value reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)). hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, $type$.class)). hs.get(am, methodType(void.class, int.class, int.class, $type$.class)).
invoke(0, 0, $value1$); invokeExact(0, 0, $value1$);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, $type$[].class, Class.class, $type$.class)). hs.get(am, methodType(void.class, $type$[].class, Class.class, $type$.class)).
invoke(array, Void.class, $value1$); invokeExact(array, Void.class, $value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
hs.get(am, methodType(void.class)). hs.get(am, methodType(void.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)). hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)).
invoke(array, 0, $value1$, Void.class); invokeExact(array, 0, $value1$, Void.class);
}); });
} }
#if[CAS] #if[CAS]
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, $type$.class, $type$.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, $type$.class)).
invoke(null, 0, $value1$, $value1$); invokeExact(($type$[]) null, 0, $value1$, $value1$);
}); });
checkCCE(() -> { // receiver reference class hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, $type$.class, $type$.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, $type$.class, $type$.class)).
invoke(Void.class, 0, $value1$, $value1$); invokeExact(Void.class, 0, $value1$, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // expected reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, Class.class, $type$.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, Class.class, $type$.class)).
invoke(array, 0, Void.class, $value1$); invokeExact(array, 0, Void.class, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // actual reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, Class.class)).
invoke(array, 0, $value1$, Void.class); invokeExact(array, 0, $value1$, Void.class);
}); });
checkWMTE(() -> { // receiver primitive class checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, $type$.class, $type$.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, $type$.class, $type$.class)).
invoke(0, 0, $value1$, $value1$); invokeExact(0, 0, $value1$, $value1$);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, Class.class, $type$.class, $type$.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, Class.class, $type$.class, $type$.class)).
invoke(array, Void.class, $value1$, $value1$); invokeExact(array, Void.class, $value1$, $value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
boolean r = (boolean) hs.get(am, methodType(boolean.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)). boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)).
invoke(array, 0, $value1$, $value1$, Void.class); invokeExact(array, 0, $value1$, $value1$, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null receiver checkNPE(() -> { // null receiver
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, $type$.class)).
invoke(null, 0, $value1$, $value1$); invokeExact(($type$[]) null, 0, $value1$, $value1$);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class, $type$.class)).
invoke(Void.class, 0, $value1$, $value1$); invokeExact(Void.class, 0, $value1$, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // expected reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class, $type$.class)).
invoke(array, 0, Void.class, $value1$); invokeExact(array, 0, Void.class, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // actual reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)).
invoke(array, 0, $value1$, Void.class); invokeExact(array, 0, $value1$, Void.class);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class, $type$.class)).
invoke(0, 0, $value1$, $value1$); invokeExact(0, 0, $value1$, $value1$);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class, $type$.class)).
invoke(array, Void.class, $value1$, $value1$); invokeExact(array, Void.class, $value1$, $value1$);
}); });
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class, $type$.class)). Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class, $type$.class)).
invoke(array, 0, $value1$, $value1$); invokeExact(array, 0, $value1$, $value1$);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class, $type$.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class, $type$.class)).
invoke(array, 0, $value1$, $value1$); invokeExact(array, 0, $value1$, $value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
$type$ x = ($type$) hs.get(am, methodType($type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)).
invoke(array, 0, $value1$, $value1$, Void.class); invokeExact(array, 0, $value1$, $value1$, Void.class);
}); });
} }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)).
invoke(null, 0, $value1$); invokeExact(($type$[]) null, 0, $value1$);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)).
invoke(Void.class, 0, $value1$); invokeExact(Void.class, 0, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // value reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)).
invoke(0, 0, $value1$); invokeExact(0, 0, $value1$);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)).
invoke(array, Void.class, $value1$); invokeExact(array, Void.class, $value1$);
}); });
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)). Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)).
invoke(array, 0, $value1$); invokeExact(array, 0, $value1$);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)).
invoke(array, 0, $value1$); invokeExact(array, 0, $value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
$type$ x = ($type$) hs.get(am, methodType($type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)).
invoke(array, 0, $value1$, Void.class); invokeExact(array, 0, $value1$, Void.class);
}); });
} }
#end[CAS] #end[CAS]
@ -2127,42 +2129,42 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest {
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
// Incorrect argument types // Incorrect argument types
checkNPE(() -> { // null array checkNPE(() -> { // null array
$type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)).
invoke(null, 0, $value1$); invokeExact(($type$[]) null, 0, $value1$);
}); });
checkCCE(() -> { // array reference class hs.checkWMTEOrCCE(() -> { // array reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)).
invoke(Void.class, 0, $value1$); invokeExact(Void.class, 0, $value1$);
}); });
check{#if[String]?CCE:WMTE}(() -> { // value reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)).
invoke(array, 0, Void.class); invokeExact(array, 0, Void.class);
}); });
checkWMTE(() -> { // array primitive class checkWMTE(() -> { // array primitive class
$type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)).
invoke(0, 0, $value1$); invokeExact(0, 0, $value1$);
}); });
checkWMTE(() -> { // index reference class checkWMTE(() -> { // index reference class
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)).
invoke(array, Void.class, $value1$); invokeExact(array, Void.class, $value1$);
}); });
// Incorrect return type // Incorrect return type
check{#if[String]?CCE:WMTE}(() -> { // reference class {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)). Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)).
invoke(array, 0, $value1$); invokeExact(array, 0, $value1$);
}); });
checkWMTE(() -> { // primitive class checkWMTE(() -> { // primitive class
$wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)). $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)).
invoke(array, 0, $value1$); invokeExact(array, 0, $value1$);
}); });
// Incorrect arity // Incorrect arity
checkWMTE(() -> { // 0 checkWMTE(() -> { // 0
$type$ x = ($type$) hs.get(am, methodType($type$.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class)).
invoke(); invokeExact();
}); });
checkWMTE(() -> { // > checkWMTE(() -> { // >
$type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)). $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)).
invoke(array, 0, $value1$, Void.class); invokeExact(array, 0, $value1$, Void.class);
}); });
} }
#end[AtomicAdd] #end[AtomicAdd]