--- old/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java 2016-05-31 12:16:49.498362733 +0300 +++ new/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java 2016-05-31 12:16:49.402363082 +0300 @@ -42,13 +42,13 @@ import static java.lang.invoke.MethodType.*; public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { - static final byte static_final_v = (byte)1; + static final byte static_final_v = (byte)0x01; - static byte static_v = (byte)1; + static byte static_v = (byte)0x01; - final byte final_v = (byte)1; + final byte final_v = (byte)0x01; - byte v = (byte)1; + byte v = (byte)0x01; VarHandle vhFinalField; @@ -152,23 +152,23 @@ // Set // Incorrect argument types checkNPE(() -> { // null receiver - vh.set(null, (byte)1); + vh.set(null, (byte)0x01); }); checkCCE(() -> { // receiver reference class - vh.set(Void.class, (byte)1); + vh.set(Void.class, (byte)0x01); }); checkWMTE(() -> { // value reference class vh.set(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class - vh.set(0, (byte)1); + vh.set(0, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 vh.set(); }); checkWMTE(() -> { // > - vh.set(recv, (byte)1, Void.class); + vh.set(recv, (byte)0x01, Void.class); }); @@ -202,23 +202,23 @@ // SetVolatile // Incorrect argument types checkNPE(() -> { // null receiver - vh.setVolatile(null, (byte)1); + vh.setVolatile(null, (byte)0x01); }); checkCCE(() -> { // receiver reference class - vh.setVolatile(Void.class, (byte)1); + vh.setVolatile(Void.class, (byte)0x01); }); checkWMTE(() -> { // value reference class vh.setVolatile(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class - vh.setVolatile(0, (byte)1); + vh.setVolatile(0, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 vh.setVolatile(); }); checkWMTE(() -> { // > - vh.setVolatile(recv, (byte)1, Void.class); + vh.setVolatile(recv, (byte)0x01, Void.class); }); @@ -252,23 +252,23 @@ // SetOpaque // Incorrect argument types checkNPE(() -> { // null receiver - vh.setOpaque(null, (byte)1); + vh.setOpaque(null, (byte)0x01); }); checkCCE(() -> { // receiver reference class - vh.setOpaque(Void.class, (byte)1); + vh.setOpaque(Void.class, (byte)0x01); }); checkWMTE(() -> { // value reference class vh.setOpaque(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class - vh.setOpaque(0, (byte)1); + vh.setOpaque(0, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 vh.setOpaque(); }); checkWMTE(() -> { // > - vh.setOpaque(recv, (byte)1, Void.class); + vh.setOpaque(recv, (byte)0x01, Void.class); }); @@ -302,52 +302,961 @@ // SetRelease // Incorrect argument types checkNPE(() -> { // null receiver - vh.setRelease(null, (byte)1); + vh.setRelease(null, (byte)0x01); }); checkCCE(() -> { // receiver reference class - vh.setRelease(Void.class, (byte)1); + vh.setRelease(Void.class, (byte)0x01); }); checkWMTE(() -> { // value reference class vh.setRelease(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class - vh.setRelease(0, (byte)1); + vh.setRelease(0, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 vh.setRelease(); }); checkWMTE(() -> { // > - vh.setRelease(recv, (byte)1, Void.class); + vh.setRelease(recv, (byte)0x01, Void.class); }); + // CompareAndSet + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.compareAndSet(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.compareAndSet(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.compareAndSet(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.compareAndSet(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.compareAndSet(0, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.compareAndSet(); + }); + checkWMTE(() -> { // > + boolean r = vh.compareAndSet(recv, (byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSet + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSet(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSet(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSet(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSet(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSet(0, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSet(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSet(recv, (byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetVolatile(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetVolatile(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetVolatile(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetVolatile(0, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetVolatile(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetVolatile(recv, (byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSetAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetAcquire(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetAcquire(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetAcquire(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetAcquire(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetAcquire(0, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetAcquire(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetAcquire(recv, (byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSetRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetRelease(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetRelease(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetRelease(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetRelease(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetRelease(0, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetRelease(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetRelease(recv, (byte)0x01, (byte)0x01, Void.class); + }); + + + // CompareAndExchangeVolatile + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.compareAndExchangeVolatile(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.compareAndExchangeVolatile(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + byte x = (byte) vh.compareAndExchangeVolatile(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + byte x = (byte) vh.compareAndExchangeVolatile(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.compareAndExchangeVolatile(0, (byte)0x01, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.compareAndExchangeVolatile(recv, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.compareAndExchangeVolatile(recv, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.compareAndExchangeVolatile(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.compareAndExchangeVolatile(recv, (byte)0x01, (byte)0x01, Void.class); + }); + + + // CompareAndExchangeVolatileAcquire + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.compareAndExchangeAcquire(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.compareAndExchangeAcquire(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + byte x = (byte) vh.compareAndExchangeAcquire(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + byte x = (byte) vh.compareAndExchangeAcquire(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.compareAndExchangeAcquire(0, (byte)0x01, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.compareAndExchangeAcquire(recv, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.compareAndExchangeAcquire(recv, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.compareAndExchangeAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.compareAndExchangeAcquire(recv, (byte)0x01, (byte)0x01, Void.class); + }); + + + // CompareAndExchangeRelease + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.compareAndExchangeRelease(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.compareAndExchangeRelease(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + byte x = (byte) vh.compareAndExchangeRelease(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + byte x = (byte) vh.compareAndExchangeRelease(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.compareAndExchangeRelease(0, (byte)0x01, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.compareAndExchangeRelease(recv, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.compareAndExchangeRelease(recv, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.compareAndExchangeRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.compareAndExchangeRelease(recv, (byte)0x01, (byte)0x01, Void.class); + }); + + + // GetAndSet + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndSet(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndSet(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSet(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndSet(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSet(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSet(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSet(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSet(recv, (byte)0x01, Void.class); + }); + + // GetAndAdd + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.getAndAdd(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.getAndAdd(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAdd(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.getAndAdd(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAdd(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAdd(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndAdd(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndAdd(recv, (byte)0x01, Void.class); + }); + + + // AddAndGet + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) vh.addAndGet(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) vh.addAndGet(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.addAndGet(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) vh.addAndGet(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.addAndGet(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.addAndGet(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.addAndGet(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.addAndGet(recv, (byte)0x01, Void.class); + }); + } + + static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeByte recv, Handles hs) throws Throwable { + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) hs.get(am, methodType(byte.class, Void.class)). + invoke(null); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class)). + invoke(Void.class); + }); + checkWMTE(() -> { // receiver primitive class + byte x = (byte) hs.get(am, methodType(byte.class, int.class)). + invoke(0); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void x = (Void) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class)). + invoke(recv); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class)). + invoke(recv); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invoke(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)). + invoke(recv, Void.class); + }); + } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { + // Incorrect argument types + checkNPE(() -> { // null receiver + hs.get(am, methodType(void.class, Void.class, byte.class)). + invoke(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + hs.get(am, methodType(void.class, Class.class, byte.class)). + invoke(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, Class.class)). + invoke(recv, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + hs.get(am, methodType(void.class, int.class, byte.class)). + invoke(0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + hs.get(am, methodType(void.class)). + invoke(); + }); + checkWMTE(() -> { // > + hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)). + invoke(recv, (byte)0x01, Void.class); + }); + } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, byte.class, byte.class)). + invoke(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, byte.class, byte.class)). + invoke(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class, Class.class, byte.class)). + invoke(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)). + invoke(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , byte.class, byte.class)). + invoke(0, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = (boolean) hs.get(am, methodType(boolean.class)). + invoke(); + }); + checkWMTE(() -> { // > + boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class, byte.class, byte.class, Class.class)). + invoke(recv, (byte)0x01, (byte)0x01, Void.class); + }); + } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { + checkNPE(() -> { // null receiver + byte x = (byte) hs.get(am, methodType(byte.class, Void.class, byte.class, byte.class)). + invoke(null, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class, byte.class, byte.class)). + invoke(Void.class, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class, byte.class)). + invoke(recv, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)). + invoke(recv, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) hs.get(am, methodType(byte.class, int.class , byte.class, byte.class)). + invoke(0, (byte)0x01, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeByte.class , byte.class, byte.class)). + invoke(recv, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class , byte.class, byte.class)). + invoke(recv, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invoke(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class, byte.class, Class.class)). + invoke(recv, (byte)0x01, (byte)0x01, Void.class); + }); + } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { + checkNPE(() -> { // null receiver + byte x = (byte) hs.get(am, methodType(byte.class, Void.class, byte.class)). + invoke(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class, byte.class)). + invoke(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)). + invoke(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) hs.get(am, methodType(byte.class, int.class, byte.class)). + invoke(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeByte.class, byte.class)). + invoke(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class, byte.class)). + invoke(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invoke(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class)). + invoke(recv, (byte)0x01, Void.class); + }); + } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { + checkNPE(() -> { // null receiver + byte x = (byte) hs.get(am, methodType(byte.class, Void.class, byte.class)). + invoke(null, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class, byte.class)). + invoke(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)). + invoke(recv, Void.class); + }); + checkWMTE(() -> { // reciever primitive class + byte x = (byte) hs.get(am, methodType(byte.class, int.class, byte.class)). + invoke(0, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeByte.class, byte.class)). + invoke(recv, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class, byte.class)). + invoke(recv, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invoke(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class)). + invoke(recv, (byte)0x01, Void.class); + }); + } + } + + + static void testStaticFieldWrongMethodType(VarHandle vh) throws Throwable { + // Get + // Incorrect return type + checkWMTE(() -> { // reference class + Void x = (Void) vh.get(); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.get(); + }); + // Incorrect arity + checkWMTE(() -> { // > + byte x = (byte) vh.get(Void.class); + }); + + + // Set + // Incorrect argument types + checkWMTE(() -> { // value reference class + vh.set(Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + vh.set(); + }); + checkWMTE(() -> { // > + vh.set((byte)0x01, Void.class); + }); + + + // GetVolatile + // Incorrect return type + checkWMTE(() -> { // reference class + Void x = (Void) vh.getVolatile(); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getVolatile(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getVolatile(Void.class); + }); + + + // SetVolatile + // Incorrect argument types + checkWMTE(() -> { // value reference class + vh.setVolatile(Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + vh.setVolatile(); + }); + checkWMTE(() -> { // > + vh.setVolatile((byte)0x01, Void.class); + }); + + + // GetOpaque + // Incorrect return type + checkWMTE(() -> { // reference class + Void x = (Void) vh.getOpaque(); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getOpaque(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getOpaque(Void.class); + }); + + + // SetOpaque + // Incorrect argument types + checkWMTE(() -> { // value reference class + vh.setOpaque(Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + vh.setOpaque(); + }); + checkWMTE(() -> { // > + vh.setOpaque((byte)0x01, Void.class); + }); + + + // GetAcquire + // Incorrect return type + checkWMTE(() -> { // reference class + Void x = (Void) vh.getAcquire(); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAcquire(Void.class); + }); + + + // SetRelease + // Incorrect argument types + checkWMTE(() -> { // value reference class + vh.setRelease(Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + vh.setRelease(); + }); + checkWMTE(() -> { // > + vh.setRelease((byte)0x01, Void.class); + }); + + + // CompareAndSet + // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.compareAndSet(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.compareAndSet((byte)0x01, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.compareAndSet(); + }); + checkWMTE(() -> { // > + boolean r = vh.compareAndSet((byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSet + // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSet(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSet((byte)0x01, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSet(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSet((byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSetVolatile + // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetVolatile(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetVolatile((byte)0x01, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetVolatile(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetVolatile((byte)0x01, (byte)0x01, Void.class); + }); + + // WeakCompareAndSetAcquire + // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetAcquire(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetAcquire((byte)0x01, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetAcquire(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetAcquire((byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSetRelease + // Incorrect argument types + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetRelease(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetRelease((byte)0x01, Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSetRelease(); + }); + checkWMTE(() -> { // > + boolean r = vh.weakCompareAndSetRelease((byte)0x01, (byte)0x01, Void.class); + }); + + + // CompareAndExchangeVolatile + // Incorrect argument types + checkWMTE(() -> { // expected reference class + byte x = (byte) vh.compareAndExchangeVolatile(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + byte x = (byte) vh.compareAndExchangeVolatile((byte)0x01, Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.compareAndExchangeVolatile((byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.compareAndExchangeVolatile((byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.compareAndExchangeVolatile(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.compareAndExchangeVolatile((byte)0x01, (byte)0x01, Void.class); + }); + + + // CompareAndExchangeAcquire + // Incorrect argument types + checkWMTE(() -> { // expected reference class + byte x = (byte) vh.compareAndExchangeAcquire(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + byte x = (byte) vh.compareAndExchangeAcquire((byte)0x01, Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.compareAndExchangeAcquire((byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.compareAndExchangeAcquire((byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.compareAndExchangeAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.compareAndExchangeAcquire((byte)0x01, (byte)0x01, Void.class); + }); + + + // CompareAndExchangeRelease + // Incorrect argument types + checkWMTE(() -> { // expected reference class + byte x = (byte) vh.compareAndExchangeRelease(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + byte x = (byte) vh.compareAndExchangeRelease((byte)0x01, Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.compareAndExchangeRelease((byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.compareAndExchangeRelease((byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.compareAndExchangeRelease(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.compareAndExchangeRelease((byte)0x01, (byte)0x01, Void.class); + }); + + + // GetAndSet + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndSet(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSet((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSet((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndSet(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndSet((byte)0x01, Void.class); + }); + + // GetAndAdd + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAdd(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndAdd((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndAdd((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAndAdd(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAndAdd((byte)0x01, Void.class); + }); + + + // AddAndGet + // Incorrect argument types + checkWMTE(() -> { // value reference class + byte x = (byte) vh.addAndGet(Void.class); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.addAndGet((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.addAndGet((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.addAndGet(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.addAndGet((byte)0x01, Void.class); + }); } - static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeByte recv, Handles hs) throws Throwable { - for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { + static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { + int i = 0; + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { + // Incorrect return type + checkWMTE(() -> { // reference class + Void x = (Void) hs.get(am, methodType(Void.class)). + invoke(); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class)). + invoke(); + }); + // Incorrect arity + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(Class.class)). + invoke(Void.class); + }); + } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { + checkWMTE(() -> { // value reference class + hs.get(am, methodType(void.class, Class.class)). + invoke(Void.class); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + hs.get(am, methodType(void.class)). + invoke(); + }); + checkWMTE(() -> { // > + hs.get(am, methodType(void.class, byte.class, Class.class)). + invoke((byte)0x01, Void.class); + }); + } + for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types - checkNPE(() -> { // null receiver - byte x = (byte) hs.get(am, methodType(byte.class, Void.class)). - invoke(null); + checkWMTE(() -> { // expected reference class + boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, byte.class)). + invoke(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = (boolean) hs.get(am, methodType(boolean.class, byte.class, Class.class)). + invoke((byte)0x01, Void.class); }); - checkCCE(() -> { // receiver reference class - byte x = (byte) hs.get(am, methodType(byte.class, Class.class)). - invoke(Void.class); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = (boolean) hs.get(am, methodType(boolean.class)). + invoke(); }); - checkWMTE(() -> { // receiver primitive class - byte x = (byte) hs.get(am, methodType(byte.class, int.class)). - invoke(0); + checkWMTE(() -> { // > + boolean r = (boolean) hs.get(am, methodType(boolean.class, byte.class, byte.class, Class.class)). + invoke((byte)0x01, (byte)0x01, Void.class); + }); + } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { + // Incorrect argument types + checkWMTE(() -> { // expected reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class, byte.class)). + invoke(Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte.class, Class.class)). + invoke((byte)0x01, Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class)). - invoke(recv); + Void r = (Void) hs.get(am, methodType(Void.class, byte.class, byte.class)). + invoke((byte)0x01, (byte)0x01); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class)). - invoke(recv); + boolean x = (boolean) hs.get(am, methodType(boolean.class, byte.class, byte.class)). + invoke((byte)0x01, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 @@ -355,430 +1264,647 @@ invoke(); }); checkWMTE(() -> { // > - byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)). - invoke(recv, Void.class); + byte x = (byte) hs.get(am, methodType(byte.class, byte.class, byte.class, Class.class)). + invoke((byte)0x01, (byte)0x01, Void.class); }); } - for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { // Incorrect argument types - checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, Void.class, byte.class)). - invoke(null, (byte)1); + checkWMTE(() -> { // value reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class)). + invoke(Void.class); }); - checkCCE(() -> { // receiver reference class - hs.get(am, methodType(void.class, Class.class, byte.class)). - invoke(Void.class, (byte)1); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, byte.class)). + invoke((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, byte.class)). + invoke((byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invoke(); }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, byte.class, Class.class)). + invoke((byte)0x01, Void.class); + }); + } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { + // Incorrect argument types checkWMTE(() -> { // value reference class - hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, Class.class)). - invoke(recv, Void.class); + byte x = (byte) hs.get(am, methodType(byte.class, Class.class)). + invoke(Void.class); }); - checkWMTE(() -> { // receiver primitive class - hs.get(am, methodType(void.class, int.class, byte.class)). - invoke(0, (byte)1); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, byte.class)). + invoke((byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, byte.class)). + invoke((byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - hs.get(am, methodType(void.class)). + byte x = (byte) hs.get(am, methodType(byte.class)). invoke(); }); checkWMTE(() -> { // > - hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)). - invoke(recv, (byte)1, Void.class); + byte x = (byte) hs.get(am, methodType(byte.class, byte.class, Class.class)). + invoke((byte)0x01, Void.class); }); } - - } - static void testStaticFieldWrongMethodType(VarHandle vh) throws Throwable { + static void testArrayWrongMethodType(VarHandle vh) throws Throwable { + byte[] array = new byte[10]; + Arrays.fill(array, (byte)0x01); + // Get + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.get(null, 0); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.get(Void.class, 0); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.get(0, 0); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.get(array, Void.class); + }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) vh.get(); + Void x = (Void) vh.get(array, 0); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.get(); + boolean x = (boolean) vh.get(array, 0); }); // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.get(); + }); checkWMTE(() -> { // > - byte x = (byte) vh.get(Void.class); + byte x = (byte) vh.get(array, 0, Void.class); }); // Set // Incorrect argument types + checkNPE(() -> { // null array + vh.set(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + vh.set(Void.class, 0, (byte)0x01); + }); checkWMTE(() -> { // value reference class - vh.set(Void.class); + vh.set(array, 0, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + vh.set(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + vh.set(array, Void.class, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 vh.set(); }); checkWMTE(() -> { // > - vh.set((byte)1, Void.class); + vh.set(array, 0, (byte)0x01, Void.class); }); // GetVolatile + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getVolatile(null, 0); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getVolatile(Void.class, 0); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getVolatile(0, 0); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getVolatile(array, Void.class); + }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) vh.getVolatile(); + Void x = (Void) vh.getVolatile(array, 0); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.getVolatile(); + boolean x = (boolean) vh.getVolatile(array, 0); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getVolatile(); }); checkWMTE(() -> { // > - byte x = (byte) vh.getVolatile(Void.class); + byte x = (byte) vh.getVolatile(array, 0, Void.class); }); // SetVolatile // Incorrect argument types + checkNPE(() -> { // null array + vh.setVolatile(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + vh.setVolatile(Void.class, 0, (byte)0x01); + }); checkWMTE(() -> { // value reference class - vh.setVolatile(Void.class); + vh.setVolatile(array, 0, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + vh.setVolatile(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + vh.setVolatile(array, Void.class, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 vh.setVolatile(); }); checkWMTE(() -> { // > - vh.setVolatile((byte)1, Void.class); + vh.setVolatile(array, 0, (byte)0x01, Void.class); }); // GetOpaque + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getOpaque(null, 0); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getOpaque(Void.class, 0); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getOpaque(0, 0); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getOpaque(array, Void.class); + }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) vh.getOpaque(); + Void x = (Void) vh.getOpaque(array, 0); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.getOpaque(); + boolean x = (boolean) vh.getOpaque(array, 0); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getOpaque(); }); checkWMTE(() -> { // > - byte x = (byte) vh.getOpaque(Void.class); + byte x = (byte) vh.getOpaque(array, 0, Void.class); }); // SetOpaque // Incorrect argument types + checkNPE(() -> { // null array + vh.setOpaque(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + vh.setOpaque(Void.class, 0, (byte)0x01); + }); checkWMTE(() -> { // value reference class - vh.setOpaque(Void.class); + vh.setOpaque(array, 0, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + vh.setOpaque(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + vh.setOpaque(array, Void.class, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 vh.setOpaque(); }); checkWMTE(() -> { // > - vh.setOpaque((byte)1, Void.class); + vh.setOpaque(array, 0, (byte)0x01, Void.class); }); // GetAcquire + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) vh.getAcquire(null, 0); + }); + checkCCE(() -> { // array reference class + byte x = (byte) vh.getAcquire(Void.class, 0); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.getAcquire(0, 0); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) vh.getAcquire(array, Void.class); + }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) vh.getAcquire(); + Void x = (Void) vh.getAcquire(array, 0); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.getAcquire(); + boolean x = (boolean) vh.getAcquire(array, 0); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) vh.getAcquire(); + }); + checkWMTE(() -> { // > + byte x = (byte) vh.getAcquire(array, 0, Void.class); + }); + + + // SetRelease + // Incorrect argument types + checkNPE(() -> { // null array + vh.setRelease(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + vh.setRelease(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + vh.setRelease(array, 0, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + vh.setRelease(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + vh.setRelease(array, Void.class, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + vh.setRelease(); + }); + checkWMTE(() -> { // > + vh.setRelease(array, 0, (byte)0x01, Void.class); + }); + + + // CompareAndSet + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.compareAndSet(null, 0, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.compareAndSet(Void.class, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.compareAndSet(array, 0, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.compareAndSet(array, 0, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.compareAndSet(0, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.compareAndSet(array, Void.class, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.compareAndSet(); + }); + checkWMTE(() -> { // > + boolean r = vh.compareAndSet(array, 0, (byte)0x01, (byte)0x01, Void.class); + }); + + + // WeakCompareAndSet + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSet(null, 0, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSet(Void.class, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSet(array, 0, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSet(array, 0, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSet(0, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSet(array, Void.class, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = vh.weakCompareAndSet(); }); checkWMTE(() -> { // > - byte x = (byte) vh.getAcquire(Void.class); + boolean r = vh.weakCompareAndSet(array, 0, (byte)0x01, (byte)0x01, Void.class); }); - // SetRelease + // WeakCompareAndSetVolatile // Incorrect argument types - checkWMTE(() -> { // value reference class - vh.setRelease(Void.class); + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetVolatile(null, 0, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetVolatile(array, 0, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetVolatile(0, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetVolatile(array, Void.class, (byte)0x01, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - vh.setRelease(); + boolean r = vh.weakCompareAndSetVolatile(); }); checkWMTE(() -> { // > - vh.setRelease((byte)1, Void.class); + boolean r = vh.weakCompareAndSetVolatile(array, 0, (byte)0x01, (byte)0x01, Void.class); }); - - } - - static void testStaticFieldWrongMethodType(Handles hs) throws Throwable { - int i = 0; - - for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { - // Incorrect return type - checkWMTE(() -> { // reference class - Void x = (Void) hs.get(am, methodType(Void.class)). - invoke(); - }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); - }); - // Incorrect arity - checkWMTE(() -> { // > - byte x = (byte) hs.get(am, methodType(Class.class)). - invoke(Void.class); - }); - } - - for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { - checkWMTE(() -> { // value reference class - hs.get(am, methodType(void.class, Class.class)). - invoke(Void.class); - }); - // Incorrect arity - checkWMTE(() -> { // 0 - hs.get(am, methodType(void.class)). - invoke(); - }); - checkWMTE(() -> { // > - hs.get(am, methodType(void.class, byte.class, Class.class)). - invoke((byte)1, Void.class); - }); - } - - } - - - static void testArrayWrongMethodType(VarHandle vh) throws Throwable { - byte[] array = new byte[10]; - Arrays.fill(array, (byte)1); - - // Get + // WeakCompareAndSetAcquire // Incorrect argument types - checkNPE(() -> { // null array - byte x = (byte) vh.get(null, 0); + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetAcquire(null, 0, (byte)0x01, (byte)0x01); }); - checkCCE(() -> { // array reference class - byte x = (byte) vh.get(Void.class, 0); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, (byte)0x01, (byte)0x01); }); - checkWMTE(() -> { // array primitive class - byte x = (byte) vh.get(0, 0); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, (byte)0x01); }); - checkWMTE(() -> { // index reference class - byte x = (byte) vh.get(array, Void.class); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetAcquire(array, 0, (byte)0x01, Void.class); }); - // Incorrect return type - checkWMTE(() -> { // reference class - Void x = (Void) vh.get(array, 0); + checkWMTE(() -> { // receiver primitive class + boolean r = vh.weakCompareAndSetAcquire(0, 0, (byte)0x01, (byte)0x01); }); - checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.get(array, 0); + checkWMTE(() -> { // index reference class + boolean r = vh.weakCompareAndSetAcquire(array, Void.class, (byte)0x01, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - byte x = (byte) vh.get(); + boolean r = vh.weakCompareAndSetAcquire(); }); checkWMTE(() -> { // > - byte x = (byte) vh.get(array, 0, Void.class); + boolean r = vh.weakCompareAndSetAcquire(array, 0, (byte)0x01, (byte)0x01, Void.class); }); - // Set + // WeakCompareAndSetRelease // Incorrect argument types - checkNPE(() -> { // null array - vh.set(null, 0, (byte)1); + checkNPE(() -> { // null receiver + boolean r = vh.weakCompareAndSetRelease(null, 0, (byte)0x01, (byte)0x01); }); - checkCCE(() -> { // array reference class - vh.set(Void.class, 0, (byte)1); + checkCCE(() -> { // receiver reference class + boolean r = vh.weakCompareAndSetRelease(Void.class, 0, (byte)0x01, (byte)0x01); }); - checkWMTE(() -> { // value reference class - vh.set(array, 0, Void.class); + checkWMTE(() -> { // expected reference class + boolean r = vh.weakCompareAndSetRelease(array, 0, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = vh.weakCompareAndSetRelease(array, 0, (byte)0x01, Void.class); }); checkWMTE(() -> { // receiver primitive class - vh.set(0, 0, (byte)1); + boolean r = vh.weakCompareAndSetRelease(0, 0, (byte)0x01, (byte)0x01); }); checkWMTE(() -> { // index reference class - vh.set(array, Void.class, (byte)1); + boolean r = vh.weakCompareAndSetRelease(array, Void.class, (byte)0x01, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - vh.set(); + boolean r = vh.weakCompareAndSetRelease(); }); checkWMTE(() -> { // > - vh.set(array, 0, (byte)1, Void.class); + boolean r = vh.weakCompareAndSetRelease(array, 0, (byte)0x01, (byte)0x01, Void.class); }); - // GetVolatile + // CompareAndExchangeVolatile // Incorrect argument types - checkNPE(() -> { // null array - byte x = (byte) vh.getVolatile(null, 0); + checkNPE(() -> { // null receiver + byte x = (byte) vh.compareAndExchangeVolatile(null, 0, (byte)0x01, (byte)0x01); }); checkCCE(() -> { // array reference class - byte x = (byte) vh.getVolatile(Void.class, 0); + byte x = (byte) vh.compareAndExchangeVolatile(Void.class, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + byte x = (byte) vh.compareAndExchangeVolatile(array, 0, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + byte x = (byte) vh.compareAndExchangeVolatile(array, 0, (byte)0x01, Void.class); }); checkWMTE(() -> { // array primitive class - byte x = (byte) vh.getVolatile(0, 0); + byte x = (byte) vh.compareAndExchangeVolatile(0, 0, (byte)0x01, (byte)0x01); }); checkWMTE(() -> { // index reference class - byte x = (byte) vh.getVolatile(array, Void.class); + byte x = (byte) vh.compareAndExchangeVolatile(array, Void.class, (byte)0x01, (byte)0x01); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) vh.getVolatile(array, 0); + Void r = (Void) vh.compareAndExchangeVolatile(array, 0, (byte)0x01, (byte)0x01); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.getVolatile(array, 0); + boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, (byte)0x01, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - byte x = (byte) vh.getVolatile(); + byte x = (byte) vh.compareAndExchangeVolatile(); }); checkWMTE(() -> { // > - byte x = (byte) vh.getVolatile(array, 0, Void.class); + byte x = (byte) vh.compareAndExchangeVolatile(array, 0, (byte)0x01, (byte)0x01, Void.class); }); - // SetVolatile + // CompareAndExchangeAcquire // Incorrect argument types - checkNPE(() -> { // null array - vh.setVolatile(null, 0, (byte)1); + checkNPE(() -> { // null receiver + byte x = (byte) vh.compareAndExchangeAcquire(null, 0, (byte)0x01, (byte)0x01); }); checkCCE(() -> { // array reference class - vh.setVolatile(Void.class, 0, (byte)1); + byte x = (byte) vh.compareAndExchangeAcquire(Void.class, 0, (byte)0x01, (byte)0x01); }); - checkWMTE(() -> { // value reference class - vh.setVolatile(array, 0, Void.class); + checkWMTE(() -> { // expected reference class + byte x = (byte) vh.compareAndExchangeAcquire(array, 0, Void.class, (byte)0x01); }); - checkWMTE(() -> { // receiver primitive class - vh.setVolatile(0, 0, (byte)1); + checkWMTE(() -> { // actual reference class + byte x = (byte) vh.compareAndExchangeAcquire(array, 0, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.compareAndExchangeAcquire(0, 0, (byte)0x01, (byte)0x01); }); checkWMTE(() -> { // index reference class - vh.setVolatile(array, Void.class, (byte)1); + byte x = (byte) vh.compareAndExchangeAcquire(array, Void.class, (byte)0x01, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.compareAndExchangeAcquire(array, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, (byte)0x01, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - vh.setVolatile(); + byte x = (byte) vh.compareAndExchangeAcquire(); }); checkWMTE(() -> { // > - vh.setVolatile(array, 0, (byte)1, Void.class); + byte x = (byte) vh.compareAndExchangeAcquire(array, 0, (byte)0x01, (byte)0x01, Void.class); }); - // GetOpaque + // CompareAndExchangeRelease // Incorrect argument types - checkNPE(() -> { // null array - byte x = (byte) vh.getOpaque(null, 0); + checkNPE(() -> { // null receiver + byte x = (byte) vh.compareAndExchangeRelease(null, 0, (byte)0x01, (byte)0x01); }); checkCCE(() -> { // array reference class - byte x = (byte) vh.getOpaque(Void.class, 0); + byte x = (byte) vh.compareAndExchangeRelease(Void.class, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + byte x = (byte) vh.compareAndExchangeRelease(array, 0, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + byte x = (byte) vh.compareAndExchangeRelease(array, 0, (byte)0x01, Void.class); }); checkWMTE(() -> { // array primitive class - byte x = (byte) vh.getOpaque(0, 0); + byte x = (byte) vh.compareAndExchangeRelease(0, 0, (byte)0x01, (byte)0x01); }); checkWMTE(() -> { // index reference class - byte x = (byte) vh.getOpaque(array, Void.class); + byte x = (byte) vh.compareAndExchangeRelease(array, Void.class, (byte)0x01, (byte)0x01); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) vh.getOpaque(array, 0); + Void r = (Void) vh.compareAndExchangeRelease(array, 0, (byte)0x01, (byte)0x01); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.getOpaque(array, 0); + boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, (byte)0x01, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - byte x = (byte) vh.getOpaque(); + byte x = (byte) vh.compareAndExchangeRelease(); }); checkWMTE(() -> { // > - byte x = (byte) vh.getOpaque(array, 0, Void.class); + byte x = (byte) vh.compareAndExchangeRelease(array, 0, (byte)0x01, (byte)0x01, Void.class); }); - // SetOpaque + // GetAndSet // Incorrect argument types checkNPE(() -> { // null array - vh.setOpaque(null, 0, (byte)1); + byte x = (byte) vh.getAndSet(null, 0, (byte)0x01); }); checkCCE(() -> { // array reference class - vh.setOpaque(Void.class, 0, (byte)1); + byte x = (byte) vh.getAndSet(Void.class, 0, (byte)0x01); }); checkWMTE(() -> { // value reference class - vh.setOpaque(array, 0, Void.class); + byte x = (byte) vh.getAndSet(array, 0, Void.class); }); - checkWMTE(() -> { // receiver primitive class - vh.setOpaque(0, 0, (byte)1); + checkWMTE(() -> { // reciarrayever primitive class + byte x = (byte) vh.getAndSet(0, 0, (byte)0x01); }); checkWMTE(() -> { // index reference class - vh.setOpaque(array, Void.class, (byte)1); + byte x = (byte) vh.getAndSet(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.getAndSet(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.getAndSet(array, 0, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - vh.setOpaque(); + byte x = (byte) vh.getAndSet(); }); checkWMTE(() -> { // > - vh.setOpaque(array, 0, (byte)1, Void.class); + byte x = (byte) vh.getAndSet(array, 0, (byte)0x01, Void.class); }); - - // GetAcquire + // GetAndAdd // Incorrect argument types checkNPE(() -> { // null array - byte x = (byte) vh.getAcquire(null, 0); + byte x = (byte) vh.getAndAdd(null, 0, (byte)0x01); }); checkCCE(() -> { // array reference class - byte x = (byte) vh.getAcquire(Void.class, 0); + byte x = (byte) vh.getAndAdd(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) vh.getAndAdd(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class - byte x = (byte) vh.getAcquire(0, 0); + byte x = (byte) vh.getAndAdd(0, 0, (byte)0x01); }); checkWMTE(() -> { // index reference class - byte x = (byte) vh.getAcquire(array, Void.class); + byte x = (byte) vh.getAndAdd(array, Void.class, (byte)0x01); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) vh.getAcquire(array, 0); + Void r = (Void) vh.getAndAdd(array, 0, (byte)0x01); }); checkWMTE(() -> { // primitive class - boolean x = (boolean) vh.getAcquire(array, 0); + boolean x = (boolean) vh.getAndAdd(array, 0, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - byte x = (byte) vh.getAcquire(); + byte x = (byte) vh.getAndAdd(); }); checkWMTE(() -> { // > - byte x = (byte) vh.getAcquire(array, 0, Void.class); + byte x = (byte) vh.getAndAdd(array, 0, (byte)0x01, Void.class); }); - // SetRelease + // AddAndGet // Incorrect argument types checkNPE(() -> { // null array - vh.setRelease(null, 0, (byte)1); + byte x = (byte) vh.addAndGet(null, 0, (byte)0x01); }); checkCCE(() -> { // array reference class - vh.setRelease(Void.class, 0, (byte)1); + byte x = (byte) vh.addAndGet(Void.class, 0, (byte)0x01); }); checkWMTE(() -> { // value reference class - vh.setRelease(array, 0, Void.class); + byte x = (byte) vh.addAndGet(array, 0, Void.class); }); - checkWMTE(() -> { // receiver primitive class - vh.setRelease(0, 0, (byte)1); + checkWMTE(() -> { // array primitive class + byte x = (byte) vh.addAndGet(0, 0, (byte)0x01); }); checkWMTE(() -> { // index reference class - vh.setRelease(array, Void.class, (byte)1); + byte x = (byte) vh.addAndGet(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) vh.addAndGet(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) vh.addAndGet(array, 0, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 - vh.setRelease(); + byte x = (byte) vh.addAndGet(); }); checkWMTE(() -> { // > - vh.setRelease(array, 0, (byte)1, Void.class); + byte x = (byte) vh.addAndGet(array, 0, (byte)0x01, Void.class); }); - - - } static void testArrayWrongMethodType(Handles hs) throws Throwable { byte[] array = new byte[10]; - Arrays.fill(array, (byte)1); + Arrays.fill(array, (byte)0x01); for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types @@ -822,11 +1948,11 @@ // Incorrect argument types checkNPE(() -> { // null array hs.get(am, methodType(void.class, Void.class, int.class, byte.class)). - invoke(null, 0, (byte)1); + invoke(null, 0, (byte)0x01); }); checkCCE(() -> { // array reference class hs.get(am, methodType(void.class, Class.class, int.class, byte.class)). - invoke(Void.class, 0, (byte)1); + invoke(Void.class, 0, (byte)0x01); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)). @@ -834,11 +1960,11 @@ }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class, byte.class)). - invoke(0, 0, (byte)1); + invoke(0, 0, (byte)0x01); }); checkWMTE(() -> { // index reference class hs.get(am, methodType(void.class, byte[].class, Class.class, byte.class)). - invoke(array, Void.class, (byte)1); + invoke(array, Void.class, (byte)0x01); }); // Incorrect arity checkWMTE(() -> { // 0 @@ -847,10 +1973,175 @@ }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)). - invoke(array, 0, (byte)1, Void.class); + invoke(array, 0, (byte)0x01, Void.class); + }); + } + for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { + // Incorrect argument types + checkNPE(() -> { // null receiver + boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, byte.class, byte.class)). + invoke(null, 0, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // receiver reference class + boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, byte.class, byte.class)). + invoke(Void.class, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + boolean r = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class, Class.class, byte.class)). + invoke(array, 0, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + boolean r = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class, byte.class, Class.class)). + invoke(array, 0, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // receiver primitive class + boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, byte.class, byte.class)). + invoke(0, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + boolean r = (boolean) hs.get(am, methodType(boolean.class, byte[].class, Class.class, byte.class, byte.class)). + invoke(array, Void.class, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + boolean r = (boolean) hs.get(am, methodType(boolean.class)). + invoke(); + }); + checkWMTE(() -> { // > + boolean r = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class, byte.class, byte.class, Class.class)). + invoke(array, 0, (byte)0x01, (byte)0x01, Void.class); + }); + } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { + // Incorrect argument types + checkNPE(() -> { // null receiver + byte x = (byte) hs.get(am, methodType(byte.class, Void.class, int.class, byte.class, byte.class)). + invoke(null, 0, (byte)0x01, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class, byte.class, byte.class)). + invoke(Void.class, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // expected reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class, byte.class)). + invoke(array, 0, Void.class, (byte)0x01); + }); + checkWMTE(() -> { // actual reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, byte.class, Class.class)). + invoke(array, 0, (byte)0x01, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class, byte.class, byte.class)). + invoke(0, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class, byte.class, byte.class)). + invoke(array, Void.class, (byte)0x01, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, byte[].class, int.class, byte.class, byte.class)). + invoke(array, 0, (byte)0x01, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class, byte.class, byte.class)). + invoke(array, 0, (byte)0x01, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invoke(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, byte.class, byte.class, Class.class)). + invoke(array, 0, (byte)0x01, (byte)0x01, Void.class); + }); + } + + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) hs.get(am, methodType(byte.class, Void.class, int.class, byte.class)). + invoke(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class, byte.class)). + invoke(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class)). + invoke(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class, byte.class)). + invoke(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class, byte.class)). + invoke(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, byte[].class, int.class, byte.class)). + invoke(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class, byte.class)). + invoke(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invoke(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, byte.class, Class.class)). + invoke(array, 0, (byte)0x01, Void.class); }); } + for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { + // Incorrect argument types + checkNPE(() -> { // null array + byte x = (byte) hs.get(am, methodType(byte.class, Void.class, int.class, byte.class)). + invoke(null, 0, (byte)0x01); + }); + checkCCE(() -> { // array reference class + byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class, byte.class)). + invoke(Void.class, 0, (byte)0x01); + }); + checkWMTE(() -> { // value reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class)). + invoke(array, 0, Void.class); + }); + checkWMTE(() -> { // array primitive class + byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class, byte.class)). + invoke(0, 0, (byte)0x01); + }); + checkWMTE(() -> { // index reference class + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class, byte.class)). + invoke(array, Void.class, (byte)0x01); + }); + // Incorrect return type + checkWMTE(() -> { // reference class + Void r = (Void) hs.get(am, methodType(Void.class, byte[].class, int.class, byte.class)). + invoke(array, 0, (byte)0x01); + }); + checkWMTE(() -> { // primitive class + boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class, byte.class)). + invoke(array, 0, (byte)0x01); + }); + // Incorrect arity + checkWMTE(() -> { // 0 + byte x = (byte) hs.get(am, methodType(byte.class)). + invoke(); + }); + checkWMTE(() -> { // > + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, byte.class, Class.class)). + invoke(array, 0, (byte)0x01, Void.class); + }); + } } }