8157726: VarHandles/Unsafe should support sub-word atomic ops
Reviewed-by: psandoz, vlivanov, lagergren
--- a/jdk/make/gensrc/GensrcVarHandles.gmk Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/make/gensrc/GensrcVarHandles.gmk Wed Jun 15 11:20:15 2016 +0300
@@ -38,14 +38,18 @@
$1_FILENAME := $(VARHANDLES_GENSRC_DIR)/VarHandle$$($1_Type)s.java
- ifneq ($$(findstring $$($1_Type), Object Int Long), )
+ ifneq ($$(findstring $$($1_Type), Object Boolean Byte Short Char Int Long), )
$1_ARGS += -KCAS
endif
- ifneq ($$(findstring $$($1_Type), Int Long), )
+ ifneq ($$(findstring $$($1_Type), Byte Short Char Int Long), )
$1_ARGS += -KAtomicAdd
endif
+ ifneq ($$(findstring $$($1_Type), Byte Short Char), )
+ $1_ARGS += -KShorterThanInt
+ endif
+
$$($1_FILENAME): $(VARHANDLES_SRC_DIR)/X-VarHandle.java.template $(BUILD_TOOLS_JDK)
ifeq ($$($1_Type), Object)
$$(eval $1_type := $$($1_Type))
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java Wed Jun 15 11:20:15 2016 +0300
@@ -1208,16 +1208,15 @@
* <ul>
* <li>if the field is declared {@code final}, then the write, atomic
* update, and numeric atomic update access modes are unsupported.
- * <li>if the field type is anything other than {@code int},
+ * <li>if the field type is anything other than {@code boolean},
+ * {@code byte}, {@code short}, {@code char}, {@code int},
* {@code long} or a reference type, then atomic update access modes
* are unsupported. (Future major platform releases of the JDK may
* support additional types for certain currently unsupported access
* modes.)
- * <li>if the field type is anything other than {@code int} or
- * {@code long}, then numeric atomic update access modes are
- * unsupported. (Future major platform releases of the JDK may
- * support additional numeric types for certain currently
- * unsupported access modes.)
+ * <li>if the field type is anything other than {@code byte},
+ * {@code short}, {@code char}, {@code int} or {@code long}, then
+ * numeric atomic update access modes are unsupported.
* </ul>
* <p>
* If the field is declared {@code volatile} then the returned VarHandle
@@ -1306,16 +1305,15 @@
* <ul>
* <li>if the field is declared {@code final}, then the write, atomic
* update, and numeric atomic update access modes are unsupported.
- * <li>if the field type is anything other than {@code int},
+ * <li>if the field type is anything other than {@code boolean},
+ * {@code byte}, {@code short}, {@code char}, {@code int},
* {@code long} or a reference type, then atomic update access modes
* are unsupported. (Future major platform releases of the JDK may
* support additional types for certain currently unsupported access
* modes.)
- * <li>if the field type is anything other than {@code int} or
- * {@code long}, then numeric atomic update access modes are
- * unsupported. (Future major platform releases of the JDK may
- * support additional numeric types for certain currently
- * unsupported access modes.)
+ * <li>if the field type is anything other than {@code byte},
+ * {@code short}, {@code char}, {@code int} or {@code long}, then
+ * numeric atomic update access modes are unsupported.
* </ul>
* <p>
* If the field is declared {@code volatile} then the returned VarHandle
@@ -1590,16 +1588,15 @@
* <ul>
* <li>if the field is declared {@code final}, then the write, atomic
* update, and numeric atomic update access modes are unsupported.
- * <li>if the field type is anything other than {@code int},
+ * <li>if the field type is anything other than {@code boolean},
+ * {@code byte}, {@code short}, {@code char}, {@code int},
* {@code long} or a reference type, then atomic update access modes
* are unsupported. (Future major platform releases of the JDK may
* support additional types for certain currently unsupported access
* modes.)
- * <li>if the field type is anything other than {@code int} or
- * {@code long}, then numeric atomic update access modes are
- * unsupported. (Future major platform releases of the JDK may
- * support additional numeric types for certain currently
- * unsupported access modes.)
+ * <li>if the field type is anything other than {@code byte},
+ * {@code short}, {@code char}, {@code int} or {@code long}, then
+ * numeric atomic update access modes are unsupported.
* </ul>
* <p>
* If the field is declared {@code volatile} then the returned VarHandle
@@ -2297,16 +2294,15 @@
* Certain access modes of the returned VarHandle are unsupported under
* the following conditions:
* <ul>
- * <li>if the component type is anything other than {@code int},
+ * <li>if the field type is anything other than {@code boolean},
+ * {@code byte}, {@code short}, {@code char}, {@code int},
* {@code long} or a reference type, then atomic update access modes
* are unsupported. (Future major platform releases of the JDK may
* support additional types for certain currently unsupported access
* modes.)
- * <li>if the component type is anything other than {@code int} or
- * {@code long}, then numeric atomic update access modes are
- * unsupported. (Future major platform releases of the JDK may
- * support additional numeric types for certain currently
- * unsupported access modes.)
+ * <li>if the component type is anything other than {@code byte},
+ * {@code short}, {@code char}, {@code int} or {@code long}, then
+ * numeric atomic update access modes are unsupported.
* </ul>
* @param arrayClass the class of an array, of type {@code T[]}
* @return a VarHandle giving access to elements of an array
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template Wed Jun 15 11:20:15 2016 +0300
@@ -205,9 +205,9 @@
@ForceInline
static $type$ addAndGet(FieldInstanceReadWrite handle, Object holder, $type$ value) {
- return UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
+ return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
handle.fieldOffset,
- value) + value;
+ value) + value);
}
#end[AtomicAdd]
@@ -386,9 +386,9 @@
@ForceInline
static $type$ addAndGet(FieldStaticReadWrite handle, $type$ value) {
- return UNSAFE.getAndAdd$Type$(handle.base,
+ return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(handle.base,
handle.fieldOffset,
- value) + value;
+ value) + value);
}
#end[AtomicAdd]
@@ -646,9 +646,9 @@
#else[Object]
$type$[] array = ($type$[]) oarray;
#end[Object]
- return UNSAFE.getAndAdd$Type$(array,
+ return {#if[ShorterThanInt]?($type$)}(UNSAFE.getAndAdd$Type$(array,
(((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
- value) + value;
+ value) + value);
}
#end[AtomicAdd]
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java Wed Jun 15 11:20:15 2016 +0300
@@ -1400,6 +1400,285 @@
return compareAndSwapInt(o, offset, expected, x);
}
+ @HotSpotIntrinsicCandidate
+ public final byte compareAndExchangeByteVolatile(Object o, long offset,
+ byte expected,
+ byte x) {
+ long wordOffset = offset & ~3;
+ int shift = (int) (offset & 3) << 3;
+ if (BE) {
+ shift = 24 - shift;
+ }
+ int mask = 0xFF << shift;
+ int maskedExpected = (expected & 0xFF) << shift;
+ int maskedX = (x & 0xFF) << shift;
+ int fullWord;
+ do {
+ fullWord = getIntVolatile(o, wordOffset);
+ if ((fullWord & mask) != maskedExpected)
+ return (byte) ((fullWord & mask) >> shift);
+ } while (!weakCompareAndSwapIntVolatile(o, wordOffset,
+ fullWord, (fullWord & ~mask) | maskedX));
+ return expected;
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final boolean compareAndSwapByte(Object o, long offset,
+ byte expected,
+ byte x) {
+ return compareAndExchangeByteVolatile(o, offset, expected, x) == expected;
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final boolean weakCompareAndSwapByteVolatile(Object o, long offset,
+ byte expected,
+ byte x) {
+ return compareAndSwapByte(o, offset, expected, x);
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final boolean weakCompareAndSwapByteAcquire(Object o, long offset,
+ byte expected,
+ byte x) {
+ return weakCompareAndSwapByteVolatile(o, offset, expected, x);
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final boolean weakCompareAndSwapByteRelease(Object o, long offset,
+ byte expected,
+ byte x) {
+ return weakCompareAndSwapByteVolatile(o, offset, expected, x);
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final boolean weakCompareAndSwapByte(Object o, long offset,
+ byte expected,
+ byte x) {
+ return weakCompareAndSwapByteVolatile(o, offset, expected, x);
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final byte compareAndExchangeByteAcquire(Object o, long offset,
+ byte expected,
+ byte x) {
+ return compareAndExchangeByteVolatile(o, offset, expected, x);
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final byte compareAndExchangeByteRelease(Object o, long offset,
+ byte expected,
+ byte x) {
+ return compareAndExchangeByteVolatile(o, offset, expected, x);
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final short compareAndExchangeShortVolatile(Object o, long offset,
+ short expected,
+ short x) {
+ if ((offset & 3) == 3) {
+ throw new IllegalArgumentException("Update spans the word, not supported");
+ }
+ long wordOffset = offset & ~3;
+ int shift = (int) (offset & 3) << 3;
+ if (BE) {
+ shift = 16 - shift;
+ }
+ int mask = 0xFFFF << shift;
+ int maskedExpected = (expected & 0xFFFF) << shift;
+ int maskedX = (x & 0xFFFF) << shift;
+ int fullWord;
+ do {
+ fullWord = getIntVolatile(o, wordOffset);
+ if ((fullWord & mask) != maskedExpected) {
+ return (short) ((fullWord & mask) >> shift);
+ }
+ } while (!weakCompareAndSwapIntVolatile(o, wordOffset,
+ fullWord, (fullWord & ~mask) | maskedX));
+ return expected;
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final boolean compareAndSwapShort(Object o, long offset,
+ short expected,
+ short x) {
+ return compareAndExchangeShortVolatile(o, offset, expected, x) == expected;
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final boolean weakCompareAndSwapShortVolatile(Object o, long offset,
+ short expected,
+ short x) {
+ return compareAndSwapShort(o, offset, expected, x);
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final boolean weakCompareAndSwapShortAcquire(Object o, long offset,
+ short expected,
+ short x) {
+ return weakCompareAndSwapShortVolatile(o, offset, expected, x);
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final boolean weakCompareAndSwapShortRelease(Object o, long offset,
+ short expected,
+ short x) {
+ return weakCompareAndSwapShortVolatile(o, offset, expected, x);
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final boolean weakCompareAndSwapShort(Object o, long offset,
+ short expected,
+ short x) {
+ return weakCompareAndSwapShortVolatile(o, offset, expected, x);
+ }
+
+
+ @HotSpotIntrinsicCandidate
+ public final short compareAndExchangeShortAcquire(Object o, long offset,
+ short expected,
+ short x) {
+ return compareAndExchangeShortVolatile(o, offset, expected, x);
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final short compareAndExchangeShortRelease(Object o, long offset,
+ short expected,
+ short x) {
+ return compareAndExchangeShortVolatile(o, offset, expected, x);
+ }
+
+ @ForceInline
+ private char s2c(short s) {
+ return (char) s;
+ }
+
+ @ForceInline
+ private short c2s(char s) {
+ return (short) s;
+ }
+
+ @ForceInline
+ public final boolean compareAndSwapChar(Object o, long offset,
+ char expected,
+ char x) {
+ return compareAndSwapShort(o, offset, c2s(expected), c2s(x));
+ }
+
+ @ForceInline
+ public final char compareAndExchangeCharVolatile(Object o, long offset,
+ char expected,
+ char x) {
+ return s2c(compareAndExchangeShortVolatile(o, offset, c2s(expected), c2s(x)));
+ }
+
+ @ForceInline
+ public final char compareAndExchangeCharAcquire(Object o, long offset,
+ char expected,
+ char x) {
+ return s2c(compareAndExchangeShortAcquire(o, offset, c2s(expected), c2s(x)));
+ }
+
+ @ForceInline
+ public final char compareAndExchangeCharRelease(Object o, long offset,
+ char expected,
+ char x) {
+ return s2c(compareAndExchangeShortRelease(o, offset, c2s(expected), c2s(x)));
+ }
+
+ @ForceInline
+ public final boolean weakCompareAndSwapCharVolatile(Object o, long offset,
+ char expected,
+ char x) {
+ return weakCompareAndSwapShortVolatile(o, offset, c2s(expected), c2s(x));
+ }
+
+ @ForceInline
+ public final boolean weakCompareAndSwapCharAcquire(Object o, long offset,
+ char expected,
+ char x) {
+ return weakCompareAndSwapShortAcquire(o, offset, c2s(expected), c2s(x));
+ }
+
+ @ForceInline
+ public final boolean weakCompareAndSwapCharRelease(Object o, long offset,
+ char expected,
+ char x) {
+ return weakCompareAndSwapShortRelease(o, offset, c2s(expected), c2s(x));
+ }
+
+ @ForceInline
+ public final boolean weakCompareAndSwapChar(Object o, long offset,
+ char expected,
+ char x) {
+ return weakCompareAndSwapShort(o, offset, c2s(expected), c2s(x));
+ }
+
+ @ForceInline
+ private boolean byte2bool(byte b) {
+ return b > 0;
+ }
+
+ @ForceInline
+ private byte bool2byte(boolean b) {
+ return b ? (byte)1 : (byte)0;
+ }
+
+ @ForceInline
+ public final boolean compareAndSwapBoolean(Object o, long offset,
+ boolean expected,
+ boolean x) {
+ return compareAndSwapByte(o, offset, bool2byte(expected), bool2byte(x));
+ }
+
+ @ForceInline
+ public final boolean compareAndExchangeBooleanVolatile(Object o, long offset,
+ boolean expected,
+ boolean x) {
+ return byte2bool(compareAndExchangeByteVolatile(o, offset, bool2byte(expected), bool2byte(x)));
+ }
+
+ @ForceInline
+ public final boolean compareAndExchangeBooleanAcquire(Object o, long offset,
+ boolean expected,
+ boolean x) {
+ return byte2bool(compareAndExchangeByteAcquire(o, offset, bool2byte(expected), bool2byte(x)));
+ }
+
+ @ForceInline
+ public final boolean compareAndExchangeBooleanRelease(Object o, long offset,
+ boolean expected,
+ boolean x) {
+ return byte2bool(compareAndExchangeByteRelease(o, offset, bool2byte(expected), bool2byte(x)));
+ }
+
+ @ForceInline
+ public final boolean weakCompareAndSwapBooleanVolatile(Object o, long offset,
+ boolean expected,
+ boolean x) {
+ return weakCompareAndSwapByteVolatile(o, offset, bool2byte(expected), bool2byte(x));
+ }
+
+ @ForceInline
+ public final boolean weakCompareAndSwapBooleanAcquire(Object o, long offset,
+ boolean expected,
+ boolean x) {
+ return weakCompareAndSwapByteAcquire(o, offset, bool2byte(expected), bool2byte(x));
+ }
+
+ @ForceInline
+ public final boolean weakCompareAndSwapBooleanRelease(Object o, long offset,
+ boolean expected,
+ boolean x) {
+ return weakCompareAndSwapByteRelease(o, offset, bool2byte(expected), bool2byte(x));
+ }
+
+ @ForceInline
+ public final boolean weakCompareAndSwapBoolean(Object o, long offset,
+ boolean expected,
+ boolean x) {
+ return weakCompareAndSwapByte(o, offset, bool2byte(expected), bool2byte(x));
+ }
+
/**
* Atomically updates Java variable to {@code x} if it is currently
* holding {@code expected}.
@@ -1840,7 +2119,7 @@
int v;
do {
v = getIntVolatile(o, offset);
- } while (!compareAndSwapInt(o, offset, v, v + delta));
+ } while (!weakCompareAndSwapIntVolatile(o, offset, v, v + delta));
return v;
}
@@ -1860,10 +2139,32 @@
long v;
do {
v = getLongVolatile(o, offset);
- } while (!compareAndSwapLong(o, offset, v, v + delta));
+ } while (!weakCompareAndSwapLongVolatile(o, offset, v, v + delta));
+ return v;
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final byte getAndAddByte(Object o, long offset, byte delta) {
+ byte v;
+ do {
+ v = getByteVolatile(o, offset);
+ } while (!weakCompareAndSwapByteVolatile(o, offset, v, (byte) (v + delta)));
return v;
}
+ @HotSpotIntrinsicCandidate
+ public final short getAndAddShort(Object o, long offset, short delta) {
+ short v;
+ do {
+ v = getShortVolatile(o, offset);
+ } while (!weakCompareAndSwapShortVolatile(o, offset, v, (short) (v + delta)));
+ return v;
+ }
+
+ public final char getAndAddChar(Object o, long offset, char delta) {
+ return (char) getAndAddShort(o, offset, (short) delta);
+ }
+
/**
* Atomically exchanges the given value with the current value of
* a field or array element within the given object {@code o}
@@ -1880,7 +2181,7 @@
int v;
do {
v = getIntVolatile(o, offset);
- } while (!compareAndSwapInt(o, offset, v, newValue));
+ } while (!weakCompareAndSwapIntVolatile(o, offset, v, newValue));
return v;
}
@@ -1900,7 +2201,7 @@
long v;
do {
v = getLongVolatile(o, offset);
- } while (!compareAndSwapLong(o, offset, v, newValue));
+ } while (!weakCompareAndSwapLongVolatile(o, offset, v, newValue));
return v;
}
@@ -1920,10 +2221,35 @@
Object v;
do {
v = getObjectVolatile(o, offset);
- } while (!compareAndSwapObject(o, offset, v, newValue));
+ } while (!weakCompareAndSwapObjectVolatile(o, offset, v, newValue));
+ return v;
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final byte getAndSetByte(Object o, long offset, byte newValue) {
+ byte v;
+ do {
+ v = getByteVolatile(o, offset);
+ } while (!weakCompareAndSwapByteVolatile(o, offset, v, newValue));
return v;
}
+ public final boolean getAndSetBoolean(Object o, long offset, boolean newValue) {
+ return byte2bool(getAndSetByte(o, offset, bool2byte(newValue)));
+ }
+
+ @HotSpotIntrinsicCandidate
+ public final short getAndSetShort(Object o, long offset, short newValue) {
+ short v;
+ do {
+ v = getShortVolatile(o, offset);
+ } while (!weakCompareAndSwapShortVolatile(o, offset, v, newValue));
+ return v;
+ }
+
+ public final char getAndSetChar(Object o, long offset, char newValue) {
+ return s2c(getAndSetShort(o, offset, c2s(newValue)));
+ }
/**
* Ensures that loads before the fence will not be reordered with loads and
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java Wed Jun 15 11:20:15 2016 +0300
@@ -99,15 +99,15 @@
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
@@ -260,41 +260,6 @@
vh.setOpaque(recv, false);
});
- checkUOE(() -> {
- boolean r = vh.compareAndSet(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeVolatile(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeAcquire(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeRelease(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.getAndSet(recv, true);
- });
checkUOE(() -> {
boolean o = (boolean) vh.getAndAdd(recv, true);
@@ -350,41 +315,6 @@
vh.setOpaque(false);
});
- checkUOE(() -> {
- boolean r = vh.compareAndSet(true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeVolatile(true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeAcquire(true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeRelease(true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.getAndSet(true);
- });
checkUOE(() -> {
boolean o = (boolean) vh.getAndAdd(true);
@@ -426,45 +356,116 @@
assertEquals(x, false, "setOpaque boolean value");
}
+ vh.set(recv, true);
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet(recv, true, false);
+ assertEquals(r, true, "success compareAndSet boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, false, "success compareAndSet boolean value");
+ }
+
+ {
+ boolean r = vh.compareAndSet(recv, true, false);
+ assertEquals(r, false, "failing compareAndSet boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, false, "failing compareAndSet boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeVolatile(recv, false, true);
+ assertEquals(r, false, "success compareAndExchangeVolatile boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, true, "success compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeVolatile(recv, false, false);
+ assertEquals(r, true, "failing compareAndExchangeVolatile boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, true, "failing compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeAcquire(recv, true, false);
+ assertEquals(r, true, "success compareAndExchangeAcquire boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, false, "success compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeAcquire(recv, true, false);
+ assertEquals(r, false, "failing compareAndExchangeAcquire boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, false, "failing compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeRelease(recv, false, true);
+ assertEquals(r, false, "success compareAndExchangeRelease boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, true, "success compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeRelease(recv, false, false);
+ assertEquals(r, true, "failing compareAndExchangeRelease boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, true, "failing compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet(recv, true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSet boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, false, "weakCompareAndSet boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire(recv, false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, true, "weakCompareAndSetAcquire boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease(recv, true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, false, "weakCompareAndSetRelease boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetVolatile(recv, false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, true, "weakCompareAndSetVolatile boolean value");
+ }
+
+ // Compare set and get
+ {
+ boolean o = (boolean) vh.getAndSet(recv, false);
+ assertEquals(o, true, "getAndSet boolean");
+ boolean x = (boolean) vh.get(recv);
+ assertEquals(x, false, "getAndSet boolean value");
+ }
}
static void testInstanceFieldUnsupported(VarHandleTestAccessBoolean recv, VarHandle vh) {
- checkUOE(() -> {
- boolean r = vh.compareAndSet(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeVolatile(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeAcquire(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeRelease(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(recv, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.getAndSet(recv, true);
- });
checkUOE(() -> {
boolean o = (boolean) vh.getAndAdd(recv, true);
@@ -506,45 +507,116 @@
assertEquals(x, false, "setOpaque boolean value");
}
+ vh.set(true);
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet(true, false);
+ assertEquals(r, true, "success compareAndSet boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, false, "success compareAndSet boolean value");
+ }
+
+ {
+ boolean r = vh.compareAndSet(true, false);
+ assertEquals(r, false, "failing compareAndSet boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, false, "failing compareAndSet boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeVolatile(false, true);
+ assertEquals(r, false, "success compareAndExchangeVolatile boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, true, "success compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeVolatile(false, false);
+ assertEquals(r, true, "failing compareAndExchangeVolatile boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, true, "failing compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeAcquire(true, false);
+ assertEquals(r, true, "success compareAndExchangeAcquire boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, false, "success compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeAcquire(true, false);
+ assertEquals(r, false, "failing compareAndExchangeAcquire boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, false, "failing compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeRelease(false, true);
+ assertEquals(r, false, "success compareAndExchangeRelease boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, true, "success compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeRelease(false, false);
+ assertEquals(r, true, "failing compareAndExchangeRelease boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, true, "failing compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet(true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSet boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, false, "weakCompareAndSet boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire(false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, true, "weakCompareAndSetAcquire boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease(true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, false, "weakCompareAndSetRelease boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease(false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, true, "weakCompareAndSetVolatile boolean");
+ }
+
+ // Compare set and get
+ {
+ boolean o = (boolean) vh.getAndSet(false);
+ assertEquals(o, true, "getAndSet boolean");
+ boolean x = (boolean) vh.get();
+ assertEquals(x, false, "getAndSet boolean value");
+ }
}
static void testStaticFieldUnsupported(VarHandle vh) {
- checkUOE(() -> {
- boolean r = vh.compareAndSet(true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeVolatile(true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeAcquire(true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeRelease(true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.getAndSet(true);
- });
checkUOE(() -> {
boolean o = (boolean) vh.getAndAdd(true);
@@ -589,6 +661,112 @@
assertEquals(x, false, "setOpaque boolean value");
}
+ vh.set(array, i, true);
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet(array, i, true, false);
+ assertEquals(r, true, "success compareAndSet boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, false, "success compareAndSet boolean value");
+ }
+
+ {
+ boolean r = vh.compareAndSet(array, i, true, false);
+ assertEquals(r, false, "failing compareAndSet boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, false, "failing compareAndSet boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeVolatile(array, i, false, true);
+ assertEquals(r, false, "success compareAndExchangeVolatile boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, true, "success compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeVolatile(array, i, false, false);
+ assertEquals(r, true, "failing compareAndExchangeVolatile boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, true, "failing compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeAcquire(array, i, true, false);
+ assertEquals(r, true, "success compareAndExchangeAcquire boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, false, "success compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeAcquire(array, i, true, false);
+ assertEquals(r, false, "failing compareAndExchangeAcquire boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, false, "failing compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeRelease(array, i, false, true);
+ assertEquals(r, false, "success compareAndExchangeRelease boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, true, "success compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean r = (boolean) vh.compareAndExchangeRelease(array, i, false, false);
+ assertEquals(r, true, "failing compareAndExchangeRelease boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, true, "failing compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet(array, i, true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSet boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, false, "weakCompareAndSet boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire(array, i, false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, true, "weakCompareAndSetAcquire boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease(array, i, true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, false, "weakCompareAndSetRelease boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetVolatile(array, i, false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, true, "weakCompareAndSetVolatile boolean");
+ }
+
+ // Compare set and get
+ {
+ boolean o = (boolean) vh.getAndSet(array, i, false);
+ assertEquals(o, true, "getAndSet boolean");
+ boolean x = (boolean) vh.get(array, i);
+ assertEquals(x, false, "getAndSet boolean value");
+ }
}
}
@@ -597,41 +775,6 @@
boolean[] array = new boolean[10];
int i = 0;
- checkUOE(() -> {
- boolean r = vh.compareAndSet(array, i, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeVolatile(array, i, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeAcquire(array, i, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.compareAndExchangeRelease(array, i, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(array, i, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(array, i, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(array, i, true, false);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(array, i, true, false);
- });
-
- checkUOE(() -> {
- boolean r = (boolean) vh.getAndSet(array, i, true);
- });
checkUOE(() -> {
boolean o = (boolean) vh.getAndAdd(array, i, true);
@@ -680,6 +823,41 @@
vh.setOpaque(array, ci, true);
});
+ checkIOOBE(() -> {
+ boolean r = vh.compareAndSet(array, ci, true, false);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = (boolean) vh.compareAndExchangeVolatile(array, ci, false, true);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = (boolean) vh.compareAndExchangeAcquire(array, ci, false, true);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = (boolean) vh.compareAndExchangeRelease(array, ci, false, true);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSet(array, ci, true, false);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetVolatile(array, ci, true, false);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetAcquire(array, ci, true, false);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetRelease(array, ci, true, false);
+ });
+
+ checkIOOBE(() -> {
+ boolean o = (boolean) vh.getAndSet(array, ci, true);
+ });
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java Wed Jun 15 11:20:15 2016 +0300
@@ -42,11 +42,11 @@
import static org.testng.Assert.*;
public class VarHandleTestAccessByte extends VarHandleBaseTest {
- static final byte static_final_v = (byte)1;
+ static final byte static_final_v = (byte)0x01;
static byte static_v;
- final byte final_v = (byte)1;
+ final byte final_v = (byte)0x01;
byte v;
@@ -99,18 +99,18 @@
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
@@ -220,89 +220,47 @@
// Plain
{
byte x = (byte) vh.get(recv);
- assertEquals(x, (byte)1, "get byte value");
+ assertEquals(x, (byte)0x01, "get byte value");
}
// Volatile
{
byte x = (byte) vh.getVolatile(recv);
- assertEquals(x, (byte)1, "getVolatile byte value");
+ assertEquals(x, (byte)0x01, "getVolatile byte value");
}
// Lazy
{
byte x = (byte) vh.getAcquire(recv);
- assertEquals(x, (byte)1, "getRelease byte value");
+ assertEquals(x, (byte)0x01, "getRelease byte value");
}
// Opaque
{
byte x = (byte) vh.getOpaque(recv);
- assertEquals(x, (byte)1, "getOpaque byte value");
+ assertEquals(x, (byte)0x01, "getOpaque byte value");
}
}
static void testInstanceFinalFieldUnsupported(VarHandleTestAccessByte recv, VarHandle vh) {
checkUOE(() -> {
- vh.set(recv, (byte)2);
- });
-
- checkUOE(() -> {
- vh.setVolatile(recv, (byte)2);
- });
-
- checkUOE(() -> {
- vh.setRelease(recv, (byte)2);
+ vh.set(recv, (byte)0x23);
});
checkUOE(() -> {
- vh.setOpaque(recv, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.compareAndSet(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeVolatile(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeAcquire(recv, (byte)1, (byte)2);
+ vh.setVolatile(recv, (byte)0x23);
});
checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeRelease(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(recv, (byte)1, (byte)2);
+ vh.setRelease(recv, (byte)0x23);
});
checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(recv, (byte)1, (byte)2);
+ vh.setOpaque(recv, (byte)0x23);
});
- checkUOE(() -> {
- byte r = (byte) vh.getAndSet(recv, (byte)1);
- });
- checkUOE(() -> {
- byte o = (byte) vh.getAndAdd(recv, (byte)1);
- });
-
- checkUOE(() -> {
- byte o = (byte) vh.addAndGet(recv, (byte)1);
- });
}
@@ -310,249 +268,353 @@
// Plain
{
byte x = (byte) vh.get();
- assertEquals(x, (byte)1, "get byte value");
+ assertEquals(x, (byte)0x01, "get byte value");
}
// Volatile
{
byte x = (byte) vh.getVolatile();
- assertEquals(x, (byte)1, "getVolatile byte value");
+ assertEquals(x, (byte)0x01, "getVolatile byte value");
}
// Lazy
{
byte x = (byte) vh.getAcquire();
- assertEquals(x, (byte)1, "getRelease byte value");
+ assertEquals(x, (byte)0x01, "getRelease byte value");
}
// Opaque
{
byte x = (byte) vh.getOpaque();
- assertEquals(x, (byte)1, "getOpaque byte value");
+ assertEquals(x, (byte)0x01, "getOpaque byte value");
}
}
static void testStaticFinalFieldUnsupported(VarHandle vh) {
checkUOE(() -> {
- vh.set((byte)2);
- });
-
- checkUOE(() -> {
- vh.setVolatile((byte)2);
- });
-
- checkUOE(() -> {
- vh.setRelease((byte)2);
+ vh.set((byte)0x23);
});
checkUOE(() -> {
- vh.setOpaque((byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.compareAndSet((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeVolatile((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeAcquire((byte)1, (byte)2);
+ vh.setVolatile((byte)0x23);
});
checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeRelease((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile((byte)1, (byte)2);
+ vh.setRelease((byte)0x23);
});
checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease((byte)1, (byte)2);
+ vh.setOpaque((byte)0x23);
});
- checkUOE(() -> {
- byte r = (byte) vh.getAndSet((byte)1);
- });
- checkUOE(() -> {
- byte o = (byte) vh.getAndAdd((byte)1);
- });
-
- checkUOE(() -> {
- byte o = (byte) vh.addAndGet((byte)1);
- });
}
static void testInstanceField(VarHandleTestAccessByte recv, VarHandle vh) {
// Plain
{
- vh.set(recv, (byte)1);
+ vh.set(recv, (byte)0x01);
byte x = (byte) vh.get(recv);
- assertEquals(x, (byte)1, "set byte value");
+ assertEquals(x, (byte)0x01, "set byte value");
}
// Volatile
{
- vh.setVolatile(recv, (byte)2);
+ vh.setVolatile(recv, (byte)0x23);
byte x = (byte) vh.getVolatile(recv);
- assertEquals(x, (byte)2, "setVolatile byte value");
+ assertEquals(x, (byte)0x23, "setVolatile byte value");
}
// Lazy
{
- vh.setRelease(recv, (byte)1);
+ vh.setRelease(recv, (byte)0x01);
byte x = (byte) vh.getAcquire(recv);
- assertEquals(x, (byte)1, "setRelease byte value");
+ assertEquals(x, (byte)0x01, "setRelease byte value");
}
// Opaque
{
- vh.setOpaque(recv, (byte)2);
+ vh.setOpaque(recv, (byte)0x23);
byte x = (byte) vh.getOpaque(recv);
- assertEquals(x, (byte)2, "setOpaque byte value");
+ assertEquals(x, (byte)0x23, "setOpaque byte value");
+ }
+
+ vh.set(recv, (byte)0x01);
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet(recv, (byte)0x01, (byte)0x23);
+ assertEquals(r, true, "success compareAndSet byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x23, "success compareAndSet byte value");
+ }
+
+ {
+ boolean r = vh.compareAndSet(recv, (byte)0x01, (byte)0x45);
+ assertEquals(r, false, "failing compareAndSet byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x23, "failing compareAndSet byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeVolatile(recv, (byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeVolatile byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x01, "success compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeVolatile(recv, (byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeVolatile byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeAcquire(recv, (byte)0x01, (byte)0x23);
+ assertEquals(r, (byte)0x01, "success compareAndExchangeAcquire byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x23, "success compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeAcquire(recv, (byte)0x01, (byte)0x45);
+ assertEquals(r, (byte)0x23, "failing compareAndExchangeAcquire byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x23, "failing compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeRelease(recv, (byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeRelease byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x01, "success compareAndExchangeRelease byte value");
}
+ {
+ byte r = (byte) vh.compareAndExchangeRelease(recv, (byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeRelease byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeRelease byte value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet(recv, (byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSet byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x23, "weakCompareAndSet byte value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire(recv, (byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x01, "weakCompareAndSetAcquire byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease(recv, (byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x23, "weakCompareAndSetRelease byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetVolatile(recv, (byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte value");
+ }
+
+ // Compare set and get
+ {
+ byte o = (byte) vh.getAndSet(recv, (byte)0x23);
+ assertEquals(o, (byte)0x01, "getAndSet byte");
+ byte x = (byte) vh.get(recv);
+ assertEquals(x, (byte)0x23, "getAndSet byte value");
+ }
+
+ vh.set(recv, (byte)0x01);
+
+ // get and add, add and get
+ {
+ byte o = (byte) vh.getAndAdd(recv, (byte)0x45);
+ assertEquals(o, (byte)0x01, "getAndAdd byte");
+ byte c = (byte) vh.addAndGet(recv, (byte)0x45);
+ assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value");
+ }
}
static void testInstanceFieldUnsupported(VarHandleTestAccessByte recv, VarHandle vh) {
- checkUOE(() -> {
- boolean r = vh.compareAndSet(recv, (byte)1, (byte)2);
- });
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeVolatile(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeAcquire(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeRelease(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(recv, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.getAndSet(recv, (byte)1);
- });
-
- checkUOE(() -> {
- byte o = (byte) vh.getAndAdd(recv, (byte)1);
- });
-
- checkUOE(() -> {
- byte o = (byte) vh.addAndGet(recv, (byte)1);
- });
}
static void testStaticField(VarHandle vh) {
// Plain
{
- vh.set((byte)1);
+ vh.set((byte)0x01);
byte x = (byte) vh.get();
- assertEquals(x, (byte)1, "set byte value");
+ assertEquals(x, (byte)0x01, "set byte value");
}
// Volatile
{
- vh.setVolatile((byte)2);
+ vh.setVolatile((byte)0x23);
byte x = (byte) vh.getVolatile();
- assertEquals(x, (byte)2, "setVolatile byte value");
+ assertEquals(x, (byte)0x23, "setVolatile byte value");
}
// Lazy
{
- vh.setRelease((byte)1);
+ vh.setRelease((byte)0x01);
byte x = (byte) vh.getAcquire();
- assertEquals(x, (byte)1, "setRelease byte value");
+ assertEquals(x, (byte)0x01, "setRelease byte value");
}
// Opaque
{
- vh.setOpaque((byte)2);
+ vh.setOpaque((byte)0x23);
byte x = (byte) vh.getOpaque();
- assertEquals(x, (byte)2, "setOpaque byte value");
+ assertEquals(x, (byte)0x23, "setOpaque byte value");
+ }
+
+ vh.set((byte)0x01);
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet((byte)0x01, (byte)0x23);
+ assertEquals(r, true, "success compareAndSet byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x23, "success compareAndSet byte value");
+ }
+
+ {
+ boolean r = vh.compareAndSet((byte)0x01, (byte)0x45);
+ assertEquals(r, false, "failing compareAndSet byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x23, "failing compareAndSet byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeVolatile((byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeVolatile byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x01, "success compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeVolatile((byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeVolatile byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeAcquire((byte)0x01, (byte)0x23);
+ assertEquals(r, (byte)0x01, "success compareAndExchangeAcquire byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x23, "success compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeAcquire((byte)0x01, (byte)0x45);
+ assertEquals(r, (byte)0x23, "failing compareAndExchangeAcquire byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x23, "failing compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeRelease((byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeRelease byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x01, "success compareAndExchangeRelease byte value");
}
+ {
+ byte r = (byte) vh.compareAndExchangeRelease((byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeRelease byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeRelease byte value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet((byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSet byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x23, "weakCompareAndSet byte value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire((byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x01, "weakCompareAndSetAcquire byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease((byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x23, "weakCompareAndSetRelease byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease((byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte");
+ }
+
+ // Compare set and get
+ {
+ byte o = (byte) vh.getAndSet((byte)0x23);
+ assertEquals(o, (byte)0x01, "getAndSet byte");
+ byte x = (byte) vh.get();
+ assertEquals(x, (byte)0x23, "getAndSet byte value");
+ }
+
+ vh.set((byte)0x01);
+
+ // get and add, add and get
+ {
+ byte o = (byte) vh.getAndAdd( (byte)0x45);
+ assertEquals(o, (byte)0x01, "getAndAdd byte");
+ byte c = (byte) vh.addAndGet((byte)0x45);
+ assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value");
+ }
}
static void testStaticFieldUnsupported(VarHandle vh) {
- checkUOE(() -> {
- boolean r = vh.compareAndSet((byte)1, (byte)2);
- });
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeVolatile((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeAcquire((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeRelease((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease((byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.getAndSet((byte)1);
- });
-
- checkUOE(() -> {
- byte o = (byte) vh.getAndAdd((byte)1);
- });
-
- checkUOE(() -> {
- byte o = (byte) vh.addAndGet((byte)1);
- });
}
@@ -562,34 +624,149 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- vh.set(array, i, (byte)1);
+ vh.set(array, i, (byte)0x01);
byte x = (byte) vh.get(array, i);
- assertEquals(x, (byte)1, "get byte value");
+ assertEquals(x, (byte)0x01, "get byte value");
}
// Volatile
{
- vh.setVolatile(array, i, (byte)2);
+ vh.setVolatile(array, i, (byte)0x23);
byte x = (byte) vh.getVolatile(array, i);
- assertEquals(x, (byte)2, "setVolatile byte value");
+ assertEquals(x, (byte)0x23, "setVolatile byte value");
}
// Lazy
{
- vh.setRelease(array, i, (byte)1);
+ vh.setRelease(array, i, (byte)0x01);
byte x = (byte) vh.getAcquire(array, i);
- assertEquals(x, (byte)1, "setRelease byte value");
+ assertEquals(x, (byte)0x01, "setRelease byte value");
}
// Opaque
{
- vh.setOpaque(array, i, (byte)2);
+ vh.setOpaque(array, i, (byte)0x23);
byte x = (byte) vh.getOpaque(array, i);
- assertEquals(x, (byte)2, "setOpaque byte value");
+ assertEquals(x, (byte)0x23, "setOpaque byte value");
+ }
+
+ vh.set(array, i, (byte)0x01);
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet(array, i, (byte)0x01, (byte)0x23);
+ assertEquals(r, true, "success compareAndSet byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x23, "success compareAndSet byte value");
+ }
+
+ {
+ boolean r = vh.compareAndSet(array, i, (byte)0x01, (byte)0x45);
+ assertEquals(r, false, "failing compareAndSet byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x23, "failing compareAndSet byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeVolatile(array, i, (byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeVolatile byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x01, "success compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeVolatile(array, i, (byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeVolatile byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeAcquire(array, i, (byte)0x01, (byte)0x23);
+ assertEquals(r, (byte)0x01, "success compareAndExchangeAcquire byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x23, "success compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeAcquire(array, i, (byte)0x01, (byte)0x45);
+ assertEquals(r, (byte)0x23, "failing compareAndExchangeAcquire byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x23, "failing compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) vh.compareAndExchangeRelease(array, i, (byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeRelease byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x01, "success compareAndExchangeRelease byte value");
}
+ {
+ byte r = (byte) vh.compareAndExchangeRelease(array, i, (byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeRelease byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeRelease byte value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet(array, i, (byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSet byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x23, "weakCompareAndSet byte value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire(array, i, (byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x01, "weakCompareAndSetAcquire byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease(array, i, (byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x23, "weakCompareAndSetRelease byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetVolatile(array, i, (byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte");
+ }
+
+ // Compare set and get
+ {
+ byte o = (byte) vh.getAndSet(array, i, (byte)0x23);
+ assertEquals(o, (byte)0x01, "getAndSet byte");
+ byte x = (byte) vh.get(array, i);
+ assertEquals(x, (byte)0x23, "getAndSet byte value");
+ }
+
+ vh.set(array, i, (byte)0x01);
+
+ // get and add, add and get
+ {
+ byte o = (byte) vh.getAndAdd(array, i, (byte)0x45);
+ assertEquals(o, (byte)0x01, "getAndAdd byte");
+ byte c = (byte) vh.addAndGet(array, i, (byte)0x45);
+ assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value");
+ }
}
}
@@ -597,49 +774,7 @@
byte[] array = new byte[10];
int i = 0;
- checkUOE(() -> {
- boolean r = vh.compareAndSet(array, i, (byte)1, (byte)2);
- });
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeVolatile(array, i, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeAcquire(array, i, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.compareAndExchangeRelease(array, i, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(array, i, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(array, i, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(array, i, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(array, i, (byte)1, (byte)2);
- });
-
- checkUOE(() -> {
- byte r = (byte) vh.getAndSet(array, i, (byte)1);
- });
-
- checkUOE(() -> {
- byte o = (byte) vh.getAndAdd(array, i, (byte)1);
- });
-
- checkUOE(() -> {
- byte o = (byte) vh.addAndGet(array, i, (byte)1);
- });
}
static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable {
@@ -653,7 +788,7 @@
});
checkIOOBE(() -> {
- vh.set(array, ci, (byte)1);
+ vh.set(array, ci, (byte)0x01);
});
checkIOOBE(() -> {
@@ -661,7 +796,7 @@
});
checkIOOBE(() -> {
- vh.setVolatile(array, ci, (byte)1);
+ vh.setVolatile(array, ci, (byte)0x01);
});
checkIOOBE(() -> {
@@ -669,7 +804,7 @@
});
checkIOOBE(() -> {
- vh.setRelease(array, ci, (byte)1);
+ vh.setRelease(array, ci, (byte)0x01);
});
checkIOOBE(() -> {
@@ -677,10 +812,52 @@
});
checkIOOBE(() -> {
- vh.setOpaque(array, ci, (byte)1);
+ vh.setOpaque(array, ci, (byte)0x01);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.compareAndSet(array, ci, (byte)0x01, (byte)0x23);
+ });
+
+ checkIOOBE(() -> {
+ byte r = (byte) vh.compareAndExchangeVolatile(array, ci, (byte)0x23, (byte)0x01);
+ });
+
+ checkIOOBE(() -> {
+ byte r = (byte) vh.compareAndExchangeAcquire(array, ci, (byte)0x23, (byte)0x01);
+ });
+
+ checkIOOBE(() -> {
+ byte r = (byte) vh.compareAndExchangeRelease(array, ci, (byte)0x23, (byte)0x01);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSet(array, ci, (byte)0x01, (byte)0x23);
});
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetVolatile(array, ci, (byte)0x01, (byte)0x23);
+ });
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetAcquire(array, ci, (byte)0x01, (byte)0x23);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetRelease(array, ci, (byte)0x01, (byte)0x23);
+ });
+
+ checkIOOBE(() -> {
+ byte o = (byte) vh.getAndSet(array, ci, (byte)0x01);
+ });
+
+ checkIOOBE(() -> {
+ byte o = (byte) vh.getAndAdd(array, ci, (byte)0x45);
+ });
+
+ checkIOOBE(() -> {
+ byte o = (byte) vh.addAndGet(array, ci, (byte)0x45);
+ });
}
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java Wed Jun 15 11:20:15 2016 +0300
@@ -42,11 +42,11 @@
import static org.testng.Assert.*;
public class VarHandleTestAccessChar extends VarHandleBaseTest {
- static final char static_final_v = 'a';
+ static final char static_final_v = '\u0123';
static char static_v;
- final char final_v = 'a';
+ final char final_v = '\u0123';
char v;
@@ -99,18 +99,18 @@
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
@@ -220,89 +220,47 @@
// Plain
{
char x = (char) vh.get(recv);
- assertEquals(x, 'a', "get char value");
+ assertEquals(x, '\u0123', "get char value");
}
// Volatile
{
char x = (char) vh.getVolatile(recv);
- assertEquals(x, 'a', "getVolatile char value");
+ assertEquals(x, '\u0123', "getVolatile char value");
}
// Lazy
{
char x = (char) vh.getAcquire(recv);
- assertEquals(x, 'a', "getRelease char value");
+ assertEquals(x, '\u0123', "getRelease char value");
}
// Opaque
{
char x = (char) vh.getOpaque(recv);
- assertEquals(x, 'a', "getOpaque char value");
+ assertEquals(x, '\u0123', "getOpaque char value");
}
}
static void testInstanceFinalFieldUnsupported(VarHandleTestAccessChar recv, VarHandle vh) {
checkUOE(() -> {
- vh.set(recv, 'b');
- });
-
- checkUOE(() -> {
- vh.setVolatile(recv, 'b');
- });
-
- checkUOE(() -> {
- vh.setRelease(recv, 'b');
+ vh.set(recv, '\u4567');
});
checkUOE(() -> {
- vh.setOpaque(recv, 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.compareAndSet(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeVolatile(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeAcquire(recv, 'a', 'b');
+ vh.setVolatile(recv, '\u4567');
});
checkUOE(() -> {
- char r = (char) vh.compareAndExchangeRelease(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(recv, 'a', 'b');
+ vh.setRelease(recv, '\u4567');
});
checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(recv, 'a', 'b');
+ vh.setOpaque(recv, '\u4567');
});
- checkUOE(() -> {
- char r = (char) vh.getAndSet(recv, 'a');
- });
- checkUOE(() -> {
- char o = (char) vh.getAndAdd(recv, 'a');
- });
-
- checkUOE(() -> {
- char o = (char) vh.addAndGet(recv, 'a');
- });
}
@@ -310,249 +268,353 @@
// Plain
{
char x = (char) vh.get();
- assertEquals(x, 'a', "get char value");
+ assertEquals(x, '\u0123', "get char value");
}
// Volatile
{
char x = (char) vh.getVolatile();
- assertEquals(x, 'a', "getVolatile char value");
+ assertEquals(x, '\u0123', "getVolatile char value");
}
// Lazy
{
char x = (char) vh.getAcquire();
- assertEquals(x, 'a', "getRelease char value");
+ assertEquals(x, '\u0123', "getRelease char value");
}
// Opaque
{
char x = (char) vh.getOpaque();
- assertEquals(x, 'a', "getOpaque char value");
+ assertEquals(x, '\u0123', "getOpaque char value");
}
}
static void testStaticFinalFieldUnsupported(VarHandle vh) {
checkUOE(() -> {
- vh.set('b');
- });
-
- checkUOE(() -> {
- vh.setVolatile('b');
- });
-
- checkUOE(() -> {
- vh.setRelease('b');
+ vh.set('\u4567');
});
checkUOE(() -> {
- vh.setOpaque('b');
- });
-
- checkUOE(() -> {
- boolean r = vh.compareAndSet('a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeVolatile('a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeAcquire('a', 'b');
+ vh.setVolatile('\u4567');
});
checkUOE(() -> {
- char r = (char) vh.compareAndExchangeRelease('a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet('a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile('a', 'b');
+ vh.setRelease('\u4567');
});
checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire('a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease('a', 'b');
+ vh.setOpaque('\u4567');
});
- checkUOE(() -> {
- char r = (char) vh.getAndSet('a');
- });
- checkUOE(() -> {
- char o = (char) vh.getAndAdd('a');
- });
-
- checkUOE(() -> {
- char o = (char) vh.addAndGet('a');
- });
}
static void testInstanceField(VarHandleTestAccessChar recv, VarHandle vh) {
// Plain
{
- vh.set(recv, 'a');
+ vh.set(recv, '\u0123');
char x = (char) vh.get(recv);
- assertEquals(x, 'a', "set char value");
+ assertEquals(x, '\u0123', "set char value");
}
// Volatile
{
- vh.setVolatile(recv, 'b');
+ vh.setVolatile(recv, '\u4567');
char x = (char) vh.getVolatile(recv);
- assertEquals(x, 'b', "setVolatile char value");
+ assertEquals(x, '\u4567', "setVolatile char value");
}
// Lazy
{
- vh.setRelease(recv, 'a');
+ vh.setRelease(recv, '\u0123');
char x = (char) vh.getAcquire(recv);
- assertEquals(x, 'a', "setRelease char value");
+ assertEquals(x, '\u0123', "setRelease char value");
}
// Opaque
{
- vh.setOpaque(recv, 'b');
+ vh.setOpaque(recv, '\u4567');
char x = (char) vh.getOpaque(recv);
- assertEquals(x, 'b', "setOpaque char value");
+ assertEquals(x, '\u4567', "setOpaque char value");
+ }
+
+ vh.set(recv, '\u0123');
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet(recv, '\u0123', '\u4567');
+ assertEquals(r, true, "success compareAndSet char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u4567', "success compareAndSet char value");
+ }
+
+ {
+ boolean r = vh.compareAndSet(recv, '\u0123', '\u89AB');
+ assertEquals(r, false, "failing compareAndSet char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u4567', "failing compareAndSet char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeVolatile(recv, '\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeVolatile char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u0123', "success compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeVolatile(recv, '\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeVolatile char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u0123', "failing compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeAcquire(recv, '\u0123', '\u4567');
+ assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeAcquire(recv, '\u0123', '\u89AB');
+ assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeRelease(recv, '\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
}
+ {
+ char r = (char) vh.compareAndExchangeRelease(recv, '\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet(recv, '\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSet char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u4567', "weakCompareAndSet char value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire(recv, '\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u0123', "weakCompareAndSetAcquire char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease(recv, '\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u4567', "weakCompareAndSetRelease char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetVolatile(recv, '\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u0123', "weakCompareAndSetVolatile char value");
+ }
+
+ // Compare set and get
+ {
+ char o = (char) vh.getAndSet(recv, '\u4567');
+ assertEquals(o, '\u0123', "getAndSet char");
+ char x = (char) vh.get(recv);
+ assertEquals(x, '\u4567', "getAndSet char value");
+ }
+
+ vh.set(recv, '\u0123');
+
+ // get and add, add and get
+ {
+ char o = (char) vh.getAndAdd(recv, '\u89AB');
+ assertEquals(o, '\u0123', "getAndAdd char");
+ char c = (char) vh.addAndGet(recv, '\u89AB');
+ assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value");
+ }
}
static void testInstanceFieldUnsupported(VarHandleTestAccessChar recv, VarHandle vh) {
- checkUOE(() -> {
- boolean r = vh.compareAndSet(recv, 'a', 'b');
- });
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeVolatile(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeAcquire(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeRelease(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(recv, 'a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.getAndSet(recv, 'a');
- });
-
- checkUOE(() -> {
- char o = (char) vh.getAndAdd(recv, 'a');
- });
-
- checkUOE(() -> {
- char o = (char) vh.addAndGet(recv, 'a');
- });
}
static void testStaticField(VarHandle vh) {
// Plain
{
- vh.set('a');
+ vh.set('\u0123');
char x = (char) vh.get();
- assertEquals(x, 'a', "set char value");
+ assertEquals(x, '\u0123', "set char value");
}
// Volatile
{
- vh.setVolatile('b');
+ vh.setVolatile('\u4567');
char x = (char) vh.getVolatile();
- assertEquals(x, 'b', "setVolatile char value");
+ assertEquals(x, '\u4567', "setVolatile char value");
}
// Lazy
{
- vh.setRelease('a');
+ vh.setRelease('\u0123');
char x = (char) vh.getAcquire();
- assertEquals(x, 'a', "setRelease char value");
+ assertEquals(x, '\u0123', "setRelease char value");
}
// Opaque
{
- vh.setOpaque('b');
+ vh.setOpaque('\u4567');
char x = (char) vh.getOpaque();
- assertEquals(x, 'b', "setOpaque char value");
+ assertEquals(x, '\u4567', "setOpaque char value");
+ }
+
+ vh.set('\u0123');
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet('\u0123', '\u4567');
+ assertEquals(r, true, "success compareAndSet char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u4567', "success compareAndSet char value");
+ }
+
+ {
+ boolean r = vh.compareAndSet('\u0123', '\u89AB');
+ assertEquals(r, false, "failing compareAndSet char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u4567', "failing compareAndSet char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeVolatile('\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeVolatile char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u0123', "success compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeVolatile('\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeVolatile char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u0123', "failing compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeAcquire('\u0123', '\u4567');
+ assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeAcquire('\u0123', '\u89AB');
+ assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeRelease('\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
}
+ {
+ char r = (char) vh.compareAndExchangeRelease('\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet('\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSet char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u4567', "weakCompareAndSet char value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire('\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u0123', "weakCompareAndSetAcquire char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease('\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u4567', "weakCompareAndSetRelease char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease('\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u0123', "weakCompareAndSetVolatile char");
+ }
+
+ // Compare set and get
+ {
+ char o = (char) vh.getAndSet('\u4567');
+ assertEquals(o, '\u0123', "getAndSet char");
+ char x = (char) vh.get();
+ assertEquals(x, '\u4567', "getAndSet char value");
+ }
+
+ vh.set('\u0123');
+
+ // get and add, add and get
+ {
+ char o = (char) vh.getAndAdd( '\u89AB');
+ assertEquals(o, '\u0123', "getAndAdd char");
+ char c = (char) vh.addAndGet('\u89AB');
+ assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value");
+ }
}
static void testStaticFieldUnsupported(VarHandle vh) {
- checkUOE(() -> {
- boolean r = vh.compareAndSet('a', 'b');
- });
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeVolatile('a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeAcquire('a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeRelease('a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet('a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile('a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire('a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease('a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.getAndSet('a');
- });
-
- checkUOE(() -> {
- char o = (char) vh.getAndAdd('a');
- });
-
- checkUOE(() -> {
- char o = (char) vh.addAndGet('a');
- });
}
@@ -562,34 +624,149 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- vh.set(array, i, 'a');
+ vh.set(array, i, '\u0123');
char x = (char) vh.get(array, i);
- assertEquals(x, 'a', "get char value");
+ assertEquals(x, '\u0123', "get char value");
}
// Volatile
{
- vh.setVolatile(array, i, 'b');
+ vh.setVolatile(array, i, '\u4567');
char x = (char) vh.getVolatile(array, i);
- assertEquals(x, 'b', "setVolatile char value");
+ assertEquals(x, '\u4567', "setVolatile char value");
}
// Lazy
{
- vh.setRelease(array, i, 'a');
+ vh.setRelease(array, i, '\u0123');
char x = (char) vh.getAcquire(array, i);
- assertEquals(x, 'a', "setRelease char value");
+ assertEquals(x, '\u0123', "setRelease char value");
}
// Opaque
{
- vh.setOpaque(array, i, 'b');
+ vh.setOpaque(array, i, '\u4567');
char x = (char) vh.getOpaque(array, i);
- assertEquals(x, 'b', "setOpaque char value");
+ assertEquals(x, '\u4567', "setOpaque char value");
+ }
+
+ vh.set(array, i, '\u0123');
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet(array, i, '\u0123', '\u4567');
+ assertEquals(r, true, "success compareAndSet char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u4567', "success compareAndSet char value");
+ }
+
+ {
+ boolean r = vh.compareAndSet(array, i, '\u0123', '\u89AB');
+ assertEquals(r, false, "failing compareAndSet char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u4567', "failing compareAndSet char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeVolatile(array, i, '\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeVolatile char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u0123', "success compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeVolatile(array, i, '\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeVolatile char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u0123', "failing compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeAcquire(array, i, '\u0123', '\u4567');
+ assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeAcquire(array, i, '\u0123', '\u89AB');
+ assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) vh.compareAndExchangeRelease(array, i, '\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
}
+ {
+ char r = (char) vh.compareAndExchangeRelease(array, i, '\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet(array, i, '\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSet char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u4567', "weakCompareAndSet char value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire(array, i, '\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u0123', "weakCompareAndSetAcquire char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease(array, i, '\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u4567', "weakCompareAndSetRelease char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetVolatile(array, i, '\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u0123', "weakCompareAndSetVolatile char");
+ }
+
+ // Compare set and get
+ {
+ char o = (char) vh.getAndSet(array, i, '\u4567');
+ assertEquals(o, '\u0123', "getAndSet char");
+ char x = (char) vh.get(array, i);
+ assertEquals(x, '\u4567', "getAndSet char value");
+ }
+
+ vh.set(array, i, '\u0123');
+
+ // get and add, add and get
+ {
+ char o = (char) vh.getAndAdd(array, i, '\u89AB');
+ assertEquals(o, '\u0123', "getAndAdd char");
+ char c = (char) vh.addAndGet(array, i, '\u89AB');
+ assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value");
+ }
}
}
@@ -597,49 +774,7 @@
char[] array = new char[10];
int i = 0;
- checkUOE(() -> {
- boolean r = vh.compareAndSet(array, i, 'a', 'b');
- });
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeVolatile(array, i, 'a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeAcquire(array, i, 'a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.compareAndExchangeRelease(array, i, 'a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(array, i, 'a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(array, i, 'a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(array, i, 'a', 'b');
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(array, i, 'a', 'b');
- });
-
- checkUOE(() -> {
- char r = (char) vh.getAndSet(array, i, 'a');
- });
-
- checkUOE(() -> {
- char o = (char) vh.getAndAdd(array, i, 'a');
- });
-
- checkUOE(() -> {
- char o = (char) vh.addAndGet(array, i, 'a');
- });
}
static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable {
@@ -653,7 +788,7 @@
});
checkIOOBE(() -> {
- vh.set(array, ci, 'a');
+ vh.set(array, ci, '\u0123');
});
checkIOOBE(() -> {
@@ -661,7 +796,7 @@
});
checkIOOBE(() -> {
- vh.setVolatile(array, ci, 'a');
+ vh.setVolatile(array, ci, '\u0123');
});
checkIOOBE(() -> {
@@ -669,7 +804,7 @@
});
checkIOOBE(() -> {
- vh.setRelease(array, ci, 'a');
+ vh.setRelease(array, ci, '\u0123');
});
checkIOOBE(() -> {
@@ -677,10 +812,52 @@
});
checkIOOBE(() -> {
- vh.setOpaque(array, ci, 'a');
+ vh.setOpaque(array, ci, '\u0123');
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.compareAndSet(array, ci, '\u0123', '\u4567');
+ });
+
+ checkIOOBE(() -> {
+ char r = (char) vh.compareAndExchangeVolatile(array, ci, '\u4567', '\u0123');
+ });
+
+ checkIOOBE(() -> {
+ char r = (char) vh.compareAndExchangeAcquire(array, ci, '\u4567', '\u0123');
+ });
+
+ checkIOOBE(() -> {
+ char r = (char) vh.compareAndExchangeRelease(array, ci, '\u4567', '\u0123');
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSet(array, ci, '\u0123', '\u4567');
});
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetVolatile(array, ci, '\u0123', '\u4567');
+ });
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetAcquire(array, ci, '\u0123', '\u4567');
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetRelease(array, ci, '\u0123', '\u4567');
+ });
+
+ checkIOOBE(() -> {
+ char o = (char) vh.getAndSet(array, ci, '\u0123');
+ });
+
+ checkIOOBE(() -> {
+ char o = (char) vh.getAndAdd(array, ci, '\u89AB');
+ });
+
+ checkIOOBE(() -> {
+ char o = (char) vh.addAndGet(array, ci, '\u89AB');
+ });
}
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java Wed Jun 15 11:20:15 2016 +0300
@@ -42,11 +42,11 @@
import static org.testng.Assert.*;
public class VarHandleTestAccessInt extends VarHandleBaseTest {
- static final int static_final_v = 1;
+ static final int static_final_v = 0x01234567;
static int static_v;
- final int final_v = 1;
+ final int final_v = 0x01234567;
int v;
@@ -220,44 +220,44 @@
// Plain
{
int x = (int) vh.get(recv);
- assertEquals(x, 1, "get int value");
+ assertEquals(x, 0x01234567, "get int value");
}
// Volatile
{
int x = (int) vh.getVolatile(recv);
- assertEquals(x, 1, "getVolatile int value");
+ assertEquals(x, 0x01234567, "getVolatile int value");
}
// Lazy
{
int x = (int) vh.getAcquire(recv);
- assertEquals(x, 1, "getRelease int value");
+ assertEquals(x, 0x01234567, "getRelease int value");
}
// Opaque
{
int x = (int) vh.getOpaque(recv);
- assertEquals(x, 1, "getOpaque int value");
+ assertEquals(x, 0x01234567, "getOpaque int value");
}
}
static void testInstanceFinalFieldUnsupported(VarHandleTestAccessInt recv, VarHandle vh) {
checkUOE(() -> {
- vh.set(recv, 2);
+ vh.set(recv, 0x89ABCDEF);
});
checkUOE(() -> {
- vh.setVolatile(recv, 2);
+ vh.setVolatile(recv, 0x89ABCDEF);
});
checkUOE(() -> {
- vh.setRelease(recv, 2);
+ vh.setRelease(recv, 0x89ABCDEF);
});
checkUOE(() -> {
- vh.setOpaque(recv, 2);
+ vh.setOpaque(recv, 0x89ABCDEF);
});
@@ -268,44 +268,44 @@
// Plain
{
int x = (int) vh.get();
- assertEquals(x, 1, "get int value");
+ assertEquals(x, 0x01234567, "get int value");
}
// Volatile
{
int x = (int) vh.getVolatile();
- assertEquals(x, 1, "getVolatile int value");
+ assertEquals(x, 0x01234567, "getVolatile int value");
}
// Lazy
{
int x = (int) vh.getAcquire();
- assertEquals(x, 1, "getRelease int value");
+ assertEquals(x, 0x01234567, "getRelease int value");
}
// Opaque
{
int x = (int) vh.getOpaque();
- assertEquals(x, 1, "getOpaque int value");
+ assertEquals(x, 0x01234567, "getOpaque int value");
}
}
static void testStaticFinalFieldUnsupported(VarHandle vh) {
checkUOE(() -> {
- vh.set(2);
+ vh.set(0x89ABCDEF);
});
checkUOE(() -> {
- vh.setVolatile(2);
+ vh.setVolatile(0x89ABCDEF);
});
checkUOE(() -> {
- vh.setRelease(2);
+ vh.setRelease(0x89ABCDEF);
});
checkUOE(() -> {
- vh.setOpaque(2);
+ vh.setOpaque(0x89ABCDEF);
});
@@ -315,148 +315,148 @@
static void testInstanceField(VarHandleTestAccessInt recv, VarHandle vh) {
// Plain
{
- vh.set(recv, 1);
+ vh.set(recv, 0x01234567);
int x = (int) vh.get(recv);
- assertEquals(x, 1, "set int value");
+ assertEquals(x, 0x01234567, "set int value");
}
// Volatile
{
- vh.setVolatile(recv, 2);
+ vh.setVolatile(recv, 0x89ABCDEF);
int x = (int) vh.getVolatile(recv);
- assertEquals(x, 2, "setVolatile int value");
+ assertEquals(x, 0x89ABCDEF, "setVolatile int value");
}
// Lazy
{
- vh.setRelease(recv, 1);
+ vh.setRelease(recv, 0x01234567);
int x = (int) vh.getAcquire(recv);
- assertEquals(x, 1, "setRelease int value");
+ assertEquals(x, 0x01234567, "setRelease int value");
}
// Opaque
{
- vh.setOpaque(recv, 2);
+ vh.setOpaque(recv, 0x89ABCDEF);
int x = (int) vh.getOpaque(recv);
- assertEquals(x, 2, "setOpaque int value");
+ assertEquals(x, 0x89ABCDEF, "setOpaque int value");
}
- vh.set(recv, 1);
+ vh.set(recv, 0x01234567);
// Compare
{
- boolean r = vh.compareAndSet(recv, 1, 2);
+ boolean r = vh.compareAndSet(recv, 0x01234567, 0x89ABCDEF);
assertEquals(r, true, "success compareAndSet int");
int x = (int) vh.get(recv);
- assertEquals(x, 2, "success compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndSet int value");
}
{
- boolean r = vh.compareAndSet(recv, 1, 3);
+ boolean r = vh.compareAndSet(recv, 0x01234567, 0xCAFEBABE);
assertEquals(r, false, "failing compareAndSet int");
int x = (int) vh.get(recv);
- assertEquals(x, 2, "failing compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndSet int value");
}
{
- int r = (int) vh.compareAndExchangeVolatile(recv, 2, 1);
- assertEquals(r, 2, "success compareAndExchangeVolatile int");
+ int r = (int) vh.compareAndExchangeVolatile(recv, 0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeVolatile int");
int x = (int) vh.get(recv);
- assertEquals(x, 1, "success compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeVolatile int value");
}
{
- int r = (int) vh.compareAndExchangeVolatile(recv, 2, 3);
- assertEquals(r, 1, "failing compareAndExchangeVolatile int");
+ int r = (int) vh.compareAndExchangeVolatile(recv, 0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeVolatile int");
int x = (int) vh.get(recv);
- assertEquals(x, 1, "failing compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeVolatile int value");
}
{
- int r = (int) vh.compareAndExchangeAcquire(recv, 1, 2);
- assertEquals(r, 1, "success compareAndExchangeAcquire int");
+ int r = (int) vh.compareAndExchangeAcquire(recv, 0x01234567, 0x89ABCDEF);
+ assertEquals(r, 0x01234567, "success compareAndExchangeAcquire int");
int x = (int) vh.get(recv);
- assertEquals(x, 2, "success compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndExchangeAcquire int value");
}
{
- int r = (int) vh.compareAndExchangeAcquire(recv, 1, 3);
- assertEquals(r, 2, "failing compareAndExchangeAcquire int");
+ int r = (int) vh.compareAndExchangeAcquire(recv, 0x01234567, 0xCAFEBABE);
+ assertEquals(r, 0x89ABCDEF, "failing compareAndExchangeAcquire int");
int x = (int) vh.get(recv);
- assertEquals(x, 2, "failing compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndExchangeAcquire int value");
}
{
- int r = (int) vh.compareAndExchangeRelease(recv, 2, 1);
- assertEquals(r, 2, "success compareAndExchangeRelease int");
+ int r = (int) vh.compareAndExchangeRelease(recv, 0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeRelease int");
int x = (int) vh.get(recv);
- assertEquals(x, 1, "success compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeRelease int value");
}
{
- int r = (int) vh.compareAndExchangeRelease(recv, 2, 3);
- assertEquals(r, 1, "failing compareAndExchangeRelease int");
+ int r = (int) vh.compareAndExchangeRelease(recv, 0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeRelease int");
int x = (int) vh.get(recv);
- assertEquals(x, 1, "failing compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeRelease int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSet(recv, 1, 2);
+ success = vh.weakCompareAndSet(recv, 0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSet int");
int x = (int) vh.get(recv);
- assertEquals(x, 2, "weakCompareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetAcquire(recv, 2, 1);
+ success = vh.weakCompareAndSetAcquire(recv, 0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetAcquire int");
int x = (int) vh.get(recv);
- assertEquals(x, 1, "weakCompareAndSetAcquire int");
+ assertEquals(x, 0x01234567, "weakCompareAndSetAcquire int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetRelease(recv, 1, 2);
+ success = vh.weakCompareAndSetRelease(recv, 0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSetRelease int");
int x = (int) vh.get(recv);
- assertEquals(x, 2, "weakCompareAndSetRelease int");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSetRelease int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetVolatile(recv, 2, 1);
+ success = vh.weakCompareAndSetVolatile(recv, 0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetVolatile int");
int x = (int) vh.get(recv);
- assertEquals(x, 1, "weakCompareAndSetVolatile int value");
+ assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int value");
}
// Compare set and get
{
- int o = (int) vh.getAndSet(recv, 2);
- assertEquals(o, 1, "getAndSet int");
+ int o = (int) vh.getAndSet(recv, 0x89ABCDEF);
+ assertEquals(o, 0x01234567, "getAndSet int");
int x = (int) vh.get(recv);
- assertEquals(x, 2, "getAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "getAndSet int value");
}
- vh.set(recv, 1);
+ vh.set(recv, 0x01234567);
// get and add, add and get
{
- int o = (int) vh.getAndAdd(recv, 3);
- assertEquals(o, 1, "getAndAdd int");
- int c = (int) vh.addAndGet(recv, 3);
- assertEquals(c, 1 + 3 + 3, "getAndAdd int value");
+ int o = (int) vh.getAndAdd(recv, 0xCAFEBABE);
+ assertEquals(o, 0x01234567, "getAndAdd int");
+ int c = (int) vh.addAndGet(recv, 0xCAFEBABE);
+ assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value");
}
}
@@ -468,148 +468,148 @@
static void testStaticField(VarHandle vh) {
// Plain
{
- vh.set(1);
+ vh.set(0x01234567);
int x = (int) vh.get();
- assertEquals(x, 1, "set int value");
+ assertEquals(x, 0x01234567, "set int value");
}
// Volatile
{
- vh.setVolatile(2);
+ vh.setVolatile(0x89ABCDEF);
int x = (int) vh.getVolatile();
- assertEquals(x, 2, "setVolatile int value");
+ assertEquals(x, 0x89ABCDEF, "setVolatile int value");
}
// Lazy
{
- vh.setRelease(1);
+ vh.setRelease(0x01234567);
int x = (int) vh.getAcquire();
- assertEquals(x, 1, "setRelease int value");
+ assertEquals(x, 0x01234567, "setRelease int value");
}
// Opaque
{
- vh.setOpaque(2);
+ vh.setOpaque(0x89ABCDEF);
int x = (int) vh.getOpaque();
- assertEquals(x, 2, "setOpaque int value");
+ assertEquals(x, 0x89ABCDEF, "setOpaque int value");
}
- vh.set(1);
+ vh.set(0x01234567);
// Compare
{
- boolean r = vh.compareAndSet(1, 2);
+ boolean r = vh.compareAndSet(0x01234567, 0x89ABCDEF);
assertEquals(r, true, "success compareAndSet int");
int x = (int) vh.get();
- assertEquals(x, 2, "success compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndSet int value");
}
{
- boolean r = vh.compareAndSet(1, 3);
+ boolean r = vh.compareAndSet(0x01234567, 0xCAFEBABE);
assertEquals(r, false, "failing compareAndSet int");
int x = (int) vh.get();
- assertEquals(x, 2, "failing compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndSet int value");
}
{
- int r = (int) vh.compareAndExchangeVolatile(2, 1);
- assertEquals(r, 2, "success compareAndExchangeVolatile int");
+ int r = (int) vh.compareAndExchangeVolatile(0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeVolatile int");
int x = (int) vh.get();
- assertEquals(x, 1, "success compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeVolatile int value");
}
{
- int r = (int) vh.compareAndExchangeVolatile(2, 3);
- assertEquals(r, 1, "failing compareAndExchangeVolatile int");
+ int r = (int) vh.compareAndExchangeVolatile(0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeVolatile int");
int x = (int) vh.get();
- assertEquals(x, 1, "failing compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeVolatile int value");
}
{
- int r = (int) vh.compareAndExchangeAcquire(1, 2);
- assertEquals(r, 1, "success compareAndExchangeAcquire int");
+ int r = (int) vh.compareAndExchangeAcquire(0x01234567, 0x89ABCDEF);
+ assertEquals(r, 0x01234567, "success compareAndExchangeAcquire int");
int x = (int) vh.get();
- assertEquals(x, 2, "success compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndExchangeAcquire int value");
}
{
- int r = (int) vh.compareAndExchangeAcquire(1, 3);
- assertEquals(r, 2, "failing compareAndExchangeAcquire int");
+ int r = (int) vh.compareAndExchangeAcquire(0x01234567, 0xCAFEBABE);
+ assertEquals(r, 0x89ABCDEF, "failing compareAndExchangeAcquire int");
int x = (int) vh.get();
- assertEquals(x, 2, "failing compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndExchangeAcquire int value");
}
{
- int r = (int) vh.compareAndExchangeRelease(2, 1);
- assertEquals(r, 2, "success compareAndExchangeRelease int");
+ int r = (int) vh.compareAndExchangeRelease(0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeRelease int");
int x = (int) vh.get();
- assertEquals(x, 1, "success compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeRelease int value");
}
{
- int r = (int) vh.compareAndExchangeRelease(2, 3);
- assertEquals(r, 1, "failing compareAndExchangeRelease int");
+ int r = (int) vh.compareAndExchangeRelease(0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeRelease int");
int x = (int) vh.get();
- assertEquals(x, 1, "failing compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeRelease int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSet(1, 2);
+ success = vh.weakCompareAndSet(0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSet int");
int x = (int) vh.get();
- assertEquals(x, 2, "weakCompareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetAcquire(2, 1);
+ success = vh.weakCompareAndSetAcquire(0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetAcquire int");
int x = (int) vh.get();
- assertEquals(x, 1, "weakCompareAndSetAcquire int");
+ assertEquals(x, 0x01234567, "weakCompareAndSetAcquire int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetRelease(1, 2);
+ success = vh.weakCompareAndSetRelease(0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSetRelease int");
int x = (int) vh.get();
- assertEquals(x, 2, "weakCompareAndSetRelease int");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSetRelease int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetRelease(2, 1);
+ success = vh.weakCompareAndSetRelease(0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetVolatile int");
int x = (int) vh.get();
- assertEquals(x, 1, "weakCompareAndSetVolatile int");
+ assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int");
}
// Compare set and get
{
- int o = (int) vh.getAndSet(2);
- assertEquals(o, 1, "getAndSet int");
+ int o = (int) vh.getAndSet(0x89ABCDEF);
+ assertEquals(o, 0x01234567, "getAndSet int");
int x = (int) vh.get();
- assertEquals(x, 2, "getAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "getAndSet int value");
}
- vh.set(1);
+ vh.set(0x01234567);
// get and add, add and get
{
- int o = (int) vh.getAndAdd( 3);
- assertEquals(o, 1, "getAndAdd int");
- int c = (int) vh.addAndGet(3);
- assertEquals(c, 1 + 3 + 3, "getAndAdd int value");
+ int o = (int) vh.getAndAdd( 0xCAFEBABE);
+ assertEquals(o, 0x01234567, "getAndAdd int");
+ int c = (int) vh.addAndGet(0xCAFEBABE);
+ assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value");
}
}
@@ -624,148 +624,148 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- vh.set(array, i, 1);
+ vh.set(array, i, 0x01234567);
int x = (int) vh.get(array, i);
- assertEquals(x, 1, "get int value");
+ assertEquals(x, 0x01234567, "get int value");
}
// Volatile
{
- vh.setVolatile(array, i, 2);
+ vh.setVolatile(array, i, 0x89ABCDEF);
int x = (int) vh.getVolatile(array, i);
- assertEquals(x, 2, "setVolatile int value");
+ assertEquals(x, 0x89ABCDEF, "setVolatile int value");
}
// Lazy
{
- vh.setRelease(array, i, 1);
+ vh.setRelease(array, i, 0x01234567);
int x = (int) vh.getAcquire(array, i);
- assertEquals(x, 1, "setRelease int value");
+ assertEquals(x, 0x01234567, "setRelease int value");
}
// Opaque
{
- vh.setOpaque(array, i, 2);
+ vh.setOpaque(array, i, 0x89ABCDEF);
int x = (int) vh.getOpaque(array, i);
- assertEquals(x, 2, "setOpaque int value");
+ assertEquals(x, 0x89ABCDEF, "setOpaque int value");
}
- vh.set(array, i, 1);
+ vh.set(array, i, 0x01234567);
// Compare
{
- boolean r = vh.compareAndSet(array, i, 1, 2);
+ boolean r = vh.compareAndSet(array, i, 0x01234567, 0x89ABCDEF);
assertEquals(r, true, "success compareAndSet int");
int x = (int) vh.get(array, i);
- assertEquals(x, 2, "success compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndSet int value");
}
{
- boolean r = vh.compareAndSet(array, i, 1, 3);
+ boolean r = vh.compareAndSet(array, i, 0x01234567, 0xCAFEBABE);
assertEquals(r, false, "failing compareAndSet int");
int x = (int) vh.get(array, i);
- assertEquals(x, 2, "failing compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndSet int value");
}
{
- int r = (int) vh.compareAndExchangeVolatile(array, i, 2, 1);
- assertEquals(r, 2, "success compareAndExchangeVolatile int");
+ int r = (int) vh.compareAndExchangeVolatile(array, i, 0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeVolatile int");
int x = (int) vh.get(array, i);
- assertEquals(x, 1, "success compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeVolatile int value");
}
{
- int r = (int) vh.compareAndExchangeVolatile(array, i, 2, 3);
- assertEquals(r, 1, "failing compareAndExchangeVolatile int");
+ int r = (int) vh.compareAndExchangeVolatile(array, i, 0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeVolatile int");
int x = (int) vh.get(array, i);
- assertEquals(x, 1, "failing compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeVolatile int value");
}
{
- int r = (int) vh.compareAndExchangeAcquire(array, i, 1, 2);
- assertEquals(r, 1, "success compareAndExchangeAcquire int");
+ int r = (int) vh.compareAndExchangeAcquire(array, i, 0x01234567, 0x89ABCDEF);
+ assertEquals(r, 0x01234567, "success compareAndExchangeAcquire int");
int x = (int) vh.get(array, i);
- assertEquals(x, 2, "success compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndExchangeAcquire int value");
}
{
- int r = (int) vh.compareAndExchangeAcquire(array, i, 1, 3);
- assertEquals(r, 2, "failing compareAndExchangeAcquire int");
+ int r = (int) vh.compareAndExchangeAcquire(array, i, 0x01234567, 0xCAFEBABE);
+ assertEquals(r, 0x89ABCDEF, "failing compareAndExchangeAcquire int");
int x = (int) vh.get(array, i);
- assertEquals(x, 2, "failing compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndExchangeAcquire int value");
}
{
- int r = (int) vh.compareAndExchangeRelease(array, i, 2, 1);
- assertEquals(r, 2, "success compareAndExchangeRelease int");
+ int r = (int) vh.compareAndExchangeRelease(array, i, 0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeRelease int");
int x = (int) vh.get(array, i);
- assertEquals(x, 1, "success compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeRelease int value");
}
{
- int r = (int) vh.compareAndExchangeRelease(array, i, 2, 3);
- assertEquals(r, 1, "failing compareAndExchangeRelease int");
+ int r = (int) vh.compareAndExchangeRelease(array, i, 0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeRelease int");
int x = (int) vh.get(array, i);
- assertEquals(x, 1, "failing compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeRelease int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSet(array, i, 1, 2);
+ success = vh.weakCompareAndSet(array, i, 0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSet int");
int x = (int) vh.get(array, i);
- assertEquals(x, 2, "weakCompareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetAcquire(array, i, 2, 1);
+ success = vh.weakCompareAndSetAcquire(array, i, 0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetAcquire int");
int x = (int) vh.get(array, i);
- assertEquals(x, 1, "weakCompareAndSetAcquire int");
+ assertEquals(x, 0x01234567, "weakCompareAndSetAcquire int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetRelease(array, i, 1, 2);
+ success = vh.weakCompareAndSetRelease(array, i, 0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSetRelease int");
int x = (int) vh.get(array, i);
- assertEquals(x, 2, "weakCompareAndSetRelease int");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSetRelease int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetVolatile(array, i, 2, 1);
+ success = vh.weakCompareAndSetVolatile(array, i, 0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetVolatile int");
int x = (int) vh.get(array, i);
- assertEquals(x, 1, "weakCompareAndSetVolatile int");
+ assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int");
}
// Compare set and get
{
- int o = (int) vh.getAndSet(array, i, 2);
- assertEquals(o, 1, "getAndSet int");
+ int o = (int) vh.getAndSet(array, i, 0x89ABCDEF);
+ assertEquals(o, 0x01234567, "getAndSet int");
int x = (int) vh.get(array, i);
- assertEquals(x, 2, "getAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "getAndSet int value");
}
- vh.set(array, i, 1);
+ vh.set(array, i, 0x01234567);
// get and add, add and get
{
- int o = (int) vh.getAndAdd(array, i, 3);
- assertEquals(o, 1, "getAndAdd int");
- int c = (int) vh.addAndGet(array, i, 3);
- assertEquals(c, 1 + 3 + 3, "getAndAdd int value");
+ int o = (int) vh.getAndAdd(array, i, 0xCAFEBABE);
+ assertEquals(o, 0x01234567, "getAndAdd int");
+ int c = (int) vh.addAndGet(array, i, 0xCAFEBABE);
+ assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value");
}
}
}
@@ -788,7 +788,7 @@
});
checkIOOBE(() -> {
- vh.set(array, ci, 1);
+ vh.set(array, ci, 0x01234567);
});
checkIOOBE(() -> {
@@ -796,7 +796,7 @@
});
checkIOOBE(() -> {
- vh.setVolatile(array, ci, 1);
+ vh.setVolatile(array, ci, 0x01234567);
});
checkIOOBE(() -> {
@@ -804,7 +804,7 @@
});
checkIOOBE(() -> {
- vh.setRelease(array, ci, 1);
+ vh.setRelease(array, ci, 0x01234567);
});
checkIOOBE(() -> {
@@ -812,51 +812,51 @@
});
checkIOOBE(() -> {
- vh.setOpaque(array, ci, 1);
+ vh.setOpaque(array, ci, 0x01234567);
});
checkIOOBE(() -> {
- boolean r = vh.compareAndSet(array, ci, 1, 2);
+ boolean r = vh.compareAndSet(array, ci, 0x01234567, 0x89ABCDEF);
});
checkIOOBE(() -> {
- int r = (int) vh.compareAndExchangeVolatile(array, ci, 2, 1);
+ int r = (int) vh.compareAndExchangeVolatile(array, ci, 0x89ABCDEF, 0x01234567);
});
checkIOOBE(() -> {
- int r = (int) vh.compareAndExchangeAcquire(array, ci, 2, 1);
+ int r = (int) vh.compareAndExchangeAcquire(array, ci, 0x89ABCDEF, 0x01234567);
});
checkIOOBE(() -> {
- int r = (int) vh.compareAndExchangeRelease(array, ci, 2, 1);
+ int r = (int) vh.compareAndExchangeRelease(array, ci, 0x89ABCDEF, 0x01234567);
});
checkIOOBE(() -> {
- boolean r = vh.weakCompareAndSet(array, ci, 1, 2);
+ boolean r = vh.weakCompareAndSet(array, ci, 0x01234567, 0x89ABCDEF);
});
checkIOOBE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(array, ci, 1, 2);
+ boolean r = vh.weakCompareAndSetVolatile(array, ci, 0x01234567, 0x89ABCDEF);
});
checkIOOBE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(array, ci, 1, 2);
+ boolean r = vh.weakCompareAndSetAcquire(array, ci, 0x01234567, 0x89ABCDEF);
});
checkIOOBE(() -> {
- boolean r = vh.weakCompareAndSetRelease(array, ci, 1, 2);
+ boolean r = vh.weakCompareAndSetRelease(array, ci, 0x01234567, 0x89ABCDEF);
});
checkIOOBE(() -> {
- int o = (int) vh.getAndSet(array, ci, 1);
+ int o = (int) vh.getAndSet(array, ci, 0x01234567);
});
checkIOOBE(() -> {
- int o = (int) vh.getAndAdd(array, ci, 3);
+ int o = (int) vh.getAndAdd(array, ci, 0xCAFEBABE);
});
checkIOOBE(() -> {
- int o = (int) vh.addAndGet(array, ci, 3);
+ int o = (int) vh.addAndGet(array, ci, 0xCAFEBABE);
});
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java Wed Jun 15 11:20:15 2016 +0300
@@ -42,11 +42,11 @@
import static org.testng.Assert.*;
public class VarHandleTestAccessLong extends VarHandleBaseTest {
- static final long static_final_v = 1L;
+ static final long static_final_v = 0x0123456789ABCDEFL;
static long static_v;
- final long final_v = 1L;
+ final long final_v = 0x0123456789ABCDEFL;
long v;
@@ -220,44 +220,44 @@
// Plain
{
long x = (long) vh.get(recv);
- assertEquals(x, 1L, "get long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "get long value");
}
// Volatile
{
long x = (long) vh.getVolatile(recv);
- assertEquals(x, 1L, "getVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "getVolatile long value");
}
// Lazy
{
long x = (long) vh.getAcquire(recv);
- assertEquals(x, 1L, "getRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "getRelease long value");
}
// Opaque
{
long x = (long) vh.getOpaque(recv);
- assertEquals(x, 1L, "getOpaque long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "getOpaque long value");
}
}
static void testInstanceFinalFieldUnsupported(VarHandleTestAccessLong recv, VarHandle vh) {
checkUOE(() -> {
- vh.set(recv, 2L);
+ vh.set(recv, 0xCAFEBABECAFEBABEL);
});
checkUOE(() -> {
- vh.setVolatile(recv, 2L);
+ vh.setVolatile(recv, 0xCAFEBABECAFEBABEL);
});
checkUOE(() -> {
- vh.setRelease(recv, 2L);
+ vh.setRelease(recv, 0xCAFEBABECAFEBABEL);
});
checkUOE(() -> {
- vh.setOpaque(recv, 2L);
+ vh.setOpaque(recv, 0xCAFEBABECAFEBABEL);
});
@@ -268,44 +268,44 @@
// Plain
{
long x = (long) vh.get();
- assertEquals(x, 1L, "get long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "get long value");
}
// Volatile
{
long x = (long) vh.getVolatile();
- assertEquals(x, 1L, "getVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "getVolatile long value");
}
// Lazy
{
long x = (long) vh.getAcquire();
- assertEquals(x, 1L, "getRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "getRelease long value");
}
// Opaque
{
long x = (long) vh.getOpaque();
- assertEquals(x, 1L, "getOpaque long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "getOpaque long value");
}
}
static void testStaticFinalFieldUnsupported(VarHandle vh) {
checkUOE(() -> {
- vh.set(2L);
+ vh.set(0xCAFEBABECAFEBABEL);
});
checkUOE(() -> {
- vh.setVolatile(2L);
+ vh.setVolatile(0xCAFEBABECAFEBABEL);
});
checkUOE(() -> {
- vh.setRelease(2L);
+ vh.setRelease(0xCAFEBABECAFEBABEL);
});
checkUOE(() -> {
- vh.setOpaque(2L);
+ vh.setOpaque(0xCAFEBABECAFEBABEL);
});
@@ -315,148 +315,148 @@
static void testInstanceField(VarHandleTestAccessLong recv, VarHandle vh) {
// Plain
{
- vh.set(recv, 1L);
+ vh.set(recv, 0x0123456789ABCDEFL);
long x = (long) vh.get(recv);
- assertEquals(x, 1L, "set long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "set long value");
}
// Volatile
{
- vh.setVolatile(recv, 2L);
+ vh.setVolatile(recv, 0xCAFEBABECAFEBABEL);
long x = (long) vh.getVolatile(recv);
- assertEquals(x, 2L, "setVolatile long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setVolatile long value");
}
// Lazy
{
- vh.setRelease(recv, 1L);
+ vh.setRelease(recv, 0x0123456789ABCDEFL);
long x = (long) vh.getAcquire(recv);
- assertEquals(x, 1L, "setRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "setRelease long value");
}
// Opaque
{
- vh.setOpaque(recv, 2L);
+ vh.setOpaque(recv, 0xCAFEBABECAFEBABEL);
long x = (long) vh.getOpaque(recv);
- assertEquals(x, 2L, "setOpaque long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setOpaque long value");
}
- vh.set(recv, 1L);
+ vh.set(recv, 0x0123456789ABCDEFL);
// Compare
{
- boolean r = vh.compareAndSet(recv, 1L, 2L);
+ boolean r = vh.compareAndSet(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
assertEquals(r, true, "success compareAndSet long");
long x = (long) vh.get(recv);
- assertEquals(x, 2L, "success compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSet long value");
}
{
- boolean r = vh.compareAndSet(recv, 1L, 3L);
+ boolean r = vh.compareAndSet(recv, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
assertEquals(r, false, "failing compareAndSet long");
long x = (long) vh.get(recv);
- assertEquals(x, 2L, "failing compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSet long value");
}
{
- long r = (long) vh.compareAndExchangeVolatile(recv, 2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeVolatile long");
+ long r = (long) vh.compareAndExchangeVolatile(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeVolatile long");
long x = (long) vh.get(recv);
- assertEquals(x, 1L, "success compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeVolatile long value");
}
{
- long r = (long) vh.compareAndExchangeVolatile(recv, 2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeVolatile long");
+ long r = (long) vh.compareAndExchangeVolatile(recv, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long");
long x = (long) vh.get(recv);
- assertEquals(x, 1L, "failing compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long value");
}
{
- long r = (long) vh.compareAndExchangeAcquire(recv, 1L, 2L);
- assertEquals(r, 1L, "success compareAndExchangeAcquire long");
+ long r = (long) vh.compareAndExchangeAcquire(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+ assertEquals(r, 0x0123456789ABCDEFL, "success compareAndExchangeAcquire long");
long x = (long) vh.get(recv);
- assertEquals(x, 2L, "success compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndExchangeAcquire long value");
}
{
- long r = (long) vh.compareAndExchangeAcquire(recv, 1L, 3L);
- assertEquals(r, 2L, "failing compareAndExchangeAcquire long");
+ long r = (long) vh.compareAndExchangeAcquire(recv, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long");
long x = (long) vh.get(recv);
- assertEquals(x, 2L, "failing compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long value");
}
{
- long r = (long) vh.compareAndExchangeRelease(recv, 2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeRelease long");
+ long r = (long) vh.compareAndExchangeRelease(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeRelease long");
long x = (long) vh.get(recv);
- assertEquals(x, 1L, "success compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeRelease long value");
}
{
- long r = (long) vh.compareAndExchangeRelease(recv, 2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeRelease long");
+ long r = (long) vh.compareAndExchangeRelease(recv, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long");
long x = (long) vh.get(recv);
- assertEquals(x, 1L, "failing compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSet(recv, 1L, 2L);
+ success = vh.weakCompareAndSet(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSet long");
long x = (long) vh.get(recv);
- assertEquals(x, 2L, "weakCompareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetAcquire(recv, 2L, 1L);
+ success = vh.weakCompareAndSetAcquire(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetAcquire long");
long x = (long) vh.get(recv);
- assertEquals(x, 1L, "weakCompareAndSetAcquire long");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetAcquire long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetRelease(recv, 1L, 2L);
+ success = vh.weakCompareAndSetRelease(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSetRelease long");
long x = (long) vh.get(recv);
- assertEquals(x, 2L, "weakCompareAndSetRelease long");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetRelease long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetVolatile(recv, 2L, 1L);
+ success = vh.weakCompareAndSetVolatile(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetVolatile long");
long x = (long) vh.get(recv);
- assertEquals(x, 1L, "weakCompareAndSetVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long value");
}
// Compare set and get
{
- long o = (long) vh.getAndSet(recv, 2L);
- assertEquals(o, 1L, "getAndSet long");
+ long o = (long) vh.getAndSet(recv, 0xCAFEBABECAFEBABEL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long");
long x = (long) vh.get(recv);
- assertEquals(x, 2L, "getAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value");
}
- vh.set(recv, 1L);
+ vh.set(recv, 0x0123456789ABCDEFL);
// get and add, add and get
{
- long o = (long) vh.getAndAdd(recv, 3L);
- assertEquals(o, 1L, "getAndAdd long");
- long c = (long) vh.addAndGet(recv, 3L);
- assertEquals(c, 1L + 3L + 3L, "getAndAdd long value");
+ long o = (long) vh.getAndAdd(recv, 0xDEADBEEFDEADBEEFL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long");
+ long c = (long) vh.addAndGet(recv, 0xDEADBEEFDEADBEEFL);
+ assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value");
}
}
@@ -468,148 +468,148 @@
static void testStaticField(VarHandle vh) {
// Plain
{
- vh.set(1L);
+ vh.set(0x0123456789ABCDEFL);
long x = (long) vh.get();
- assertEquals(x, 1L, "set long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "set long value");
}
// Volatile
{
- vh.setVolatile(2L);
+ vh.setVolatile(0xCAFEBABECAFEBABEL);
long x = (long) vh.getVolatile();
- assertEquals(x, 2L, "setVolatile long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setVolatile long value");
}
// Lazy
{
- vh.setRelease(1L);
+ vh.setRelease(0x0123456789ABCDEFL);
long x = (long) vh.getAcquire();
- assertEquals(x, 1L, "setRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "setRelease long value");
}
// Opaque
{
- vh.setOpaque(2L);
+ vh.setOpaque(0xCAFEBABECAFEBABEL);
long x = (long) vh.getOpaque();
- assertEquals(x, 2L, "setOpaque long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setOpaque long value");
}
- vh.set(1L);
+ vh.set(0x0123456789ABCDEFL);
// Compare
{
- boolean r = vh.compareAndSet(1L, 2L);
+ boolean r = vh.compareAndSet(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
assertEquals(r, true, "success compareAndSet long");
long x = (long) vh.get();
- assertEquals(x, 2L, "success compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSet long value");
}
{
- boolean r = vh.compareAndSet(1L, 3L);
+ boolean r = vh.compareAndSet(0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
assertEquals(r, false, "failing compareAndSet long");
long x = (long) vh.get();
- assertEquals(x, 2L, "failing compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSet long value");
}
{
- long r = (long) vh.compareAndExchangeVolatile(2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeVolatile long");
+ long r = (long) vh.compareAndExchangeVolatile(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeVolatile long");
long x = (long) vh.get();
- assertEquals(x, 1L, "success compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeVolatile long value");
}
{
- long r = (long) vh.compareAndExchangeVolatile(2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeVolatile long");
+ long r = (long) vh.compareAndExchangeVolatile(0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long");
long x = (long) vh.get();
- assertEquals(x, 1L, "failing compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long value");
}
{
- long r = (long) vh.compareAndExchangeAcquire(1L, 2L);
- assertEquals(r, 1L, "success compareAndExchangeAcquire long");
+ long r = (long) vh.compareAndExchangeAcquire(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+ assertEquals(r, 0x0123456789ABCDEFL, "success compareAndExchangeAcquire long");
long x = (long) vh.get();
- assertEquals(x, 2L, "success compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndExchangeAcquire long value");
}
{
- long r = (long) vh.compareAndExchangeAcquire(1L, 3L);
- assertEquals(r, 2L, "failing compareAndExchangeAcquire long");
+ long r = (long) vh.compareAndExchangeAcquire(0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long");
long x = (long) vh.get();
- assertEquals(x, 2L, "failing compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long value");
}
{
- long r = (long) vh.compareAndExchangeRelease(2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeRelease long");
+ long r = (long) vh.compareAndExchangeRelease(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeRelease long");
long x = (long) vh.get();
- assertEquals(x, 1L, "success compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeRelease long value");
}
{
- long r = (long) vh.compareAndExchangeRelease(2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeRelease long");
+ long r = (long) vh.compareAndExchangeRelease(0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long");
long x = (long) vh.get();
- assertEquals(x, 1L, "failing compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSet(1L, 2L);
+ success = vh.weakCompareAndSet(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSet long");
long x = (long) vh.get();
- assertEquals(x, 2L, "weakCompareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetAcquire(2L, 1L);
+ success = vh.weakCompareAndSetAcquire(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetAcquire long");
long x = (long) vh.get();
- assertEquals(x, 1L, "weakCompareAndSetAcquire long");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetAcquire long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetRelease(1L, 2L);
+ success = vh.weakCompareAndSetRelease(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSetRelease long");
long x = (long) vh.get();
- assertEquals(x, 2L, "weakCompareAndSetRelease long");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetRelease long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetRelease(2L, 1L);
+ success = vh.weakCompareAndSetRelease(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetVolatile long");
long x = (long) vh.get();
- assertEquals(x, 1L, "weakCompareAndSetVolatile long");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long");
}
// Compare set and get
{
- long o = (long) vh.getAndSet(2L);
- assertEquals(o, 1L, "getAndSet long");
+ long o = (long) vh.getAndSet(0xCAFEBABECAFEBABEL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long");
long x = (long) vh.get();
- assertEquals(x, 2L, "getAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value");
}
- vh.set(1L);
+ vh.set(0x0123456789ABCDEFL);
// get and add, add and get
{
- long o = (long) vh.getAndAdd( 3L);
- assertEquals(o, 1L, "getAndAdd long");
- long c = (long) vh.addAndGet(3L);
- assertEquals(c, 1L + 3L + 3L, "getAndAdd long value");
+ long o = (long) vh.getAndAdd( 0xDEADBEEFDEADBEEFL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long");
+ long c = (long) vh.addAndGet(0xDEADBEEFDEADBEEFL);
+ assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value");
}
}
@@ -624,148 +624,148 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- vh.set(array, i, 1L);
+ vh.set(array, i, 0x0123456789ABCDEFL);
long x = (long) vh.get(array, i);
- assertEquals(x, 1L, "get long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "get long value");
}
// Volatile
{
- vh.setVolatile(array, i, 2L);
+ vh.setVolatile(array, i, 0xCAFEBABECAFEBABEL);
long x = (long) vh.getVolatile(array, i);
- assertEquals(x, 2L, "setVolatile long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setVolatile long value");
}
// Lazy
{
- vh.setRelease(array, i, 1L);
+ vh.setRelease(array, i, 0x0123456789ABCDEFL);
long x = (long) vh.getAcquire(array, i);
- assertEquals(x, 1L, "setRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "setRelease long value");
}
// Opaque
{
- vh.setOpaque(array, i, 2L);
+ vh.setOpaque(array, i, 0xCAFEBABECAFEBABEL);
long x = (long) vh.getOpaque(array, i);
- assertEquals(x, 2L, "setOpaque long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setOpaque long value");
}
- vh.set(array, i, 1L);
+ vh.set(array, i, 0x0123456789ABCDEFL);
// Compare
{
- boolean r = vh.compareAndSet(array, i, 1L, 2L);
+ boolean r = vh.compareAndSet(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
assertEquals(r, true, "success compareAndSet long");
long x = (long) vh.get(array, i);
- assertEquals(x, 2L, "success compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSet long value");
}
{
- boolean r = vh.compareAndSet(array, i, 1L, 3L);
+ boolean r = vh.compareAndSet(array, i, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
assertEquals(r, false, "failing compareAndSet long");
long x = (long) vh.get(array, i);
- assertEquals(x, 2L, "failing compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSet long value");
}
{
- long r = (long) vh.compareAndExchangeVolatile(array, i, 2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeVolatile long");
+ long r = (long) vh.compareAndExchangeVolatile(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeVolatile long");
long x = (long) vh.get(array, i);
- assertEquals(x, 1L, "success compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeVolatile long value");
}
{
- long r = (long) vh.compareAndExchangeVolatile(array, i, 2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeVolatile long");
+ long r = (long) vh.compareAndExchangeVolatile(array, i, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long");
long x = (long) vh.get(array, i);
- assertEquals(x, 1L, "failing compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long value");
}
{
- long r = (long) vh.compareAndExchangeAcquire(array, i, 1L, 2L);
- assertEquals(r, 1L, "success compareAndExchangeAcquire long");
+ long r = (long) vh.compareAndExchangeAcquire(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+ assertEquals(r, 0x0123456789ABCDEFL, "success compareAndExchangeAcquire long");
long x = (long) vh.get(array, i);
- assertEquals(x, 2L, "success compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndExchangeAcquire long value");
}
{
- long r = (long) vh.compareAndExchangeAcquire(array, i, 1L, 3L);
- assertEquals(r, 2L, "failing compareAndExchangeAcquire long");
+ long r = (long) vh.compareAndExchangeAcquire(array, i, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long");
long x = (long) vh.get(array, i);
- assertEquals(x, 2L, "failing compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long value");
}
{
- long r = (long) vh.compareAndExchangeRelease(array, i, 2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeRelease long");
+ long r = (long) vh.compareAndExchangeRelease(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeRelease long");
long x = (long) vh.get(array, i);
- assertEquals(x, 1L, "success compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeRelease long value");
}
{
- long r = (long) vh.compareAndExchangeRelease(array, i, 2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeRelease long");
+ long r = (long) vh.compareAndExchangeRelease(array, i, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long");
long x = (long) vh.get(array, i);
- assertEquals(x, 1L, "failing compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSet(array, i, 1L, 2L);
+ success = vh.weakCompareAndSet(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSet long");
long x = (long) vh.get(array, i);
- assertEquals(x, 2L, "weakCompareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetAcquire(array, i, 2L, 1L);
+ success = vh.weakCompareAndSetAcquire(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetAcquire long");
long x = (long) vh.get(array, i);
- assertEquals(x, 1L, "weakCompareAndSetAcquire long");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetAcquire long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetRelease(array, i, 1L, 2L);
+ success = vh.weakCompareAndSetRelease(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSetRelease long");
long x = (long) vh.get(array, i);
- assertEquals(x, 2L, "weakCompareAndSetRelease long");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetRelease long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = vh.weakCompareAndSetVolatile(array, i, 2L, 1L);
+ success = vh.weakCompareAndSetVolatile(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetVolatile long");
long x = (long) vh.get(array, i);
- assertEquals(x, 1L, "weakCompareAndSetVolatile long");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long");
}
// Compare set and get
{
- long o = (long) vh.getAndSet(array, i, 2L);
- assertEquals(o, 1L, "getAndSet long");
+ long o = (long) vh.getAndSet(array, i, 0xCAFEBABECAFEBABEL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long");
long x = (long) vh.get(array, i);
- assertEquals(x, 2L, "getAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value");
}
- vh.set(array, i, 1L);
+ vh.set(array, i, 0x0123456789ABCDEFL);
// get and add, add and get
{
- long o = (long) vh.getAndAdd(array, i, 3L);
- assertEquals(o, 1L, "getAndAdd long");
- long c = (long) vh.addAndGet(array, i, 3L);
- assertEquals(c, 1L + 3L + 3L, "getAndAdd long value");
+ long o = (long) vh.getAndAdd(array, i, 0xDEADBEEFDEADBEEFL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long");
+ long c = (long) vh.addAndGet(array, i, 0xDEADBEEFDEADBEEFL);
+ assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value");
}
}
}
@@ -788,7 +788,7 @@
});
checkIOOBE(() -> {
- vh.set(array, ci, 1L);
+ vh.set(array, ci, 0x0123456789ABCDEFL);
});
checkIOOBE(() -> {
@@ -796,7 +796,7 @@
});
checkIOOBE(() -> {
- vh.setVolatile(array, ci, 1L);
+ vh.setVolatile(array, ci, 0x0123456789ABCDEFL);
});
checkIOOBE(() -> {
@@ -804,7 +804,7 @@
});
checkIOOBE(() -> {
- vh.setRelease(array, ci, 1L);
+ vh.setRelease(array, ci, 0x0123456789ABCDEFL);
});
checkIOOBE(() -> {
@@ -812,51 +812,51 @@
});
checkIOOBE(() -> {
- vh.setOpaque(array, ci, 1L);
+ vh.setOpaque(array, ci, 0x0123456789ABCDEFL);
});
checkIOOBE(() -> {
- boolean r = vh.compareAndSet(array, ci, 1L, 2L);
+ boolean r = vh.compareAndSet(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
});
checkIOOBE(() -> {
- long r = (long) vh.compareAndExchangeVolatile(array, ci, 2L, 1L);
+ long r = (long) vh.compareAndExchangeVolatile(array, ci, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
});
checkIOOBE(() -> {
- long r = (long) vh.compareAndExchangeAcquire(array, ci, 2L, 1L);
+ long r = (long) vh.compareAndExchangeAcquire(array, ci, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
});
checkIOOBE(() -> {
- long r = (long) vh.compareAndExchangeRelease(array, ci, 2L, 1L);
+ long r = (long) vh.compareAndExchangeRelease(array, ci, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
});
checkIOOBE(() -> {
- boolean r = vh.weakCompareAndSet(array, ci, 1L, 2L);
+ boolean r = vh.weakCompareAndSet(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
});
checkIOOBE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(array, ci, 1L, 2L);
+ boolean r = vh.weakCompareAndSetVolatile(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
});
checkIOOBE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(array, ci, 1L, 2L);
+ boolean r = vh.weakCompareAndSetAcquire(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
});
checkIOOBE(() -> {
- boolean r = vh.weakCompareAndSetRelease(array, ci, 1L, 2L);
+ boolean r = vh.weakCompareAndSetRelease(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
});
checkIOOBE(() -> {
- long o = (long) vh.getAndSet(array, ci, 1L);
+ long o = (long) vh.getAndSet(array, ci, 0x0123456789ABCDEFL);
});
checkIOOBE(() -> {
- long o = (long) vh.getAndAdd(array, ci, 3L);
+ long o = (long) vh.getAndAdd(array, ci, 0xDEADBEEFDEADBEEFL);
});
checkIOOBE(() -> {
- long o = (long) vh.addAndGet(array, ci, 3L);
+ long o = (long) vh.addAndGet(array, ci, 0xDEADBEEFDEADBEEFL);
});
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java Wed Jun 15 11:20:15 2016 +0300
@@ -42,11 +42,11 @@
import static org.testng.Assert.*;
public class VarHandleTestAccessShort extends VarHandleBaseTest {
- static final short static_final_v = (short)1;
+ static final short static_final_v = (short)0x0123;
static short static_v;
- final short final_v = (short)1;
+ final short final_v = (short)0x0123;
short v;
@@ -99,18 +99,18 @@
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_OPAQUE));
assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.SET_OPAQUE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
- assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD));
+ assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.ADD_AND_GET));
}
@@ -220,89 +220,47 @@
// Plain
{
short x = (short) vh.get(recv);
- assertEquals(x, (short)1, "get short value");
+ assertEquals(x, (short)0x0123, "get short value");
}
// Volatile
{
short x = (short) vh.getVolatile(recv);
- assertEquals(x, (short)1, "getVolatile short value");
+ assertEquals(x, (short)0x0123, "getVolatile short value");
}
// Lazy
{
short x = (short) vh.getAcquire(recv);
- assertEquals(x, (short)1, "getRelease short value");
+ assertEquals(x, (short)0x0123, "getRelease short value");
}
// Opaque
{
short x = (short) vh.getOpaque(recv);
- assertEquals(x, (short)1, "getOpaque short value");
+ assertEquals(x, (short)0x0123, "getOpaque short value");
}
}
static void testInstanceFinalFieldUnsupported(VarHandleTestAccessShort recv, VarHandle vh) {
checkUOE(() -> {
- vh.set(recv, (short)2);
- });
-
- checkUOE(() -> {
- vh.setVolatile(recv, (short)2);
- });
-
- checkUOE(() -> {
- vh.setRelease(recv, (short)2);
+ vh.set(recv, (short)0x4567);
});
checkUOE(() -> {
- vh.setOpaque(recv, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.compareAndSet(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeVolatile(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeAcquire(recv, (short)1, (short)2);
+ vh.setVolatile(recv, (short)0x4567);
});
checkUOE(() -> {
- short r = (short) vh.compareAndExchangeRelease(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(recv, (short)1, (short)2);
+ vh.setRelease(recv, (short)0x4567);
});
checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(recv, (short)1, (short)2);
+ vh.setOpaque(recv, (short)0x4567);
});
- checkUOE(() -> {
- short r = (short) vh.getAndSet(recv, (short)1);
- });
- checkUOE(() -> {
- short o = (short) vh.getAndAdd(recv, (short)1);
- });
-
- checkUOE(() -> {
- short o = (short) vh.addAndGet(recv, (short)1);
- });
}
@@ -310,249 +268,353 @@
// Plain
{
short x = (short) vh.get();
- assertEquals(x, (short)1, "get short value");
+ assertEquals(x, (short)0x0123, "get short value");
}
// Volatile
{
short x = (short) vh.getVolatile();
- assertEquals(x, (short)1, "getVolatile short value");
+ assertEquals(x, (short)0x0123, "getVolatile short value");
}
// Lazy
{
short x = (short) vh.getAcquire();
- assertEquals(x, (short)1, "getRelease short value");
+ assertEquals(x, (short)0x0123, "getRelease short value");
}
// Opaque
{
short x = (short) vh.getOpaque();
- assertEquals(x, (short)1, "getOpaque short value");
+ assertEquals(x, (short)0x0123, "getOpaque short value");
}
}
static void testStaticFinalFieldUnsupported(VarHandle vh) {
checkUOE(() -> {
- vh.set((short)2);
- });
-
- checkUOE(() -> {
- vh.setVolatile((short)2);
- });
-
- checkUOE(() -> {
- vh.setRelease((short)2);
+ vh.set((short)0x4567);
});
checkUOE(() -> {
- vh.setOpaque((short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.compareAndSet((short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeVolatile((short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeAcquire((short)1, (short)2);
+ vh.setVolatile((short)0x4567);
});
checkUOE(() -> {
- short r = (short) vh.compareAndExchangeRelease((short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet((short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile((short)1, (short)2);
+ vh.setRelease((short)0x4567);
});
checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire((short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease((short)1, (short)2);
+ vh.setOpaque((short)0x4567);
});
- checkUOE(() -> {
- short r = (short) vh.getAndSet((short)1);
- });
- checkUOE(() -> {
- short o = (short) vh.getAndAdd((short)1);
- });
-
- checkUOE(() -> {
- short o = (short) vh.addAndGet((short)1);
- });
}
static void testInstanceField(VarHandleTestAccessShort recv, VarHandle vh) {
// Plain
{
- vh.set(recv, (short)1);
+ vh.set(recv, (short)0x0123);
short x = (short) vh.get(recv);
- assertEquals(x, (short)1, "set short value");
+ assertEquals(x, (short)0x0123, "set short value");
}
// Volatile
{
- vh.setVolatile(recv, (short)2);
+ vh.setVolatile(recv, (short)0x4567);
short x = (short) vh.getVolatile(recv);
- assertEquals(x, (short)2, "setVolatile short value");
+ assertEquals(x, (short)0x4567, "setVolatile short value");
}
// Lazy
{
- vh.setRelease(recv, (short)1);
+ vh.setRelease(recv, (short)0x0123);
short x = (short) vh.getAcquire(recv);
- assertEquals(x, (short)1, "setRelease short value");
+ assertEquals(x, (short)0x0123, "setRelease short value");
}
// Opaque
{
- vh.setOpaque(recv, (short)2);
+ vh.setOpaque(recv, (short)0x4567);
short x = (short) vh.getOpaque(recv);
- assertEquals(x, (short)2, "setOpaque short value");
+ assertEquals(x, (short)0x4567, "setOpaque short value");
+ }
+
+ vh.set(recv, (short)0x0123);
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet(recv, (short)0x0123, (short)0x4567);
+ assertEquals(r, true, "success compareAndSet short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x4567, "success compareAndSet short value");
+ }
+
+ {
+ boolean r = vh.compareAndSet(recv, (short)0x0123, (short)0x89AB);
+ assertEquals(r, false, "failing compareAndSet short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x4567, "failing compareAndSet short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeVolatile(recv, (short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeVolatile short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x0123, "success compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeVolatile(recv, (short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeVolatile short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeAcquire(recv, (short)0x0123, (short)0x4567);
+ assertEquals(r, (short)0x0123, "success compareAndExchangeAcquire short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x4567, "success compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeAcquire(recv, (short)0x0123, (short)0x89AB);
+ assertEquals(r, (short)0x4567, "failing compareAndExchangeAcquire short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x4567, "failing compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeRelease(recv, (short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeRelease short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x0123, "success compareAndExchangeRelease short value");
}
+ {
+ short r = (short) vh.compareAndExchangeRelease(recv, (short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeRelease short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeRelease short value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet(recv, (short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSet short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x4567, "weakCompareAndSet short value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire(recv, (short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x0123, "weakCompareAndSetAcquire short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease(recv, (short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x4567, "weakCompareAndSetRelease short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetVolatile(recv, (short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short value");
+ }
+
+ // Compare set and get
+ {
+ short o = (short) vh.getAndSet(recv, (short)0x4567);
+ assertEquals(o, (short)0x0123, "getAndSet short");
+ short x = (short) vh.get(recv);
+ assertEquals(x, (short)0x4567, "getAndSet short value");
+ }
+
+ vh.set(recv, (short)0x0123);
+
+ // get and add, add and get
+ {
+ short o = (short) vh.getAndAdd(recv, (short)0x89AB);
+ assertEquals(o, (short)0x0123, "getAndAdd short");
+ short c = (short) vh.addAndGet(recv, (short)0x89AB);
+ assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value");
+ }
}
static void testInstanceFieldUnsupported(VarHandleTestAccessShort recv, VarHandle vh) {
- checkUOE(() -> {
- boolean r = vh.compareAndSet(recv, (short)1, (short)2);
- });
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeVolatile(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeAcquire(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeRelease(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(recv, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.getAndSet(recv, (short)1);
- });
-
- checkUOE(() -> {
- short o = (short) vh.getAndAdd(recv, (short)1);
- });
-
- checkUOE(() -> {
- short o = (short) vh.addAndGet(recv, (short)1);
- });
}
static void testStaticField(VarHandle vh) {
// Plain
{
- vh.set((short)1);
+ vh.set((short)0x0123);
short x = (short) vh.get();
- assertEquals(x, (short)1, "set short value");
+ assertEquals(x, (short)0x0123, "set short value");
}
// Volatile
{
- vh.setVolatile((short)2);
+ vh.setVolatile((short)0x4567);
short x = (short) vh.getVolatile();
- assertEquals(x, (short)2, "setVolatile short value");
+ assertEquals(x, (short)0x4567, "setVolatile short value");
}
// Lazy
{
- vh.setRelease((short)1);
+ vh.setRelease((short)0x0123);
short x = (short) vh.getAcquire();
- assertEquals(x, (short)1, "setRelease short value");
+ assertEquals(x, (short)0x0123, "setRelease short value");
}
// Opaque
{
- vh.setOpaque((short)2);
+ vh.setOpaque((short)0x4567);
short x = (short) vh.getOpaque();
- assertEquals(x, (short)2, "setOpaque short value");
+ assertEquals(x, (short)0x4567, "setOpaque short value");
+ }
+
+ vh.set((short)0x0123);
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet((short)0x0123, (short)0x4567);
+ assertEquals(r, true, "success compareAndSet short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x4567, "success compareAndSet short value");
+ }
+
+ {
+ boolean r = vh.compareAndSet((short)0x0123, (short)0x89AB);
+ assertEquals(r, false, "failing compareAndSet short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x4567, "failing compareAndSet short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeVolatile((short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeVolatile short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x0123, "success compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeVolatile((short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeVolatile short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeAcquire((short)0x0123, (short)0x4567);
+ assertEquals(r, (short)0x0123, "success compareAndExchangeAcquire short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x4567, "success compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeAcquire((short)0x0123, (short)0x89AB);
+ assertEquals(r, (short)0x4567, "failing compareAndExchangeAcquire short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x4567, "failing compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeRelease((short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeRelease short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x0123, "success compareAndExchangeRelease short value");
}
+ {
+ short r = (short) vh.compareAndExchangeRelease((short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeRelease short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeRelease short value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet((short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSet short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x4567, "weakCompareAndSet short value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire((short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x0123, "weakCompareAndSetAcquire short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease((short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x4567, "weakCompareAndSetRelease short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease((short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short");
+ }
+
+ // Compare set and get
+ {
+ short o = (short) vh.getAndSet((short)0x4567);
+ assertEquals(o, (short)0x0123, "getAndSet short");
+ short x = (short) vh.get();
+ assertEquals(x, (short)0x4567, "getAndSet short value");
+ }
+
+ vh.set((short)0x0123);
+
+ // get and add, add and get
+ {
+ short o = (short) vh.getAndAdd( (short)0x89AB);
+ assertEquals(o, (short)0x0123, "getAndAdd short");
+ short c = (short) vh.addAndGet((short)0x89AB);
+ assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value");
+ }
}
static void testStaticFieldUnsupported(VarHandle vh) {
- checkUOE(() -> {
- boolean r = vh.compareAndSet((short)1, (short)2);
- });
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeVolatile((short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeAcquire((short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeRelease((short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet((short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile((short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire((short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease((short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.getAndSet((short)1);
- });
-
- checkUOE(() -> {
- short o = (short) vh.getAndAdd((short)1);
- });
-
- checkUOE(() -> {
- short o = (short) vh.addAndGet((short)1);
- });
}
@@ -562,34 +624,149 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- vh.set(array, i, (short)1);
+ vh.set(array, i, (short)0x0123);
short x = (short) vh.get(array, i);
- assertEquals(x, (short)1, "get short value");
+ assertEquals(x, (short)0x0123, "get short value");
}
// Volatile
{
- vh.setVolatile(array, i, (short)2);
+ vh.setVolatile(array, i, (short)0x4567);
short x = (short) vh.getVolatile(array, i);
- assertEquals(x, (short)2, "setVolatile short value");
+ assertEquals(x, (short)0x4567, "setVolatile short value");
}
// Lazy
{
- vh.setRelease(array, i, (short)1);
+ vh.setRelease(array, i, (short)0x0123);
short x = (short) vh.getAcquire(array, i);
- assertEquals(x, (short)1, "setRelease short value");
+ assertEquals(x, (short)0x0123, "setRelease short value");
}
// Opaque
{
- vh.setOpaque(array, i, (short)2);
+ vh.setOpaque(array, i, (short)0x4567);
short x = (short) vh.getOpaque(array, i);
- assertEquals(x, (short)2, "setOpaque short value");
+ assertEquals(x, (short)0x4567, "setOpaque short value");
+ }
+
+ vh.set(array, i, (short)0x0123);
+
+ // Compare
+ {
+ boolean r = vh.compareAndSet(array, i, (short)0x0123, (short)0x4567);
+ assertEquals(r, true, "success compareAndSet short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x4567, "success compareAndSet short value");
+ }
+
+ {
+ boolean r = vh.compareAndSet(array, i, (short)0x0123, (short)0x89AB);
+ assertEquals(r, false, "failing compareAndSet short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x4567, "failing compareAndSet short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeVolatile(array, i, (short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeVolatile short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x0123, "success compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeVolatile(array, i, (short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeVolatile short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeAcquire(array, i, (short)0x0123, (short)0x4567);
+ assertEquals(r, (short)0x0123, "success compareAndExchangeAcquire short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x4567, "success compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeAcquire(array, i, (short)0x0123, (short)0x89AB);
+ assertEquals(r, (short)0x4567, "failing compareAndExchangeAcquire short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x4567, "failing compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) vh.compareAndExchangeRelease(array, i, (short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeRelease short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x0123, "success compareAndExchangeRelease short value");
}
+ {
+ short r = (short) vh.compareAndExchangeRelease(array, i, (short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeRelease short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeRelease short value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSet(array, i, (short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSet short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x4567, "weakCompareAndSet short value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetAcquire(array, i, (short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x0123, "weakCompareAndSetAcquire short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetRelease(array, i, (short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x4567, "weakCompareAndSetRelease short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = vh.weakCompareAndSetVolatile(array, i, (short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short");
+ }
+
+ // Compare set and get
+ {
+ short o = (short) vh.getAndSet(array, i, (short)0x4567);
+ assertEquals(o, (short)0x0123, "getAndSet short");
+ short x = (short) vh.get(array, i);
+ assertEquals(x, (short)0x4567, "getAndSet short value");
+ }
+
+ vh.set(array, i, (short)0x0123);
+
+ // get and add, add and get
+ {
+ short o = (short) vh.getAndAdd(array, i, (short)0x89AB);
+ assertEquals(o, (short)0x0123, "getAndAdd short");
+ short c = (short) vh.addAndGet(array, i, (short)0x89AB);
+ assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value");
+ }
}
}
@@ -597,49 +774,7 @@
short[] array = new short[10];
int i = 0;
- checkUOE(() -> {
- boolean r = vh.compareAndSet(array, i, (short)1, (short)2);
- });
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeVolatile(array, i, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeAcquire(array, i, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.compareAndExchangeRelease(array, i, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSet(array, i, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetVolatile(array, i, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetAcquire(array, i, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- boolean r = vh.weakCompareAndSetRelease(array, i, (short)1, (short)2);
- });
-
- checkUOE(() -> {
- short r = (short) vh.getAndSet(array, i, (short)1);
- });
-
- checkUOE(() -> {
- short o = (short) vh.getAndAdd(array, i, (short)1);
- });
-
- checkUOE(() -> {
- short o = (short) vh.addAndGet(array, i, (short)1);
- });
}
static void testArrayIndexOutOfBounds(VarHandle vh) throws Throwable {
@@ -653,7 +788,7 @@
});
checkIOOBE(() -> {
- vh.set(array, ci, (short)1);
+ vh.set(array, ci, (short)0x0123);
});
checkIOOBE(() -> {
@@ -661,7 +796,7 @@
});
checkIOOBE(() -> {
- vh.setVolatile(array, ci, (short)1);
+ vh.setVolatile(array, ci, (short)0x0123);
});
checkIOOBE(() -> {
@@ -669,7 +804,7 @@
});
checkIOOBE(() -> {
- vh.setRelease(array, ci, (short)1);
+ vh.setRelease(array, ci, (short)0x0123);
});
checkIOOBE(() -> {
@@ -677,10 +812,52 @@
});
checkIOOBE(() -> {
- vh.setOpaque(array, ci, (short)1);
+ vh.setOpaque(array, ci, (short)0x0123);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.compareAndSet(array, ci, (short)0x0123, (short)0x4567);
+ });
+
+ checkIOOBE(() -> {
+ short r = (short) vh.compareAndExchangeVolatile(array, ci, (short)0x4567, (short)0x0123);
+ });
+
+ checkIOOBE(() -> {
+ short r = (short) vh.compareAndExchangeAcquire(array, ci, (short)0x4567, (short)0x0123);
+ });
+
+ checkIOOBE(() -> {
+ short r = (short) vh.compareAndExchangeRelease(array, ci, (short)0x4567, (short)0x0123);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSet(array, ci, (short)0x0123, (short)0x4567);
});
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetVolatile(array, ci, (short)0x0123, (short)0x4567);
+ });
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetAcquire(array, ci, (short)0x0123, (short)0x4567);
+ });
+
+ checkIOOBE(() -> {
+ boolean r = vh.weakCompareAndSetRelease(array, ci, (short)0x0123, (short)0x4567);
+ });
+
+ checkIOOBE(() -> {
+ short o = (short) vh.getAndSet(array, ci, (short)0x0123);
+ });
+
+ checkIOOBE(() -> {
+ short o = (short) vh.getAndAdd(array, ci, (short)0x89AB);
+ });
+
+ checkIOOBE(() -> {
+ short o = (short) vh.addAndGet(array, ci, (short)0x89AB);
+ });
}
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java Wed Jun 15 11:20:15 2016 +0300
@@ -148,27 +148,116 @@
assertEquals(x, false, "setOpaque boolean value");
}
+ hs.get(TestAccessMode.SET).invokeExact(recv, true);
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, true, false);
+ assertEquals(r, true, "success compareAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, false, "success compareAndSet boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, true, false);
+ assertEquals(r, false, "failing compareAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, false, "failing compareAndSet boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, false, true);
+ assertEquals(r, false, "success compareAndExchangeVolatile boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, true, "success compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, false, false);
+ assertEquals(r, true, "failing compareAndExchangeVolatile boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, true, "failing compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, true, false);
+ assertEquals(r, true, "success compareAndExchangeAcquire boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, false, "success compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, true, false);
+ assertEquals(r, false, "failing compareAndExchangeAcquire boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, false, "failing compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, false, true);
+ assertEquals(r, false, "success compareAndExchangeRelease boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, true, "success compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, false, false);
+ assertEquals(r, true, "failing compareAndExchangeRelease boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, true, "failing compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, false, "weakCompareAndSet boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, true, "weakCompareAndSetAcquire boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, false, "weakCompareAndSetRelease boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, true, "weakCompareAndSetVolatile boolean");
+ }
+
+ // Compare set and get
+ {
+ boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, false);
+ assertEquals(o, true, "getAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, false, "getAndSet boolean value");
+ }
}
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessBoolean recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(recv, true, false);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(recv, true, false);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(recv, true);
- });
- }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
@@ -208,27 +297,116 @@
assertEquals(x, false, "setOpaque boolean value");
}
+ hs.get(TestAccessMode.SET).invokeExact(true);
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(true, false);
+ assertEquals(r, true, "success compareAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, false, "success compareAndSet boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(true, false);
+ assertEquals(r, false, "failing compareAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, false, "failing compareAndSet boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(false, true);
+ assertEquals(r, false, "success compareAndExchangeVolatile boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, true, "success compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(false, false);
+ assertEquals(r, true, "failing compareAndExchangeVolatile boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, true, "failing compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(true, false);
+ assertEquals(r, true, "success compareAndExchangeAcquire boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, false, "success compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(true, false);
+ assertEquals(r, false, "failing compareAndExchangeAcquire boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, false, "failing compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(false, true);
+ assertEquals(r, false, "success compareAndExchangeRelease boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, true, "success compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(false, false);
+ assertEquals(r, true, "failing compareAndExchangeRelease boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, true, "failing compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, false, "weakCompareAndSet boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, true, "weakCompareAndSetAcquire boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, false, "weakCompareAndSetRelease boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, true, "weakCompareAndSetVolatile boolean");
+ }
+
+ // Compare set and get
+ {
+ boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact( false);
+ assertEquals(o, true, "getAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, false, "getAndSet boolean value");
+ }
}
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(true, false);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(true, false);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(true);
- });
- }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
@@ -271,6 +449,112 @@
assertEquals(x, false, "setOpaque boolean value");
}
+ hs.get(TestAccessMode.SET).invokeExact(array, i, true);
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, true, false);
+ assertEquals(r, true, "success compareAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, false, "success compareAndSet boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, true, false);
+ assertEquals(r, false, "failing compareAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, false, "failing compareAndSet boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, false, true);
+ assertEquals(r, false, "success compareAndExchangeVolatile boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, true, "success compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, false, false);
+ assertEquals(r, true, "failing compareAndExchangeVolatile boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, true, "failing compareAndExchangeVolatile boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, true, false);
+ assertEquals(r, true, "success compareAndExchangeAcquire boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, false, "success compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, true, false);
+ assertEquals(r, false, "failing compareAndExchangeAcquire boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, false, "failing compareAndExchangeAcquire boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, false, true);
+ assertEquals(r, false, "success compareAndExchangeRelease boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, true, "success compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, false, false);
+ assertEquals(r, true, "failing compareAndExchangeRelease boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, true, "failing compareAndExchangeRelease boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, false, "weakCompareAndSet boolean value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, true, "weakCompareAndSetAcquire boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, true, false);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, false, "weakCompareAndSetRelease boolean");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, false, true);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, true, "weakCompareAndSetVolatile boolean");
+ }
+
+ // Compare set and get
+ {
+ boolean o = (boolean) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, false);
+ assertEquals(o, true, "getAndSet boolean");
+ boolean x = (boolean) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, false, "getAndSet boolean value");
+ }
}
}
@@ -279,23 +563,6 @@
boolean[] array = new boolean[10];
final int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(array, i, true, false);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(array, i, true, false);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(array, i, true);
- });
- }
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkUOE(am, () -> {
@@ -322,6 +589,23 @@
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
+ checkIOOBE(am, () -> {
+ boolean r = (boolean) hs.get(am).invokeExact(array, ci, true, false);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ checkIOOBE(am, () -> {
+ boolean r = (boolean) hs.get(am).invokeExact(array, ci, false, true);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ checkIOOBE(am, () -> {
+ boolean o = (boolean) hs.get(am).invokeExact(array, ci, true);
+ });
+ }
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java Wed Jun 15 11:20:15 2016 +0300
@@ -39,11 +39,11 @@
import static org.testng.Assert.*;
public class VarHandleTestMethodHandleAccessByte extends VarHandleBaseTest {
- static final byte static_final_v = (byte)1;
+ static final byte static_final_v = (byte)0x01;
static byte static_v;
- final byte final_v = (byte)1;
+ final byte final_v = (byte)0x01;
byte v;
@@ -121,120 +121,306 @@
static void testInstanceField(VarHandleTestMethodHandleAccessByte recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(recv, (byte)1);
+ hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01);
byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, (byte)1, "set byte value");
+ assertEquals(x, (byte)0x01, "set byte value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, (byte)2);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, (byte)0x23);
byte x = (byte) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
- assertEquals(x, (byte)2, "setVolatile byte value");
+ assertEquals(x, (byte)0x23, "setVolatile byte value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, (byte)1);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, (byte)0x01);
byte x = (byte) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
- assertEquals(x, (byte)1, "setRelease byte value");
+ assertEquals(x, (byte)0x01, "setRelease byte value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, (byte)2);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, (byte)0x23);
byte x = (byte) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
- assertEquals(x, (byte)2, "setOpaque byte value");
+ assertEquals(x, (byte)0x23, "setOpaque byte value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01);
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, (byte)0x01, (byte)0x23);
+ assertEquals(r, true, "success compareAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x23, "success compareAndSet byte value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, (byte)0x01, (byte)0x45);
+ assertEquals(r, false, "failing compareAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x23, "failing compareAndSet byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, (byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeVolatile byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x01, "success compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, (byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeVolatile byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, (byte)0x01, (byte)0x23);
+ assertEquals(r, (byte)0x01, "success compareAndExchangeAcquire byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x23, "success compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, (byte)0x01, (byte)0x45);
+ assertEquals(r, (byte)0x23, "failing compareAndExchangeAcquire byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x23, "failing compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, (byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeRelease byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x01, "success compareAndExchangeRelease byte value");
}
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, (byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeRelease byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeRelease byte value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, (byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x23, "weakCompareAndSet byte value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, (byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x01, "weakCompareAndSetAcquire byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, (byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x23, "weakCompareAndSetRelease byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, (byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte");
+ }
+
+ // Compare set and get
+ {
+ byte o = (byte) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, (byte)0x23);
+ assertEquals(o, (byte)0x01, "getAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (byte)0x23, "getAndSet byte value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(recv, (byte)0x01);
+
+ // get and add, add and get
+ {
+ byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (byte)0x45);
+ assertEquals(o, (byte)0x01, "getAndAdd byte");
+ byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, (byte)0x45);
+ assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value");
+ }
}
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessByte recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(recv, (byte)1, (byte)2);
- });
- }
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- byte r = (byte) hs.get(am).invokeExact(recv, (byte)1, (byte)2);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- byte r = (byte) hs.get(am).invokeExact(recv, (byte)1);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
- checkUOE(am, () -> {
- byte r = (byte) hs.get(am).invokeExact(recv, (byte)1);
- });
- }
}
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact((byte)1);
+ hs.get(TestAccessMode.SET).invokeExact((byte)0x01);
byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, (byte)1, "set byte value");
+ assertEquals(x, (byte)0x01, "set byte value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact((byte)2);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact((byte)0x23);
byte x = (byte) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
- assertEquals(x, (byte)2, "setVolatile byte value");
+ assertEquals(x, (byte)0x23, "setVolatile byte value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact((byte)1);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact((byte)0x01);
byte x = (byte) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
- assertEquals(x, (byte)1, "setRelease byte value");
+ assertEquals(x, (byte)0x01, "setRelease byte value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact((byte)2);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact((byte)0x23);
byte x = (byte) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
- assertEquals(x, (byte)2, "setOpaque byte value");
+ assertEquals(x, (byte)0x23, "setOpaque byte value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact((byte)0x01);
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact((byte)0x01, (byte)0x23);
+ assertEquals(r, true, "success compareAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x23, "success compareAndSet byte value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact((byte)0x01, (byte)0x45);
+ assertEquals(r, false, "failing compareAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x23, "failing compareAndSet byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact((byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeVolatile byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x01, "success compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact((byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeVolatile byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact((byte)0x01, (byte)0x23);
+ assertEquals(r, (byte)0x01, "success compareAndExchangeAcquire byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x23, "success compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact((byte)0x01, (byte)0x45);
+ assertEquals(r, (byte)0x23, "failing compareAndExchangeAcquire byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x23, "failing compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact((byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeRelease byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x01, "success compareAndExchangeRelease byte value");
}
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact((byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeRelease byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeRelease byte value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact((byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x23, "weakCompareAndSet byte value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact((byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x01, "weakCompareAndSetAcquire byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact((byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x23, "weakCompareAndSetRelease byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact((byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte");
+ }
+
+ // Compare set and get
+ {
+ byte o = (byte) hs.get(TestAccessMode.GET_AND_SET).invokeExact( (byte)0x23);
+ assertEquals(o, (byte)0x01, "getAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (byte)0x23, "getAndSet byte value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact((byte)0x01);
+
+ // get and add, add and get
+ {
+ byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( (byte)0x45);
+ assertEquals(o, (byte)0x01, "getAndAdd byte");
+ byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact((byte)0x45);
+ assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value");
+ }
}
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact((byte)1, (byte)2);
- });
- }
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- byte r = (byte) hs.get(am).invokeExact((byte)1, (byte)2);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- byte r = (byte) hs.get(am).invokeExact((byte)1);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
- checkUOE(am, () -> {
- byte r = (byte) hs.get(am).invokeExact((byte)1);
- });
- }
}
@@ -244,34 +430,149 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)1);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01);
byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, (byte)1, "get byte value");
+ assertEquals(x, (byte)0x01, "get byte value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, (byte)2);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, (byte)0x23);
byte x = (byte) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
- assertEquals(x, (byte)2, "setVolatile byte value");
+ assertEquals(x, (byte)0x23, "setVolatile byte value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, (byte)1);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, (byte)0x01);
byte x = (byte) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
- assertEquals(x, (byte)1, "setRelease byte value");
+ assertEquals(x, (byte)0x01, "setRelease byte value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, (byte)2);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, (byte)0x23);
byte x = (byte) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
- assertEquals(x, (byte)2, "setOpaque byte value");
+ assertEquals(x, (byte)0x23, "setOpaque byte value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01);
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, (byte)0x01, (byte)0x23);
+ assertEquals(r, true, "success compareAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x23, "success compareAndSet byte value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, (byte)0x01, (byte)0x45);
+ assertEquals(r, false, "failing compareAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x23, "failing compareAndSet byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, (byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeVolatile byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x01, "success compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, (byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeVolatile byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeVolatile byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, (byte)0x01, (byte)0x23);
+ assertEquals(r, (byte)0x01, "success compareAndExchangeAcquire byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x23, "success compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, (byte)0x01, (byte)0x45);
+ assertEquals(r, (byte)0x23, "failing compareAndExchangeAcquire byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x23, "failing compareAndExchangeAcquire byte value");
+ }
+
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, (byte)0x23, (byte)0x01);
+ assertEquals(r, (byte)0x23, "success compareAndExchangeRelease byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x01, "success compareAndExchangeRelease byte value");
}
+ {
+ byte r = (byte) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, (byte)0x23, (byte)0x45);
+ assertEquals(r, (byte)0x01, "failing compareAndExchangeRelease byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x01, "failing compareAndExchangeRelease byte value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, (byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x23, "weakCompareAndSet byte value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, (byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x01, "weakCompareAndSetAcquire byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, (byte)0x01, (byte)0x23);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x23, "weakCompareAndSetRelease byte");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, (byte)0x23, (byte)0x01);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x01, "weakCompareAndSetVolatile byte");
+ }
+
+ // Compare set and get
+ {
+ byte o = (byte) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, (byte)0x23);
+ assertEquals(o, (byte)0x01, "getAndSet byte");
+ byte x = (byte) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (byte)0x23, "getAndSet byte value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(array, i, (byte)0x01);
+
+ // get and add, add and get
+ {
+ byte o = (byte) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (byte)0x45);
+ assertEquals(o, (byte)0x01, "getAndAdd byte");
+ byte c = (byte) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, (byte)0x45);
+ assertEquals(c, (byte)((byte)0x01 + (byte)0x45 + (byte)0x45), "getAndAdd byte value");
+ }
}
}
@@ -279,29 +580,7 @@
byte[] array = new byte[10];
final int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(array, i, (byte)1, (byte)2);
- });
- }
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- byte r = (byte) hs.get(am).invokeExact(array, i, (byte)1, (byte)2);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- byte r = (byte) hs.get(am).invokeExact(array, i, (byte)1);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
- checkUOE(am, () -> {
- byte o = (byte) hs.get(am).invokeExact(array, i, (byte)1);
- });
- }
}
static void testArrayIndexOutOfBounds(Handles hs) throws Throwable {
@@ -318,11 +597,33 @@
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
- hs.get(am).invokeExact(array, ci, (byte)1);
+ hs.get(am).invokeExact(array, ci, (byte)0x01);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
+ checkIOOBE(am, () -> {
+ boolean r = (boolean) hs.get(am).invokeExact(array, ci, (byte)0x01, (byte)0x23);
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ checkIOOBE(am, () -> {
+ byte r = (byte) hs.get(am).invokeExact(array, ci, (byte)0x23, (byte)0x01);
+ });
+ }
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ checkIOOBE(am, () -> {
+ byte o = (byte) hs.get(am).invokeExact(array, ci, (byte)0x01);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ checkIOOBE(am, () -> {
+ byte o = (byte) hs.get(am).invokeExact(array, ci, (byte)0x45);
+ });
+ }
}
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java Wed Jun 15 11:20:15 2016 +0300
@@ -39,11 +39,11 @@
import static org.testng.Assert.*;
public class VarHandleTestMethodHandleAccessChar extends VarHandleBaseTest {
- static final char static_final_v = 'a';
+ static final char static_final_v = '\u0123';
static char static_v;
- final char final_v = 'a';
+ final char final_v = '\u0123';
char v;
@@ -121,120 +121,306 @@
static void testInstanceField(VarHandleTestMethodHandleAccessChar recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(recv, 'a');
+ hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 'a', "set char value");
+ assertEquals(x, '\u0123', "set char value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, 'b');
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, '\u4567');
char x = (char) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
- assertEquals(x, 'b', "setVolatile char value");
+ assertEquals(x, '\u4567', "setVolatile char value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, 'a');
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, '\u0123');
char x = (char) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
- assertEquals(x, 'a', "setRelease char value");
+ assertEquals(x, '\u0123', "setRelease char value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, 'b');
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, '\u4567');
char x = (char) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
- assertEquals(x, 'b', "setOpaque char value");
+ assertEquals(x, '\u4567', "setOpaque char value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, '\u0123', '\u4567');
+ assertEquals(r, true, "success compareAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u4567', "success compareAndSet char value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, '\u0123', '\u89AB');
+ assertEquals(r, false, "failing compareAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u4567', "failing compareAndSet char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, '\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeVolatile char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u0123', "success compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, '\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeVolatile char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u0123', "failing compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, '\u0123', '\u4567');
+ assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, '\u0123', '\u89AB');
+ assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, '\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
}
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, '\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, '\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u4567', "weakCompareAndSet char value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, '\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u0123', "weakCompareAndSetAcquire char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, '\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u4567', "weakCompareAndSetRelease char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, '\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u0123', "weakCompareAndSetVolatile char");
+ }
+
+ // Compare set and get
+ {
+ char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, '\u4567');
+ assertEquals(o, '\u0123', "getAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, '\u4567', "getAndSet char value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(recv, '\u0123');
+
+ // get and add, add and get
+ {
+ char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, '\u89AB');
+ assertEquals(o, '\u0123', "getAndAdd char");
+ char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, '\u89AB');
+ assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value");
+ }
}
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessChar recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(recv, 'a', 'b');
- });
- }
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- char r = (char) hs.get(am).invokeExact(recv, 'a', 'b');
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- char r = (char) hs.get(am).invokeExact(recv, 'a');
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
- checkUOE(am, () -> {
- char r = (char) hs.get(am).invokeExact(recv, 'a');
- });
- }
}
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact('a');
+ hs.get(TestAccessMode.SET).invokeExact('\u0123');
char x = (char) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 'a', "set char value");
+ assertEquals(x, '\u0123', "set char value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact('b');
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact('\u4567');
char x = (char) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
- assertEquals(x, 'b', "setVolatile char value");
+ assertEquals(x, '\u4567', "setVolatile char value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact('a');
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact('\u0123');
char x = (char) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
- assertEquals(x, 'a', "setRelease char value");
+ assertEquals(x, '\u0123', "setRelease char value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact('b');
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact('\u4567');
char x = (char) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
- assertEquals(x, 'b', "setOpaque char value");
+ assertEquals(x, '\u4567', "setOpaque char value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact('\u0123');
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact('\u0123', '\u4567');
+ assertEquals(r, true, "success compareAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u4567', "success compareAndSet char value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact('\u0123', '\u89AB');
+ assertEquals(r, false, "failing compareAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u4567', "failing compareAndSet char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact('\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeVolatile char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u0123', "success compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact('\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeVolatile char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u0123', "failing compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact('\u0123', '\u4567');
+ assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact('\u0123', '\u89AB');
+ assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact('\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
}
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact('\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact('\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u4567', "weakCompareAndSet char value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact('\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u0123', "weakCompareAndSetAcquire char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact('\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u4567', "weakCompareAndSetRelease char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact('\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u0123', "weakCompareAndSetVolatile char");
+ }
+
+ // Compare set and get
+ {
+ char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact( '\u4567');
+ assertEquals(o, '\u0123', "getAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, '\u4567', "getAndSet char value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact('\u0123');
+
+ // get and add, add and get
+ {
+ char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( '\u89AB');
+ assertEquals(o, '\u0123', "getAndAdd char");
+ char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact('\u89AB');
+ assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value");
+ }
}
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact('a', 'b');
- });
- }
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- char r = (char) hs.get(am).invokeExact('a', 'b');
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- char r = (char) hs.get(am).invokeExact('a');
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
- checkUOE(am, () -> {
- char r = (char) hs.get(am).invokeExact('a');
- });
- }
}
@@ -244,34 +430,149 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(array, i, 'a');
+ hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 'a', "get char value");
+ assertEquals(x, '\u0123', "get char value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, 'b');
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, '\u4567');
char x = (char) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
- assertEquals(x, 'b', "setVolatile char value");
+ assertEquals(x, '\u4567', "setVolatile char value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, 'a');
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, '\u0123');
char x = (char) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
- assertEquals(x, 'a', "setRelease char value");
+ assertEquals(x, '\u0123', "setRelease char value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, 'b');
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, '\u4567');
char x = (char) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
- assertEquals(x, 'b', "setOpaque char value");
+ assertEquals(x, '\u4567', "setOpaque char value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, '\u0123', '\u4567');
+ assertEquals(r, true, "success compareAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u4567', "success compareAndSet char value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, '\u0123', '\u89AB');
+ assertEquals(r, false, "failing compareAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u4567', "failing compareAndSet char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, '\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeVolatile char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u0123', "success compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, '\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeVolatile char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u0123', "failing compareAndExchangeVolatile char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, '\u0123', '\u4567');
+ assertEquals(r, '\u0123', "success compareAndExchangeAcquire char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u4567', "success compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, '\u0123', '\u89AB');
+ assertEquals(r, '\u4567', "failing compareAndExchangeAcquire char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u4567', "failing compareAndExchangeAcquire char value");
+ }
+
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, '\u4567', '\u0123');
+ assertEquals(r, '\u4567', "success compareAndExchangeRelease char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u0123', "success compareAndExchangeRelease char value");
}
+ {
+ char r = (char) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, '\u4567', '\u89AB');
+ assertEquals(r, '\u0123', "failing compareAndExchangeRelease char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u0123', "failing compareAndExchangeRelease char value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, '\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u4567', "weakCompareAndSet char value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, '\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u0123', "weakCompareAndSetAcquire char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, '\u0123', '\u4567');
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u4567', "weakCompareAndSetRelease char");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, '\u4567', '\u0123');
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u0123', "weakCompareAndSetVolatile char");
+ }
+
+ // Compare set and get
+ {
+ char o = (char) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, '\u4567');
+ assertEquals(o, '\u0123', "getAndSet char");
+ char x = (char) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, '\u4567', "getAndSet char value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(array, i, '\u0123');
+
+ // get and add, add and get
+ {
+ char o = (char) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, '\u89AB');
+ assertEquals(o, '\u0123', "getAndAdd char");
+ char c = (char) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, '\u89AB');
+ assertEquals(c, (char)('\u0123' + '\u89AB' + '\u89AB'), "getAndAdd char value");
+ }
}
}
@@ -279,29 +580,7 @@
char[] array = new char[10];
final int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(array, i, 'a', 'b');
- });
- }
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- char r = (char) hs.get(am).invokeExact(array, i, 'a', 'b');
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- char r = (char) hs.get(am).invokeExact(array, i, 'a');
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
- checkUOE(am, () -> {
- char o = (char) hs.get(am).invokeExact(array, i, 'a');
- });
- }
}
static void testArrayIndexOutOfBounds(Handles hs) throws Throwable {
@@ -318,11 +597,33 @@
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
- hs.get(am).invokeExact(array, ci, 'a');
+ hs.get(am).invokeExact(array, ci, '\u0123');
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
+ checkIOOBE(am, () -> {
+ boolean r = (boolean) hs.get(am).invokeExact(array, ci, '\u0123', '\u4567');
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ checkIOOBE(am, () -> {
+ char r = (char) hs.get(am).invokeExact(array, ci, '\u4567', '\u0123');
+ });
+ }
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ checkIOOBE(am, () -> {
+ char o = (char) hs.get(am).invokeExact(array, ci, '\u0123');
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ checkIOOBE(am, () -> {
+ char o = (char) hs.get(am).invokeExact(array, ci, '\u89AB');
+ });
+ }
}
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java Wed Jun 15 11:20:15 2016 +0300
@@ -39,11 +39,11 @@
import static org.testng.Assert.*;
public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest {
- static final int static_final_v = 1;
+ static final int static_final_v = 0x01234567;
static int static_v;
- final int final_v = 1;
+ final int final_v = 0x01234567;
int v;
@@ -121,148 +121,148 @@
static void testInstanceField(VarHandleTestMethodHandleAccessInt recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(recv, 1);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567);
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1, "set int value");
+ assertEquals(x, 0x01234567, "set int value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, 2);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, 0x89ABCDEF);
int x = (int) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
- assertEquals(x, 2, "setVolatile int value");
+ assertEquals(x, 0x89ABCDEF, "setVolatile int value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, 1);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, 0x01234567);
int x = (int) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
- assertEquals(x, 1, "setRelease int value");
+ assertEquals(x, 0x01234567, "setRelease int value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, 2);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, 0x89ABCDEF);
int x = (int) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
- assertEquals(x, 2, "setOpaque int value");
+ assertEquals(x, 0x89ABCDEF, "setOpaque int value");
}
- hs.get(TestAccessMode.SET).invokeExact(recv, 1);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 0x01234567, 0x89ABCDEF);
assertEquals(r, true, "success compareAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2, "success compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndSet int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 1, 3);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 0x01234567, 0xCAFEBABE);
assertEquals(r, false, "failing compareAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2, "failing compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndSet int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 2, 1);
- assertEquals(r, 2, "success compareAndExchangeVolatile int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeVolatile int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1, "success compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 2, 3);
- assertEquals(r, 1, "failing compareAndExchangeVolatile int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeVolatile int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1, "failing compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 1, 2);
- assertEquals(r, 1, "success compareAndExchangeAcquire int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 0x01234567, 0x89ABCDEF);
+ assertEquals(r, 0x01234567, "success compareAndExchangeAcquire int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2, "success compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 1, 3);
- assertEquals(r, 2, "failing compareAndExchangeAcquire int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 0x01234567, 0xCAFEBABE);
+ assertEquals(r, 0x89ABCDEF, "failing compareAndExchangeAcquire int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2, "failing compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 2, 1);
- assertEquals(r, 2, "success compareAndExchangeRelease int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeRelease int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1, "success compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeRelease int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 2, 3);
- assertEquals(r, 1, "failing compareAndExchangeRelease int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeRelease int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1, "failing compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeRelease int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1, 2);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2, "weakCompareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2, 1);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetAcquire int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1, "weakCompareAndSetAcquire int");
+ assertEquals(x, 0x01234567, "weakCompareAndSetAcquire int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1, 2);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSetRelease int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2, "weakCompareAndSetRelease int");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSetRelease int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2, 1);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetVolatile int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1, "weakCompareAndSetVolatile int");
+ assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int");
}
// Compare set and get
{
- int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, 2);
- assertEquals(o, 1, "getAndSet int");
+ int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, 0x89ABCDEF);
+ assertEquals(o, 0x01234567, "getAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2, "getAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "getAndSet int value");
}
- hs.get(TestAccessMode.SET).invokeExact(recv, 1);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 0x01234567);
// get and add, add and get
{
- int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 3);
- assertEquals(o, 1, "getAndAdd int");
- int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 3);
- assertEquals(c, 1 + 3 + 3, "getAndAdd int value");
+ int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0xCAFEBABE);
+ assertEquals(o, 0x01234567, "getAndAdd int");
+ int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 0xCAFEBABE);
+ assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value");
}
}
@@ -274,148 +274,148 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(1);
+ hs.get(TestAccessMode.SET).invokeExact(0x01234567);
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1, "set int value");
+ assertEquals(x, 0x01234567, "set int value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(2);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(0x89ABCDEF);
int x = (int) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
- assertEquals(x, 2, "setVolatile int value");
+ assertEquals(x, 0x89ABCDEF, "setVolatile int value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(1);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(0x01234567);
int x = (int) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
- assertEquals(x, 1, "setRelease int value");
+ assertEquals(x, 0x01234567, "setRelease int value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(2);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(0x89ABCDEF);
int x = (int) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
- assertEquals(x, 2, "setOpaque int value");
+ assertEquals(x, 0x89ABCDEF, "setOpaque int value");
}
- hs.get(TestAccessMode.SET).invokeExact(1);
+ hs.get(TestAccessMode.SET).invokeExact(0x01234567);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(0x01234567, 0x89ABCDEF);
assertEquals(r, true, "success compareAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2, "success compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndSet int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(1, 3);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(0x01234567, 0xCAFEBABE);
assertEquals(r, false, "failing compareAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2, "failing compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndSet int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(2, 1);
- assertEquals(r, 2, "success compareAndExchangeVolatile int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeVolatile int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1, "success compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(2, 3);
- assertEquals(r, 1, "failing compareAndExchangeVolatile int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeVolatile int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1, "failing compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(1, 2);
- assertEquals(r, 1, "success compareAndExchangeAcquire int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(0x01234567, 0x89ABCDEF);
+ assertEquals(r, 0x01234567, "success compareAndExchangeAcquire int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2, "success compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(1, 3);
- assertEquals(r, 2, "failing compareAndExchangeAcquire int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(0x01234567, 0xCAFEBABE);
+ assertEquals(r, 0x89ABCDEF, "failing compareAndExchangeAcquire int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2, "failing compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(2, 1);
- assertEquals(r, 2, "success compareAndExchangeRelease int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeRelease int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1, "success compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeRelease int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(2, 3);
- assertEquals(r, 1, "failing compareAndExchangeRelease int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeRelease int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1, "failing compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeRelease int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1, 2);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2, "weakCompareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2, 1);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetAcquire int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1, "weakCompareAndSetAcquire int");
+ assertEquals(x, 0x01234567, "weakCompareAndSetAcquire int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1, 2);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSetRelease int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2, "weakCompareAndSetRelease int");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSetRelease int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2, 1);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetVolatile int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1, "weakCompareAndSetVolatile int");
+ assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int");
}
// Compare set and get
{
- int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2);
- assertEquals(o, 1, "getAndSet int");
+ int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 0x89ABCDEF);
+ assertEquals(o, 0x01234567, "getAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2, "getAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "getAndSet int value");
}
- hs.get(TestAccessMode.SET).invokeExact(1);
+ hs.get(TestAccessMode.SET).invokeExact(0x01234567);
// get and add, add and get
{
- int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 3);
- assertEquals(o, 1, "getAndAdd int");
- int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(3);
- assertEquals(c, 1 + 3 + 3, "getAndAdd int value");
+ int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 0xCAFEBABE);
+ assertEquals(o, 0x01234567, "getAndAdd int");
+ int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(0xCAFEBABE);
+ assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value");
}
}
@@ -430,148 +430,148 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(array, i, 1);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567);
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1, "get int value");
+ assertEquals(x, 0x01234567, "get int value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, 2);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, 0x89ABCDEF);
int x = (int) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
- assertEquals(x, 2, "setVolatile int value");
+ assertEquals(x, 0x89ABCDEF, "setVolatile int value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, 1);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, 0x01234567);
int x = (int) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
- assertEquals(x, 1, "setRelease int value");
+ assertEquals(x, 0x01234567, "setRelease int value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, 2);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, 0x89ABCDEF);
int x = (int) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
- assertEquals(x, 2, "setOpaque int value");
+ assertEquals(x, 0x89ABCDEF, "setOpaque int value");
}
- hs.get(TestAccessMode.SET).invokeExact(array, i, 1);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 1, 2);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 0x01234567, 0x89ABCDEF);
assertEquals(r, true, "success compareAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2, "success compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndSet int value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 1, 3);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 0x01234567, 0xCAFEBABE);
assertEquals(r, false, "failing compareAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2, "failing compareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndSet int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 2, 1);
- assertEquals(r, 2, "success compareAndExchangeVolatile int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeVolatile int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1, "success compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 2, 3);
- assertEquals(r, 1, "failing compareAndExchangeVolatile int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeVolatile int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1, "failing compareAndExchangeVolatile int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeVolatile int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 1, 2);
- assertEquals(r, 1, "success compareAndExchangeAcquire int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 0x01234567, 0x89ABCDEF);
+ assertEquals(r, 0x01234567, "success compareAndExchangeAcquire int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2, "success compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "success compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 1, 3);
- assertEquals(r, 2, "failing compareAndExchangeAcquire int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 0x01234567, 0xCAFEBABE);
+ assertEquals(r, 0x89ABCDEF, "failing compareAndExchangeAcquire int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2, "failing compareAndExchangeAcquire int value");
+ assertEquals(x, 0x89ABCDEF, "failing compareAndExchangeAcquire int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 2, 1);
- assertEquals(r, 2, "success compareAndExchangeRelease int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 0x89ABCDEF, 0x01234567);
+ assertEquals(r, 0x89ABCDEF, "success compareAndExchangeRelease int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1, "success compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "success compareAndExchangeRelease int value");
}
{
- int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 2, 3);
- assertEquals(r, 1, "failing compareAndExchangeRelease int");
+ int r = (int) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 0x89ABCDEF, 0xCAFEBABE);
+ assertEquals(r, 0x01234567, "failing compareAndExchangeRelease int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1, "failing compareAndExchangeRelease int value");
+ assertEquals(x, 0x01234567, "failing compareAndExchangeRelease int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1, 2);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2, "weakCompareAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSet int value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2, 1);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetAcquire int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1, "weakCompareAndSetAcquire int");
+ assertEquals(x, 0x01234567, "weakCompareAndSetAcquire int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1, 2);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 0x01234567, 0x89ABCDEF);
}
assertEquals(success, true, "weakCompareAndSetRelease int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2, "weakCompareAndSetRelease int");
+ assertEquals(x, 0x89ABCDEF, "weakCompareAndSetRelease int");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2, 1);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 0x89ABCDEF, 0x01234567);
}
assertEquals(success, true, "weakCompareAndSetVolatile int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1, "weakCompareAndSetVolatile int");
+ assertEquals(x, 0x01234567, "weakCompareAndSetVolatile int");
}
// Compare set and get
{
- int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 2);
- assertEquals(o, 1, "getAndSet int");
+ int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 0x89ABCDEF);
+ assertEquals(o, 0x01234567, "getAndSet int");
int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2, "getAndSet int value");
+ assertEquals(x, 0x89ABCDEF, "getAndSet int value");
}
- hs.get(TestAccessMode.SET).invokeExact(array, i, 1);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 0x01234567);
// get and add, add and get
{
- int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 3);
- assertEquals(o, 1, "getAndAdd int");
- int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 3);
- assertEquals(c, 1 + 3 + 3, "getAndAdd int value");
+ int o = (int) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0xCAFEBABE);
+ assertEquals(o, 0x01234567, "getAndAdd int");
+ int c = (int) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 0xCAFEBABE);
+ assertEquals(c, (int)(0x01234567 + 0xCAFEBABE + 0xCAFEBABE), "getAndAdd int value");
}
}
}
@@ -597,31 +597,31 @@
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
- hs.get(am).invokeExact(array, ci, 1);
+ hs.get(am).invokeExact(array, ci, 0x01234567);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkIOOBE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(array, ci, 1, 2);
+ boolean r = (boolean) hs.get(am).invokeExact(array, ci, 0x01234567, 0x89ABCDEF);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkIOOBE(am, () -> {
- int r = (int) hs.get(am).invokeExact(array, ci, 2, 1);
+ int r = (int) hs.get(am).invokeExact(array, ci, 0x89ABCDEF, 0x01234567);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkIOOBE(am, () -> {
- int o = (int) hs.get(am).invokeExact(array, ci, 1);
+ int o = (int) hs.get(am).invokeExact(array, ci, 0x01234567);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkIOOBE(am, () -> {
- int o = (int) hs.get(am).invokeExact(array, ci, 3);
+ int o = (int) hs.get(am).invokeExact(array, ci, 0xCAFEBABE);
});
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java Wed Jun 15 11:20:15 2016 +0300
@@ -39,11 +39,11 @@
import static org.testng.Assert.*;
public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest {
- static final long static_final_v = 1L;
+ static final long static_final_v = 0x0123456789ABCDEFL;
static long static_v;
- final long final_v = 1L;
+ final long final_v = 0x0123456789ABCDEFL;
long v;
@@ -121,148 +121,148 @@
static void testInstanceField(VarHandleTestMethodHandleAccessLong recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(recv, 1L);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL);
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1L, "set long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "set long value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, 2L);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, 0xCAFEBABECAFEBABEL);
long x = (long) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
- assertEquals(x, 2L, "setVolatile long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setVolatile long value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, 1L);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, 0x0123456789ABCDEFL);
long x = (long) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
- assertEquals(x, 1L, "setRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "setRelease long value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, 2L);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, 0xCAFEBABECAFEBABEL);
long x = (long) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
- assertEquals(x, 2L, "setOpaque long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setOpaque long value");
}
- hs.get(TestAccessMode.SET).invokeExact(recv, 1L);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
assertEquals(r, true, "success compareAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2L, "success compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSet long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 1L, 3L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
assertEquals(r, false, "failing compareAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2L, "failing compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSet long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeVolatile long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeVolatile long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1L, "success compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeVolatile long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1L, "failing compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 1L, 2L);
- assertEquals(r, 1L, "success compareAndExchangeAcquire long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+ assertEquals(r, 0x0123456789ABCDEFL, "success compareAndExchangeAcquire long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2L, "success compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 1L, 3L);
- assertEquals(r, 2L, "failing compareAndExchangeAcquire long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2L, "failing compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeRelease long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeRelease long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1L, "success compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeRelease long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeRelease long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1L, "failing compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1L, 2L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2L, "weakCompareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2L, 1L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetAcquire long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1L, "weakCompareAndSetAcquire long");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetAcquire long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1L, 2L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSetRelease long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2L, "weakCompareAndSetRelease long");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetRelease long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2L, 1L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetVolatile long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 1L, "weakCompareAndSetVolatile long");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long");
}
// Compare set and get
{
- long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, 2L);
- assertEquals(o, 1L, "getAndSet long");
+ long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, 0xCAFEBABECAFEBABEL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, 2L, "getAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value");
}
- hs.get(TestAccessMode.SET).invokeExact(recv, 1L);
+ hs.get(TestAccessMode.SET).invokeExact(recv, 0x0123456789ABCDEFL);
// get and add, add and get
{
- long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 3L);
- assertEquals(o, 1L, "getAndAdd long");
- long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 3L);
- assertEquals(c, 1L + 3L + 3L, "getAndAdd long value");
+ long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, 0xDEADBEEFDEADBEEFL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long");
+ long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, 0xDEADBEEFDEADBEEFL);
+ assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value");
}
}
@@ -274,148 +274,148 @@
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(1L);
+ hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL);
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1L, "set long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "set long value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(2L);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(0xCAFEBABECAFEBABEL);
long x = (long) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
- assertEquals(x, 2L, "setVolatile long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setVolatile long value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(1L);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(0x0123456789ABCDEFL);
long x = (long) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
- assertEquals(x, 1L, "setRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "setRelease long value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(2L);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(0xCAFEBABECAFEBABEL);
long x = (long) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
- assertEquals(x, 2L, "setOpaque long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setOpaque long value");
}
- hs.get(TestAccessMode.SET).invokeExact(1L);
+ hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
assertEquals(r, true, "success compareAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2L, "success compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSet long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(1L, 3L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
assertEquals(r, false, "failing compareAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2L, "failing compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSet long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeVolatile long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeVolatile long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1L, "success compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeVolatile long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1L, "failing compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(1L, 2L);
- assertEquals(r, 1L, "success compareAndExchangeAcquire long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+ assertEquals(r, 0x0123456789ABCDEFL, "success compareAndExchangeAcquire long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2L, "success compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(1L, 3L);
- assertEquals(r, 2L, "failing compareAndExchangeAcquire long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2L, "failing compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeRelease long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeRelease long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1L, "success compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeRelease long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeRelease long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1L, "failing compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1L, 2L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2L, "weakCompareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2L, 1L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetAcquire long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1L, "weakCompareAndSetAcquire long");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetAcquire long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1L, 2L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSetRelease long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2L, "weakCompareAndSetRelease long");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetRelease long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2L, 1L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetVolatile long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 1L, "weakCompareAndSetVolatile long");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long");
}
// Compare set and get
{
- long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2L);
- assertEquals(o, 1L, "getAndSet long");
+ long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 0xCAFEBABECAFEBABEL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, 2L, "getAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value");
}
- hs.get(TestAccessMode.SET).invokeExact(1L);
+ hs.get(TestAccessMode.SET).invokeExact(0x0123456789ABCDEFL);
// get and add, add and get
{
- long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 3L);
- assertEquals(o, 1L, "getAndAdd long");
- long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(3L);
- assertEquals(c, 1L + 3L + 3L, "getAndAdd long value");
+ long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( 0xDEADBEEFDEADBEEFL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long");
+ long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(0xDEADBEEFDEADBEEFL);
+ assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value");
}
}
@@ -430,148 +430,148 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(array, i, 1L);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL);
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1L, "get long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "get long value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, 2L);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, 0xCAFEBABECAFEBABEL);
long x = (long) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
- assertEquals(x, 2L, "setVolatile long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setVolatile long value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, 1L);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, 0x0123456789ABCDEFL);
long x = (long) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
- assertEquals(x, 1L, "setRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "setRelease long value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, 2L);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, 0xCAFEBABECAFEBABEL);
long x = (long) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
- assertEquals(x, 2L, "setOpaque long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "setOpaque long value");
}
- hs.get(TestAccessMode.SET).invokeExact(array, i, 1L);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL);
// Compare
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 1L, 2L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
assertEquals(r, true, "success compareAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2L, "success compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSet long value");
}
{
- boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 1L, 3L);
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
assertEquals(r, false, "failing compareAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2L, "failing compareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSet long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeVolatile long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeVolatile long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1L, "success compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeVolatile long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1L, "failing compareAndExchangeVolatile long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 1L, 2L);
- assertEquals(r, 1L, "success compareAndExchangeAcquire long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+ assertEquals(r, 0x0123456789ABCDEFL, "success compareAndExchangeAcquire long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2L, "success compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 1L, 3L);
- assertEquals(r, 2L, "failing compareAndExchangeAcquire long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2L, "failing compareAndExchangeAcquire long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndExchangeAcquire long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 2L, 1L);
- assertEquals(r, 2L, "success compareAndExchangeRelease long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+ assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeRelease long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1L, "success compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeRelease long value");
}
{
- long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 2L, 3L);
- assertEquals(r, 1L, "failing compareAndExchangeRelease long");
+ long r = (long) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+ assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1L, "failing compareAndExchangeRelease long value");
+ assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeRelease long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1L, 2L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2L, "weakCompareAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSet long value");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2L, 1L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetAcquire long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1L, "weakCompareAndSetAcquire long");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetAcquire long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1L, 2L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
}
assertEquals(success, true, "weakCompareAndSetRelease long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2L, "weakCompareAndSetRelease long");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetRelease long");
}
{
boolean success = false;
for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
- success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2L, 1L);
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
}
assertEquals(success, true, "weakCompareAndSetVolatile long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 1L, "weakCompareAndSetVolatile long");
+ assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetVolatile long");
}
// Compare set and get
{
- long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 2L);
- assertEquals(o, 1L, "getAndSet long");
+ long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 0xCAFEBABECAFEBABEL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndSet long");
long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, 2L, "getAndSet long value");
+ assertEquals(x, 0xCAFEBABECAFEBABEL, "getAndSet long value");
}
- hs.get(TestAccessMode.SET).invokeExact(array, i, 1L);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, 0x0123456789ABCDEFL);
// get and add, add and get
{
- long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 3L);
- assertEquals(o, 1L, "getAndAdd long");
- long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 3L);
- assertEquals(c, 1L + 3L + 3L, "getAndAdd long value");
+ long o = (long) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, 0xDEADBEEFDEADBEEFL);
+ assertEquals(o, 0x0123456789ABCDEFL, "getAndAdd long");
+ long c = (long) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, 0xDEADBEEFDEADBEEFL);
+ assertEquals(c, (long)(0x0123456789ABCDEFL + 0xDEADBEEFDEADBEEFL + 0xDEADBEEFDEADBEEFL), "getAndAdd long value");
}
}
}
@@ -597,31 +597,31 @@
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
- hs.get(am).invokeExact(array, ci, 1L);
+ hs.get(am).invokeExact(array, ci, 0x0123456789ABCDEFL);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
checkIOOBE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(array, ci, 1L, 2L);
+ boolean r = (boolean) hs.get(am).invokeExact(array, ci, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkIOOBE(am, () -> {
- long r = (long) hs.get(am).invokeExact(array, ci, 2L, 1L);
+ long r = (long) hs.get(am).invokeExact(array, ci, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkIOOBE(am, () -> {
- long o = (long) hs.get(am).invokeExact(array, ci, 1L);
+ long o = (long) hs.get(am).invokeExact(array, ci, 0x0123456789ABCDEFL);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkIOOBE(am, () -> {
- long o = (long) hs.get(am).invokeExact(array, ci, 3L);
+ long o = (long) hs.get(am).invokeExact(array, ci, 0xDEADBEEFDEADBEEFL);
});
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java Wed Jun 15 11:20:15 2016 +0300
@@ -39,11 +39,11 @@
import static org.testng.Assert.*;
public class VarHandleTestMethodHandleAccessShort extends VarHandleBaseTest {
- static final short static_final_v = (short)1;
+ static final short static_final_v = (short)0x0123;
static short static_v;
- final short final_v = (short)1;
+ final short final_v = (short)0x0123;
short v;
@@ -121,120 +121,306 @@
static void testInstanceField(VarHandleTestMethodHandleAccessShort recv, Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(recv, (short)1);
+ hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123);
short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
- assertEquals(x, (short)1, "set short value");
+ assertEquals(x, (short)0x0123, "set short value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, (short)2);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(recv, (short)0x4567);
short x = (short) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(recv);
- assertEquals(x, (short)2, "setVolatile short value");
+ assertEquals(x, (short)0x4567, "setVolatile short value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, (short)1);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(recv, (short)0x0123);
short x = (short) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(recv);
- assertEquals(x, (short)1, "setRelease short value");
+ assertEquals(x, (short)0x0123, "setRelease short value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, (short)2);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(recv, (short)0x4567);
short x = (short) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(recv);
- assertEquals(x, (short)2, "setOpaque short value");
+ assertEquals(x, (short)0x4567, "setOpaque short value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123);
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, (short)0x0123, (short)0x4567);
+ assertEquals(r, true, "success compareAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x4567, "success compareAndSet short value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(recv, (short)0x0123, (short)0x89AB);
+ assertEquals(r, false, "failing compareAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x4567, "failing compareAndSet short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, (short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeVolatile short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x0123, "success compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(recv, (short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeVolatile short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, (short)0x0123, (short)0x4567);
+ assertEquals(r, (short)0x0123, "success compareAndExchangeAcquire short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x4567, "success compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(recv, (short)0x0123, (short)0x89AB);
+ assertEquals(r, (short)0x4567, "failing compareAndExchangeAcquire short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x4567, "failing compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, (short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeRelease short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x0123, "success compareAndExchangeRelease short value");
}
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(recv, (short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeRelease short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeRelease short value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, (short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x4567, "weakCompareAndSet short value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, (short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x0123, "weakCompareAndSetAcquire short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, (short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x4567, "weakCompareAndSetRelease short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, (short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short");
+ }
+
+ // Compare set and get
+ {
+ short o = (short) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, (short)0x4567);
+ assertEquals(o, (short)0x0123, "getAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(recv);
+ assertEquals(x, (short)0x4567, "getAndSet short value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(recv, (short)0x0123);
+
+ // get and add, add and get
+ {
+ short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, (short)0x89AB);
+ assertEquals(o, (short)0x0123, "getAndAdd short");
+ short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, (short)0x89AB);
+ assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value");
+ }
}
static void testInstanceFieldUnsupported(VarHandleTestMethodHandleAccessShort recv, Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(recv, (short)1, (short)2);
- });
- }
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- short r = (short) hs.get(am).invokeExact(recv, (short)1, (short)2);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- short r = (short) hs.get(am).invokeExact(recv, (short)1);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
- checkUOE(am, () -> {
- short r = (short) hs.get(am).invokeExact(recv, (short)1);
- });
- }
}
static void testStaticField(Handles hs) throws Throwable {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact((short)1);
+ hs.get(TestAccessMode.SET).invokeExact((short)0x0123);
short x = (short) hs.get(TestAccessMode.GET).invokeExact();
- assertEquals(x, (short)1, "set short value");
+ assertEquals(x, (short)0x0123, "set short value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact((short)2);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact((short)0x4567);
short x = (short) hs.get(TestAccessMode.GET_VOLATILE).invokeExact();
- assertEquals(x, (short)2, "setVolatile short value");
+ assertEquals(x, (short)0x4567, "setVolatile short value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact((short)1);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact((short)0x0123);
short x = (short) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact();
- assertEquals(x, (short)1, "setRelease short value");
+ assertEquals(x, (short)0x0123, "setRelease short value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact((short)2);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact((short)0x4567);
short x = (short) hs.get(TestAccessMode.GET_OPAQUE).invokeExact();
- assertEquals(x, (short)2, "setOpaque short value");
+ assertEquals(x, (short)0x4567, "setOpaque short value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact((short)0x0123);
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact((short)0x0123, (short)0x4567);
+ assertEquals(r, true, "success compareAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x4567, "success compareAndSet short value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact((short)0x0123, (short)0x89AB);
+ assertEquals(r, false, "failing compareAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x4567, "failing compareAndSet short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact((short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeVolatile short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x0123, "success compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact((short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeVolatile short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact((short)0x0123, (short)0x4567);
+ assertEquals(r, (short)0x0123, "success compareAndExchangeAcquire short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x4567, "success compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact((short)0x0123, (short)0x89AB);
+ assertEquals(r, (short)0x4567, "failing compareAndExchangeAcquire short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x4567, "failing compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact((short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeRelease short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x0123, "success compareAndExchangeRelease short value");
}
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact((short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeRelease short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeRelease short value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact((short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x4567, "weakCompareAndSet short value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact((short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x0123, "weakCompareAndSetAcquire short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact((short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x4567, "weakCompareAndSetRelease short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact((short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short");
+ }
+
+ // Compare set and get
+ {
+ short o = (short) hs.get(TestAccessMode.GET_AND_SET).invokeExact( (short)0x4567);
+ assertEquals(o, (short)0x0123, "getAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact();
+ assertEquals(x, (short)0x4567, "getAndSet short value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact((short)0x0123);
+
+ // get and add, add and get
+ {
+ short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( (short)0x89AB);
+ assertEquals(o, (short)0x0123, "getAndAdd short");
+ short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact((short)0x89AB);
+ assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value");
+ }
}
static void testStaticFieldUnsupported(Handles hs) throws Throwable {
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact((short)1, (short)2);
- });
- }
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- short r = (short) hs.get(am).invokeExact((short)1, (short)2);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- short r = (short) hs.get(am).invokeExact((short)1);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
- checkUOE(am, () -> {
- short r = (short) hs.get(am).invokeExact((short)1);
- });
- }
}
@@ -244,34 +430,149 @@
for (int i = 0; i < array.length; i++) {
// Plain
{
- hs.get(TestAccessMode.SET).invokeExact(array, i, (short)1);
+ hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123);
short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
- assertEquals(x, (short)1, "get short value");
+ assertEquals(x, (short)0x0123, "get short value");
}
// Volatile
{
- hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, (short)2);
+ hs.get(TestAccessMode.SET_VOLATILE).invokeExact(array, i, (short)0x4567);
short x = (short) hs.get(TestAccessMode.GET_VOLATILE).invokeExact(array, i);
- assertEquals(x, (short)2, "setVolatile short value");
+ assertEquals(x, (short)0x4567, "setVolatile short value");
}
// Lazy
{
- hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, (short)1);
+ hs.get(TestAccessMode.SET_RELEASE).invokeExact(array, i, (short)0x0123);
short x = (short) hs.get(TestAccessMode.GET_ACQUIRE).invokeExact(array, i);
- assertEquals(x, (short)1, "setRelease short value");
+ assertEquals(x, (short)0x0123, "setRelease short value");
}
// Opaque
{
- hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, (short)2);
+ hs.get(TestAccessMode.SET_OPAQUE).invokeExact(array, i, (short)0x4567);
short x = (short) hs.get(TestAccessMode.GET_OPAQUE).invokeExact(array, i);
- assertEquals(x, (short)2, "setOpaque short value");
+ assertEquals(x, (short)0x4567, "setOpaque short value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123);
+
+ // Compare
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, (short)0x0123, (short)0x4567);
+ assertEquals(r, true, "success compareAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x4567, "success compareAndSet short value");
+ }
+
+ {
+ boolean r = (boolean) hs.get(TestAccessMode.COMPARE_AND_SET).invokeExact(array, i, (short)0x0123, (short)0x89AB);
+ assertEquals(r, false, "failing compareAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x4567, "failing compareAndSet short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, (short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeVolatile short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x0123, "success compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_VOLATILE).invokeExact(array, i, (short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeVolatile short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeVolatile short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, (short)0x0123, (short)0x4567);
+ assertEquals(r, (short)0x0123, "success compareAndExchangeAcquire short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x4567, "success compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_ACQUIRE).invokeExact(array, i, (short)0x0123, (short)0x89AB);
+ assertEquals(r, (short)0x4567, "failing compareAndExchangeAcquire short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x4567, "failing compareAndExchangeAcquire short value");
+ }
+
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, (short)0x4567, (short)0x0123);
+ assertEquals(r, (short)0x4567, "success compareAndExchangeRelease short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x0123, "success compareAndExchangeRelease short value");
}
+ {
+ short r = (short) hs.get(TestAccessMode.COMPARE_AND_EXCHANGE_RELEASE).invokeExact(array, i, (short)0x4567, (short)0x89AB);
+ assertEquals(r, (short)0x0123, "failing compareAndExchangeRelease short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x0123, "failing compareAndExchangeRelease short value");
+ }
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, (short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x4567, "weakCompareAndSet short value");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, (short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetAcquire short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x0123, "weakCompareAndSetAcquire short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, (short)0x0123, (short)0x4567);
+ }
+ assertEquals(success, true, "weakCompareAndSetRelease short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x4567, "weakCompareAndSetRelease short");
+ }
+
+ {
+ boolean success = false;
+ for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
+ success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, (short)0x4567, (short)0x0123);
+ }
+ assertEquals(success, true, "weakCompareAndSetVolatile short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x0123, "weakCompareAndSetVolatile short");
+ }
+
+ // Compare set and get
+ {
+ short o = (short) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, (short)0x4567);
+ assertEquals(o, (short)0x0123, "getAndSet short");
+ short x = (short) hs.get(TestAccessMode.GET).invokeExact(array, i);
+ assertEquals(x, (short)0x4567, "getAndSet short value");
+ }
+
+ hs.get(TestAccessMode.SET).invokeExact(array, i, (short)0x0123);
+
+ // get and add, add and get
+ {
+ short o = (short) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, (short)0x89AB);
+ assertEquals(o, (short)0x0123, "getAndAdd short");
+ short c = (short) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, (short)0x89AB);
+ assertEquals(c, (short)((short)0x0123 + (short)0x89AB + (short)0x89AB), "getAndAdd short value");
+ }
}
}
@@ -279,29 +580,7 @@
short[] array = new short[10];
final int i = 0;
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
- checkUOE(am, () -> {
- boolean r = (boolean) hs.get(am).invokeExact(array, i, (short)1, (short)2);
- });
- }
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
- checkUOE(am, () -> {
- short r = (short) hs.get(am).invokeExact(array, i, (short)1, (short)2);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
- checkUOE(am, () -> {
- short r = (short) hs.get(am).invokeExact(array, i, (short)1);
- });
- }
-
- for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
- checkUOE(am, () -> {
- short o = (short) hs.get(am).invokeExact(array, i, (short)1);
- });
- }
}
static void testArrayIndexOutOfBounds(Handles hs) throws Throwable {
@@ -318,11 +597,33 @@
for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) {
checkIOOBE(am, () -> {
- hs.get(am).invokeExact(array, ci, (short)1);
+ hs.get(am).invokeExact(array, ci, (short)0x0123);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
+ checkIOOBE(am, () -> {
+ boolean r = (boolean) hs.get(am).invokeExact(array, ci, (short)0x0123, (short)0x4567);
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ checkIOOBE(am, () -> {
+ short r = (short) hs.get(am).invokeExact(array, ci, (short)0x4567, (short)0x0123);
+ });
+ }
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ checkIOOBE(am, () -> {
+ short o = (short) hs.get(am).invokeExact(array, ci, (short)0x0123);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ checkIOOBE(am, () -> {
+ short o = (short) hs.get(am).invokeExact(array, ci, (short)0x89AB);
+ });
+ }
}
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java Wed Jun 15 11:20:15 2016 +0300
@@ -324,6 +324,263 @@
});
+ // CompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.compareAndSet(null, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.compareAndSet(Void.class, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.compareAndSet(recv, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.compareAndSet(recv, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.compareAndSet(0, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.compareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.compareAndSet(recv, true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSet(null, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSet(Void.class, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSet(recv, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSet(recv, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSet(0, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSet(recv, true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSetVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetVolatile(null, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetVolatile(recv, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetVolatile(0, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetVolatile(recv, true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSetAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetAcquire(null, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetAcquire(recv, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetAcquire(recv, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetAcquire(0, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetAcquire(recv, true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSetRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetRelease(null, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetRelease(Void.class, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetRelease(recv, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetRelease(recv, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetRelease(0, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetRelease(recv, true, true, Void.class);
+ });
+
+
+ // CompareAndExchangeVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean x = (boolean) vh.compareAndExchangeVolatile(null, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(Void.class, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(recv, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(recv, true, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(0, true, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeVolatile(recv, true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.compareAndExchangeVolatile(recv, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.compareAndExchangeVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.compareAndExchangeVolatile(recv, true, true, Void.class);
+ });
+
+
+ // CompareAndExchangeVolatileAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean x = (boolean) vh.compareAndExchangeAcquire(null, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(Void.class, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(recv, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(recv, true, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(0, true, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeAcquire(recv, true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.compareAndExchangeAcquire(recv, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.compareAndExchangeAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.compareAndExchangeAcquire(recv, true, true, Void.class);
+ });
+
+
+ // CompareAndExchangeRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean x = (boolean) vh.compareAndExchangeRelease(null, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean x = (boolean) vh.compareAndExchangeRelease(Void.class, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) vh.compareAndExchangeRelease(recv, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) vh.compareAndExchangeRelease(recv, true, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ boolean x = (boolean) vh.compareAndExchangeRelease(0, true, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeRelease(recv, true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.compareAndExchangeRelease(recv, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.compareAndExchangeRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.compareAndExchangeRelease(recv, true, true, Void.class);
+ });
+
+
+ // GetAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean x = (boolean) vh.getAndSet(null, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean x = (boolean) vh.getAndSet(Void.class, true);
+ });
+ checkWMTE(() -> { // value reference class
+ boolean x = (boolean) vh.getAndSet(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ boolean x = (boolean) vh.getAndSet(0, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndSet(recv, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.getAndSet(recv, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.getAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.getAndSet(recv, true, Void.class);
+ });
}
@@ -391,6 +648,116 @@
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class, boolean.class)).
+ invokeExact((VarHandleTestMethodTypeBoolean) null, true, true);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class, boolean.class)).
+ invokeExact(Void.class, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class, boolean.class)).
+ invokeExact(recv, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class, Class.class)).
+ invokeExact(recv, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , boolean.class, boolean.class)).
+ invokeExact(0, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class, boolean.class, Class.class)).
+ invokeExact(recv, true, true, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ checkNPE(() -> { // null receiver
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class, boolean.class)).
+ invokeExact((VarHandleTestMethodTypeBoolean) null, true, true);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class, boolean.class)).
+ invokeExact(Void.class, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class, boolean.class)).
+ invokeExact(recv, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class, Class.class)).
+ invokeExact(recv, true, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class , boolean.class, boolean.class)).
+ invokeExact(0, true, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeBoolean.class , boolean.class, boolean.class)).
+ invokeExact(recv, true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeBoolean.class , boolean.class, boolean.class)).
+ invokeExact(recv, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class, boolean.class, Class.class)).
+ invokeExact(recv, true, true, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ checkNPE(() -> { // null receiver
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class)).
+ invokeExact((VarHandleTestMethodTypeBoolean) null, true);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class)).
+ invokeExact(Void.class, true);
+ });
+ checkWMTE(() -> { // value reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class)).
+ invokeExact(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, boolean.class)).
+ invokeExact(0, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeBoolean.class, boolean.class)).
+ invokeExact(recv, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeBoolean.class, boolean.class)).
+ invokeExact(recv, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, boolean.class)).
+ invokeExact(recv, true, Void.class);
+ });
+ }
}
@@ -505,6 +872,182 @@
});
+ // CompareAndSet
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.compareAndSet(Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.compareAndSet(true, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.compareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.compareAndSet(true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSet
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSet(Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSet(true, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSet(true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSetVolatile
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetVolatile(true, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetVolatile(true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSetAcquire
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetAcquire(true, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetAcquire(true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSetRelease
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetRelease(Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetRelease(true, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetRelease(true, true, Void.class);
+ });
+
+
+ // CompareAndExchangeVolatile
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(true, Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeVolatile(true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.compareAndExchangeVolatile(true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.compareAndExchangeVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.compareAndExchangeVolatile(true, true, Void.class);
+ });
+
+
+ // CompareAndExchangeAcquire
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(true, Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeAcquire(true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.compareAndExchangeAcquire(true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.compareAndExchangeAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.compareAndExchangeAcquire(true, true, Void.class);
+ });
+
+
+ // CompareAndExchangeRelease
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) vh.compareAndExchangeRelease(Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) vh.compareAndExchangeRelease(true, Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeRelease(true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.compareAndExchangeRelease(true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.compareAndExchangeRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.compareAndExchangeRelease(true, true, Void.class);
+ });
+
+
+ // GetAndSet
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ boolean x = (boolean) vh.getAndSet(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndSet(true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.getAndSet(true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.getAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.getAndSet(true, Void.class);
+ });
}
@@ -543,6 +1086,82 @@
invokeExact(true, Void.class);
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class)).
+ invokeExact(Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean.class, Class.class)).
+ invokeExact(true, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean.class, boolean.class, Class.class)).
+ invokeExact(true, true, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, boolean.class)).
+ invokeExact(Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean.class, Class.class)).
+ invokeExact(true, Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, boolean.class, boolean.class)).
+ invokeExact(true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) hs.get(am, methodType(int.class, boolean.class, boolean.class)).
+ invokeExact(true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean.class, boolean.class, Class.class)).
+ invokeExact(true, true, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class)).
+ invokeExact(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, boolean.class)).
+ invokeExact(true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) hs.get(am, methodType(int.class, boolean.class)).
+ invokeExact(true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean.class, Class.class)).
+ invokeExact(true, Void.class);
+ });
+ }
}
@@ -775,6 +1394,290 @@
});
+ // CompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.compareAndSet(null, 0, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.compareAndSet(Void.class, 0, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.compareAndSet(array, 0, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.compareAndSet(array, 0, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.compareAndSet(0, 0, true, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.compareAndSet(array, Void.class, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.compareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.compareAndSet(array, 0, true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSet(null, 0, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSet(Void.class, 0, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSet(array, 0, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSet(array, 0, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSet(0, 0, true, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSet(array, Void.class, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSet(array, 0, true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSetVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetVolatile(null, 0, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetVolatile(0, 0, true, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSetVolatile(array, Void.class, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSetAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetAcquire(null, 0, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetAcquire(0, 0, true, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, Void.class, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, true, true, Void.class);
+ });
+
+
+ // WeakCompareAndSetRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetRelease(null, 0, true, true);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetRelease(Void.class, 0, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetRelease(array, 0, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetRelease(array, 0, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetRelease(0, 0, true, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSetRelease(array, Void.class, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetRelease(array, 0, true, true, Void.class);
+ });
+
+
+ // CompareAndExchangeVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean x = (boolean) vh.compareAndExchangeVolatile(null, 0, true, true);
+ });
+ checkCCE(() -> { // array reference class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(Void.class, 0, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, true, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(0, 0, true, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(array, Void.class, true, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeVolatile(array, 0, true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.compareAndExchangeVolatile(array, 0, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.compareAndExchangeVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, true, true, Void.class);
+ });
+
+
+ // CompareAndExchangeAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean x = (boolean) vh.compareAndExchangeAcquire(null, 0, true, true);
+ });
+ checkCCE(() -> { // array reference class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(Void.class, 0, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, true, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(0, 0, true, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(array, Void.class, true, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeAcquire(array, 0, true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.compareAndExchangeAcquire(array, 0, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.compareAndExchangeAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, true, true, Void.class);
+ });
+
+
+ // CompareAndExchangeRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean x = (boolean) vh.compareAndExchangeRelease(null, 0, true, true);
+ });
+ checkCCE(() -> { // array reference class
+ boolean x = (boolean) vh.compareAndExchangeRelease(Void.class, 0, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, true, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ boolean x = (boolean) vh.compareAndExchangeRelease(0, 0, true, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean x = (boolean) vh.compareAndExchangeRelease(array, Void.class, true, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeRelease(array, 0, true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.compareAndExchangeRelease(array, 0, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.compareAndExchangeRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, true, true, Void.class);
+ });
+
+
+ // GetAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ boolean x = (boolean) vh.getAndSet(null, 0, true);
+ });
+ checkCCE(() -> { // array reference class
+ boolean x = (boolean) vh.getAndSet(Void.class, 0, true);
+ });
+ checkWMTE(() -> { // value reference class
+ boolean x = (boolean) vh.getAndSet(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // reciarrayever primitive class
+ boolean x = (boolean) vh.getAndSet(0, 0, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean x = (boolean) vh.getAndSet(array, Void.class, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndSet(array, 0, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) vh.getAndSet(array, 0, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) vh.getAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) vh.getAndSet(array, 0, true, Void.class);
+ });
}
@@ -852,6 +1755,130 @@
invokeExact(array, 0, true, 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, boolean[].class, int.class, boolean.class, boolean.class)).
+ invokeExact((boolean[]) null, 0, true, true);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, boolean.class, boolean.class)).
+ invokeExact(Void.class, 0, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class, boolean.class)).
+ invokeExact(array, 0, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, Class.class)).
+ invokeExact(array, 0, true, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, boolean.class, boolean.class)).
+ invokeExact(0, 0, true, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class, boolean.class, boolean.class)).
+ invokeExact(array, Void.class, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, boolean.class, Class.class)).
+ invokeExact(array, 0, true, true, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, boolean.class)).
+ invokeExact((boolean[]) null, 0, true, true);
+ });
+ hs.checkWMTEOrCCE(() -> { // array reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, boolean.class, boolean.class)).
+ invokeExact(Void.class, 0, true, true);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class, boolean.class)).
+ invokeExact(array, 0, Void.class, true);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, Class.class)).
+ invokeExact(array, 0, true, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, boolean.class, boolean.class)).
+ invokeExact(0, 0, true, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class, boolean.class, boolean.class)).
+ invokeExact(array, Void.class, true, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, boolean[].class, int.class, boolean.class, boolean.class)).
+ invokeExact(array, 0, true, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) hs.get(am, methodType(int.class, boolean[].class, int.class, boolean.class, boolean.class)).
+ invokeExact(array, 0, true, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, boolean.class, Class.class)).
+ invokeExact(array, 0, true, true, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class)).
+ invokeExact((boolean[]) null, 0, true);
+ });
+ hs.checkWMTEOrCCE(() -> { // array reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, boolean.class)).
+ invokeExact(Void.class, 0, true);
+ });
+ checkWMTE(() -> { // value reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class)).
+ invokeExact(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, boolean.class)).
+ invokeExact(0, 0, true);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class, boolean.class)).
+ invokeExact(array, Void.class, true);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, boolean[].class, int.class, boolean.class)).
+ invokeExact(array, 0, true);
+ });
+ checkWMTE(() -> { // primitive class
+ int x = (int) hs.get(am, methodType(int.class, boolean[].class, int.class, boolean.class)).
+ invokeExact(array, 0, true);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean x = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, boolean.class, Class.class)).
+ invokeExact(array, 0, true, Void.class);
+ });
+ }
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java Wed Jun 15 11:20:15 2016 +0300
@@ -43,13 +43,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;
@@ -154,23 +154,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);
});
@@ -204,23 +204,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);
});
@@ -254,23 +254,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);
});
@@ -304,27 +304,342 @@
// 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 {
@@ -366,11 +681,11 @@
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class)).
- invokeExact((VarHandleTestMethodTypeByte) null, (byte)1);
+ invokeExact((VarHandleTestMethodTypeByte) null, (byte)0x01);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, byte.class)).
- invokeExact(Void.class, (byte)1);
+ invokeExact(Void.class, (byte)0x01);
});
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, Class.class)).
@@ -378,7 +693,7 @@
});
checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, byte.class)).
- invokeExact(0, (byte)1);
+ invokeExact(0, (byte)0x01);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -387,11 +702,157 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)).
- invokeExact(recv, (byte)1, Void.class);
+ invokeExact(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, VarHandleTestMethodTypeByte.class, byte.class, byte.class)).
+ invokeExact((VarHandleTestMethodTypeByte) null, (byte)0x01, (byte)0x01);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, byte.class, byte.class)).
+ invokeExact(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)).
+ invokeExact(recv, Void.class, (byte)0x01);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)).
+ invokeExact(recv, (byte)0x01, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , byte.class, byte.class)).
+ invokeExact(0, (byte)0x01, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class, byte.class, byte.class, Class.class)).
+ invokeExact(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, VarHandleTestMethodTypeByte.class, byte.class, byte.class)).
+ invokeExact((VarHandleTestMethodTypeByte) null, (byte)0x01, (byte)0x01);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, Class.class, byte.class, byte.class)).
+ invokeExact(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)).
+ invokeExact(recv, Void.class, (byte)0x01);
+ });
+ checkWMTE(() -> { // actual reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)).
+ invokeExact(recv, (byte)0x01, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ byte x = (byte) hs.get(am, methodType(byte.class, int.class , byte.class, byte.class)).
+ invokeExact(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)).
+ invokeExact(recv, (byte)0x01, (byte)0x01);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class , byte.class, byte.class)).
+ invokeExact(recv, (byte)0x01, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) hs.get(am, methodType(byte.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class, byte.class, Class.class)).
+ invokeExact(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, VarHandleTestMethodTypeByte.class, byte.class)).
+ invokeExact((VarHandleTestMethodTypeByte) null, (byte)0x01);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, Class.class, byte.class)).
+ invokeExact(Void.class, (byte)0x01);
+ });
+ checkWMTE(() -> { // value reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)).
+ invokeExact(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ byte x = (byte) hs.get(am, methodType(byte.class, int.class, byte.class)).
+ invokeExact(0, (byte)0x01);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeByte.class, byte.class)).
+ invokeExact(recv, (byte)0x01);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class, byte.class)).
+ invokeExact(recv, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) hs.get(am, methodType(byte.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class)).
+ invokeExact(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, VarHandleTestMethodTypeByte.class, byte.class)).
+ invokeExact((VarHandleTestMethodTypeByte) null, (byte)0x01);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, Class.class, byte.class)).
+ invokeExact(Void.class, (byte)0x01);
+ });
+ checkWMTE(() -> { // value reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)).
+ invokeExact(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ byte x = (byte) hs.get(am, methodType(byte.class, int.class, byte.class)).
+ invokeExact(0, (byte)0x01);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeByte.class, byte.class)).
+ invokeExact(recv, (byte)0x01);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class, byte.class)).
+ invokeExact(recv, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) hs.get(am, methodType(byte.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, byte.class)).
+ invokeExact(recv, (byte)0x01, Void.class);
+ });
+ }
}
@@ -420,7 +881,7 @@
vh.set();
});
checkWMTE(() -> { // >
- vh.set((byte)1, Void.class);
+ vh.set((byte)0x01, Void.class);
});
@@ -447,7 +908,7 @@
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile((byte)1, Void.class);
+ vh.setVolatile((byte)0x01, Void.class);
});
@@ -474,7 +935,7 @@
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque((byte)1, Void.class);
+ vh.setOpaque((byte)0x01, Void.class);
});
@@ -501,11 +962,227 @@
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease((byte)1, Void.class);
+ 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 testStaticFieldWrongMethodType(Handles hs) throws Throwable {
@@ -540,16 +1217,117 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, byte.class, Class.class)).
- invokeExact((byte)1, Void.class);
+ invokeExact((byte)0x01, Void.class);
+ });
+ }
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, byte.class)).
+ invokeExact(Void.class, (byte)0x01);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, byte.class, Class.class)).
+ invokeExact((byte)0x01, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, byte.class, byte.class, Class.class)).
+ invokeExact((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)).
+ invokeExact(Void.class, (byte)0x01);
+ });
+ checkWMTE(() -> { // actual reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, byte.class, Class.class)).
+ invokeExact((byte)0x01, Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, byte.class, byte.class)).
+ invokeExact((byte)0x01, (byte)0x01);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, byte.class, byte.class)).
+ invokeExact((byte)0x01, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) hs.get(am, methodType(byte.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) hs.get(am, methodType(byte.class, byte.class, byte.class, Class.class)).
+ invokeExact((byte)0x01, (byte)0x01, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, Class.class)).
+ invokeExact(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, byte.class)).
+ invokeExact((byte)0x01);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, byte.class)).
+ invokeExact((byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) hs.get(am, methodType(byte.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) hs.get(am, methodType(byte.class, byte.class, Class.class)).
+ invokeExact((byte)0x01, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, Class.class)).
+ invokeExact(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, byte.class)).
+ invokeExact((byte)0x01);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, byte.class)).
+ invokeExact((byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) hs.get(am, methodType(byte.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) hs.get(am, methodType(byte.class, byte.class, Class.class)).
+ invokeExact((byte)0x01, Void.class);
+ });
+ }
}
static void testArrayWrongMethodType(VarHandle vh) throws Throwable {
byte[] array = new byte[10];
- Arrays.fill(array, (byte)1);
+ Arrays.fill(array, (byte)0x01);
// Get
// Incorrect argument types
@@ -584,26 +1362,26 @@
// Set
// Incorrect argument types
checkNPE(() -> { // null array
- vh.set(null, 0, (byte)1);
+ vh.set(null, 0, (byte)0x01);
});
checkCCE(() -> { // array reference class
- vh.set(Void.class, 0, (byte)1);
+ vh.set(Void.class, 0, (byte)0x01);
});
checkWMTE(() -> { // value reference class
vh.set(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.set(0, 0, (byte)1);
+ vh.set(0, 0, (byte)0x01);
});
checkWMTE(() -> { // index reference class
- vh.set(array, Void.class, (byte)1);
+ vh.set(array, Void.class, (byte)0x01);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.set();
});
checkWMTE(() -> { // >
- vh.set(array, 0, (byte)1, Void.class);
+ vh.set(array, 0, (byte)0x01, Void.class);
});
@@ -640,26 +1418,26 @@
// SetVolatile
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setVolatile(null, 0, (byte)1);
+ vh.setVolatile(null, 0, (byte)0x01);
});
checkCCE(() -> { // array reference class
- vh.setVolatile(Void.class, 0, (byte)1);
+ vh.setVolatile(Void.class, 0, (byte)0x01);
});
checkWMTE(() -> { // value reference class
vh.setVolatile(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setVolatile(0, 0, (byte)1);
+ vh.setVolatile(0, 0, (byte)0x01);
});
checkWMTE(() -> { // index reference class
- vh.setVolatile(array, Void.class, (byte)1);
+ vh.setVolatile(array, Void.class, (byte)0x01);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile(array, 0, (byte)1, Void.class);
+ vh.setVolatile(array, 0, (byte)0x01, Void.class);
});
@@ -696,26 +1474,26 @@
// SetOpaque
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setOpaque(null, 0, (byte)1);
+ vh.setOpaque(null, 0, (byte)0x01);
});
checkCCE(() -> { // array reference class
- vh.setOpaque(Void.class, 0, (byte)1);
+ vh.setOpaque(Void.class, 0, (byte)0x01);
});
checkWMTE(() -> { // value reference class
vh.setOpaque(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setOpaque(0, 0, (byte)1);
+ vh.setOpaque(0, 0, (byte)0x01);
});
checkWMTE(() -> { // index reference class
- vh.setOpaque(array, Void.class, (byte)1);
+ vh.setOpaque(array, Void.class, (byte)0x01);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque(array, 0, (byte)1, Void.class);
+ vh.setOpaque(array, 0, (byte)0x01, Void.class);
});
@@ -752,35 +1530,383 @@
// SetRelease
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setRelease(null, 0, (byte)1);
+ vh.setRelease(null, 0, (byte)0x01);
});
checkCCE(() -> { // array reference class
- vh.setRelease(Void.class, 0, (byte)1);
+ 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)1);
+ vh.setRelease(0, 0, (byte)0x01);
});
checkWMTE(() -> { // index reference class
- vh.setRelease(array, Void.class, (byte)1);
+ vh.setRelease(array, Void.class, (byte)0x01);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease(array, 0, (byte)1, Void.class);
+ 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(() -> { // >
+ boolean r = vh.weakCompareAndSet(array, 0, (byte)0x01, (byte)0x01, Void.class);
+ });
+
+
+ // WeakCompareAndSetVolatile
+ // Incorrect argument types
+ 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
+ boolean r = vh.weakCompareAndSetVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, (byte)0x01, (byte)0x01, Void.class);
+ });
+
+
+ // WeakCompareAndSetAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetAcquire(null, 0, (byte)0x01, (byte)0x01);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, (byte)0x01, (byte)0x01);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, (byte)0x01);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, (byte)0x01, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetAcquire(0, 0, (byte)0x01, (byte)0x01);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, Void.class, (byte)0x01, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, (byte)0x01, (byte)0x01, Void.class);
+ });
+
+
+ // WeakCompareAndSetRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetRelease(null, 0, (byte)0x01, (byte)0x01);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetRelease(Void.class, 0, (byte)0x01, (byte)0x01);
+ });
+ 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
+ boolean r = vh.weakCompareAndSetRelease(0, 0, (byte)0x01, (byte)0x01);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSetRelease(array, Void.class, (byte)0x01, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetRelease(array, 0, (byte)0x01, (byte)0x01, Void.class);
});
+ // CompareAndExchangeVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ byte x = (byte) vh.compareAndExchangeVolatile(null, 0, (byte)0x01, (byte)0x01);
+ });
+ checkCCE(() -> { // array reference class
+ 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.compareAndExchangeVolatile(0, 0, (byte)0x01, (byte)0x01);
+ });
+ checkWMTE(() -> { // index reference class
+ byte x = (byte) vh.compareAndExchangeVolatile(array, Void.class, (byte)0x01, (byte)0x01);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeVolatile(array, 0, (byte)0x01, (byte)0x01);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, (byte)0x01, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) vh.compareAndExchangeVolatile();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) vh.compareAndExchangeVolatile(array, 0, (byte)0x01, (byte)0x01, Void.class);
+ });
+
+ // CompareAndExchangeAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ byte x = (byte) vh.compareAndExchangeAcquire(null, 0, (byte)0x01, (byte)0x01);
+ });
+ checkCCE(() -> { // array reference class
+ byte x = (byte) vh.compareAndExchangeAcquire(Void.class, 0, (byte)0x01, (byte)0x01);
+ });
+ checkWMTE(() -> { // expected reference class
+ byte x = (byte) vh.compareAndExchangeAcquire(array, 0, Void.class, (byte)0x01);
+ });
+ 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
+ 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
+ byte x = (byte) vh.compareAndExchangeAcquire();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) vh.compareAndExchangeAcquire(array, 0, (byte)0x01, (byte)0x01, Void.class);
+ });
+
+
+ // CompareAndExchangeRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ byte x = (byte) vh.compareAndExchangeRelease(null, 0, (byte)0x01, (byte)0x01);
+ });
+ checkCCE(() -> { // array reference class
+ 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.compareAndExchangeRelease(0, 0, (byte)0x01, (byte)0x01);
+ });
+ checkWMTE(() -> { // index reference class
+ byte x = (byte) vh.compareAndExchangeRelease(array, Void.class, (byte)0x01, (byte)0x01);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeRelease(array, 0, (byte)0x01, (byte)0x01);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, (byte)0x01, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) vh.compareAndExchangeRelease();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) vh.compareAndExchangeRelease(array, 0, (byte)0x01, (byte)0x01, Void.class);
+ });
+
+
+ // GetAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ byte x = (byte) vh.getAndSet(null, 0, (byte)0x01);
+ });
+ checkCCE(() -> { // array reference class
+ byte x = (byte) vh.getAndSet(Void.class, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // value reference class
+ byte x = (byte) vh.getAndSet(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // reciarrayever primitive class
+ byte x = (byte) vh.getAndSet(0, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // index reference class
+ 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
+ byte x = (byte) vh.getAndSet();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) vh.getAndSet(array, 0, (byte)0x01, Void.class);
+ });
+
+ // GetAndAdd
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ byte x = (byte) vh.getAndAdd(null, 0, (byte)0x01);
+ });
+ checkCCE(() -> { // array reference class
+ 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.getAndAdd(0, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // index reference class
+ byte x = (byte) vh.getAndAdd(array, Void.class, (byte)0x01);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndAdd(array, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndAdd(array, 0, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) vh.getAndAdd();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) vh.getAndAdd(array, 0, (byte)0x01, Void.class);
+ });
+
+
+ // AddAndGet
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ byte x = (byte) vh.addAndGet(null, 0, (byte)0x01);
+ });
+ checkCCE(() -> { // array reference class
+ byte x = (byte) vh.addAndGet(Void.class, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // value reference class
+ byte x = (byte) vh.addAndGet(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ byte x = (byte) vh.addAndGet(0, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // index reference class
+ 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
+ byte x = (byte) vh.addAndGet();
+ });
+ checkWMTE(() -> { // >
+ 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
@@ -824,11 +1950,11 @@
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, byte[].class, int.class, byte.class)).
- invokeExact((byte[]) null, 0, (byte)1);
+ invokeExact((byte[]) null, 0, (byte)0x01);
});
hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, byte.class)).
- invokeExact(Void.class, 0, (byte)1);
+ invokeExact(Void.class, 0, (byte)0x01);
});
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)).
@@ -836,11 +1962,11 @@
});
checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, byte.class)).
- invokeExact(0, 0, (byte)1);
+ invokeExact(0, 0, (byte)0x01);
});
checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, byte[].class, Class.class, byte.class)).
- invokeExact(array, Void.class, (byte)1);
+ invokeExact(array, Void.class, (byte)0x01);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -849,10 +1975,175 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)).
- invokeExact(array, 0, (byte)1, Void.class);
+ invokeExact(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, byte[].class, int.class, byte.class, byte.class)).
+ invokeExact((byte[]) null, 0, (byte)0x01, (byte)0x01);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, byte.class, byte.class)).
+ invokeExact(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)).
+ invokeExact(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)).
+ invokeExact(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)).
+ invokeExact(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)).
+ invokeExact(array, Void.class, (byte)0x01, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class, byte.class, byte.class, Class.class)).
+ invokeExact(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, byte[].class, int.class, byte.class, byte.class)).
+ invokeExact((byte[]) null, 0, (byte)0x01, (byte)0x01);
+ });
+ hs.checkWMTEOrCCE(() -> { // array reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class, byte.class, byte.class)).
+ invokeExact(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)).
+ invokeExact(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)).
+ invokeExact(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)).
+ invokeExact(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)).
+ invokeExact(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)).
+ invokeExact(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)).
+ invokeExact(array, 0, (byte)0x01, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) hs.get(am, methodType(byte.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, byte.class, byte.class, Class.class)).
+ invokeExact(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, byte[].class, int.class, byte.class)).
+ invokeExact((byte[]) null, 0, (byte)0x01);
+ });
+ hs.checkWMTEOrCCE(() -> { // array reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class, byte.class)).
+ invokeExact(Void.class, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // value reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class)).
+ invokeExact(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class, byte.class)).
+ invokeExact(0, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // index reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class, byte.class)).
+ invokeExact(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)).
+ invokeExact(array, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class, byte.class)).
+ invokeExact(array, 0, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) hs.get(am, methodType(byte.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, byte.class, Class.class)).
+ invokeExact(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, byte[].class, int.class, byte.class)).
+ invokeExact((byte[]) null, 0, (byte)0x01);
+ });
+ hs.checkWMTEOrCCE(() -> { // array reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class, byte.class)).
+ invokeExact(Void.class, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // value reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class)).
+ invokeExact(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class, byte.class)).
+ invokeExact(0, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // index reference class
+ byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class, byte.class)).
+ invokeExact(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)).
+ invokeExact(array, 0, (byte)0x01);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class, byte.class)).
+ invokeExact(array, 0, (byte)0x01);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ byte x = (byte) hs.get(am, methodType(byte.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, byte.class, Class.class)).
+ invokeExact(array, 0, (byte)0x01, Void.class);
+ });
+ }
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java Wed Jun 15 11:20:15 2016 +0300
@@ -43,13 +43,13 @@
import static java.lang.invoke.MethodType.*;
public class VarHandleTestMethodTypeChar extends VarHandleBaseTest {
- static final char static_final_v = 'a';
+ static final char static_final_v = '\u0123';
- static char static_v = 'a';
+ static char static_v = '\u0123';
- final char final_v = 'a';
+ final char final_v = '\u0123';
- char v = 'a';
+ char v = '\u0123';
VarHandle vhFinalField;
@@ -154,23 +154,23 @@
// Set
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.set(null, 'a');
+ vh.set(null, '\u0123');
});
checkCCE(() -> { // receiver reference class
- vh.set(Void.class, 'a');
+ vh.set(Void.class, '\u0123');
});
checkWMTE(() -> { // value reference class
vh.set(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.set(0, 'a');
+ vh.set(0, '\u0123');
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.set();
});
checkWMTE(() -> { // >
- vh.set(recv, 'a', Void.class);
+ vh.set(recv, '\u0123', Void.class);
});
@@ -204,23 +204,23 @@
// SetVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setVolatile(null, 'a');
+ vh.setVolatile(null, '\u0123');
});
checkCCE(() -> { // receiver reference class
- vh.setVolatile(Void.class, 'a');
+ vh.setVolatile(Void.class, '\u0123');
});
checkWMTE(() -> { // value reference class
vh.setVolatile(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setVolatile(0, 'a');
+ vh.setVolatile(0, '\u0123');
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile(recv, 'a', Void.class);
+ vh.setVolatile(recv, '\u0123', Void.class);
});
@@ -254,23 +254,23 @@
// SetOpaque
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setOpaque(null, 'a');
+ vh.setOpaque(null, '\u0123');
});
checkCCE(() -> { // receiver reference class
- vh.setOpaque(Void.class, 'a');
+ vh.setOpaque(Void.class, '\u0123');
});
checkWMTE(() -> { // value reference class
vh.setOpaque(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setOpaque(0, 'a');
+ vh.setOpaque(0, '\u0123');
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque(recv, 'a', Void.class);
+ vh.setOpaque(recv, '\u0123', Void.class);
});
@@ -304,27 +304,342 @@
// SetRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setRelease(null, 'a');
+ vh.setRelease(null, '\u0123');
});
checkCCE(() -> { // receiver reference class
- vh.setRelease(Void.class, 'a');
+ vh.setRelease(Void.class, '\u0123');
});
checkWMTE(() -> { // value reference class
vh.setRelease(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setRelease(0, 'a');
+ vh.setRelease(0, '\u0123');
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease(recv, 'a', Void.class);
+ vh.setRelease(recv, '\u0123', Void.class);
+ });
+
+
+ // CompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.compareAndSet(null, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.compareAndSet(Void.class, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.compareAndSet(recv, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.compareAndSet(recv, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.compareAndSet(0, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.compareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.compareAndSet(recv, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSet(null, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSet(Void.class, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSet(recv, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSet(recv, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSet(0, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSet(recv, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSetVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetVolatile(null, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetVolatile(recv, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetVolatile(0, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetVolatile(recv, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSetAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetAcquire(null, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetAcquire(recv, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetAcquire(recv, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetAcquire(0, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetAcquire(recv, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSetRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetRelease(null, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetRelease(Void.class, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetRelease(recv, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetRelease(recv, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetRelease(0, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetRelease(recv, '\u0123', '\u0123', Void.class);
});
+ // CompareAndExchangeVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ char x = (char) vh.compareAndExchangeVolatile(null, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ char x = (char) vh.compareAndExchangeVolatile(Void.class, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ char x = (char) vh.compareAndExchangeVolatile(recv, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) vh.compareAndExchangeVolatile(recv, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ char x = (char) vh.compareAndExchangeVolatile(0, '\u0123', '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeVolatile(recv, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(recv, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.compareAndExchangeVolatile();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.compareAndExchangeVolatile(recv, '\u0123', '\u0123', Void.class);
+ });
+
+ // CompareAndExchangeVolatileAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ char x = (char) vh.compareAndExchangeAcquire(null, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ char x = (char) vh.compareAndExchangeAcquire(Void.class, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ char x = (char) vh.compareAndExchangeAcquire(recv, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) vh.compareAndExchangeAcquire(recv, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ char x = (char) vh.compareAndExchangeAcquire(0, '\u0123', '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeAcquire(recv, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(recv, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.compareAndExchangeAcquire();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.compareAndExchangeAcquire(recv, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // CompareAndExchangeRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ char x = (char) vh.compareAndExchangeRelease(null, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ char x = (char) vh.compareAndExchangeRelease(Void.class, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ char x = (char) vh.compareAndExchangeRelease(recv, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) vh.compareAndExchangeRelease(recv, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ char x = (char) vh.compareAndExchangeRelease(0, '\u0123', '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeRelease(recv, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeRelease(recv, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.compareAndExchangeRelease();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.compareAndExchangeRelease(recv, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // GetAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ char x = (char) vh.getAndSet(null, '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ char x = (char) vh.getAndSet(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // value reference class
+ char x = (char) vh.getAndSet(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ char x = (char) vh.getAndSet(0, '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndSet(recv, '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndSet(recv, '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.getAndSet();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.getAndSet(recv, '\u0123', Void.class);
+ });
+
+ // GetAndAdd
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ char x = (char) vh.getAndAdd(null, '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ char x = (char) vh.getAndAdd(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // value reference class
+ char x = (char) vh.getAndAdd(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ char x = (char) vh.getAndAdd(0, '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndAdd(recv, '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndAdd(recv, '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.getAndAdd();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.getAndAdd(recv, '\u0123', Void.class);
+ });
+
+
+ // AddAndGet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ char x = (char) vh.addAndGet(null, '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ char x = (char) vh.addAndGet(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // value reference class
+ char x = (char) vh.addAndGet(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ char x = (char) vh.addAndGet(0, '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.addAndGet(recv, '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.addAndGet(recv, '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.addAndGet();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.addAndGet(recv, '\u0123', Void.class);
+ });
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeChar recv, Handles hs) throws Throwable {
@@ -366,11 +681,11 @@
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, char.class)).
- invokeExact((VarHandleTestMethodTypeChar) null, 'a');
+ invokeExact((VarHandleTestMethodTypeChar) null, '\u0123');
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, char.class)).
- invokeExact(Void.class, 'a');
+ invokeExact(Void.class, '\u0123');
});
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, Class.class)).
@@ -378,7 +693,7 @@
});
checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, char.class)).
- invokeExact(0, 'a');
+ invokeExact(0, '\u0123');
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -387,11 +702,157 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, char.class, Class.class)).
- invokeExact(recv, 'a', Void.class);
+ invokeExact(recv, '\u0123', 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, VarHandleTestMethodTypeChar.class, char.class, char.class)).
+ invokeExact((VarHandleTestMethodTypeChar) null, '\u0123', '\u0123');
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, char.class, char.class)).
+ invokeExact(Void.class, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class, Class.class, char.class)).
+ invokeExact(recv, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class, char.class, Class.class)).
+ invokeExact(recv, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , char.class, char.class)).
+ invokeExact(0, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class, char.class, char.class, Class.class)).
+ invokeExact(recv, '\u0123', '\u0123', Void.class);
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ checkNPE(() -> { // null receiver
+ char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, char.class, char.class)).
+ invokeExact((VarHandleTestMethodTypeChar) null, '\u0123', '\u0123');
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ char x = (char) hs.get(am, methodType(char.class, Class.class, char.class, char.class)).
+ invokeExact(Void.class, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, Class.class, char.class)).
+ invokeExact(recv, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, char.class, Class.class)).
+ invokeExact(recv, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ char x = (char) hs.get(am, methodType(char.class, int.class , char.class, char.class)).
+ invokeExact(0, '\u0123', '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeChar.class , char.class, char.class)).
+ invokeExact(recv, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class , char.class, char.class)).
+ invokeExact(recv, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) hs.get(am, methodType(char.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, char.class, char.class, Class.class)).
+ invokeExact(recv, '\u0123', '\u0123', Void.class);
+ });
+ }
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ checkNPE(() -> { // null receiver
+ char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, char.class)).
+ invokeExact((VarHandleTestMethodTypeChar) null, '\u0123');
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ char x = (char) hs.get(am, methodType(char.class, Class.class, char.class)).
+ invokeExact(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // value reference class
+ char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, Class.class)).
+ invokeExact(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ char x = (char) hs.get(am, methodType(char.class, int.class, char.class)).
+ invokeExact(0, '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeChar.class, char.class)).
+ invokeExact(recv, '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class, char.class)).
+ invokeExact(recv, '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) hs.get(am, methodType(char.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, char.class)).
+ invokeExact(recv, '\u0123', Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ checkNPE(() -> { // null receiver
+ char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, char.class)).
+ invokeExact((VarHandleTestMethodTypeChar) null, '\u0123');
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ char x = (char) hs.get(am, methodType(char.class, Class.class, char.class)).
+ invokeExact(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // value reference class
+ char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, Class.class)).
+ invokeExact(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ char x = (char) hs.get(am, methodType(char.class, int.class, char.class)).
+ invokeExact(0, '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeChar.class, char.class)).
+ invokeExact(recv, '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class, char.class)).
+ invokeExact(recv, '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) hs.get(am, methodType(char.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, char.class)).
+ invokeExact(recv, '\u0123', Void.class);
+ });
+ }
}
@@ -420,7 +881,7 @@
vh.set();
});
checkWMTE(() -> { // >
- vh.set('a', Void.class);
+ vh.set('\u0123', Void.class);
});
@@ -447,7 +908,7 @@
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile('a', Void.class);
+ vh.setVolatile('\u0123', Void.class);
});
@@ -474,7 +935,7 @@
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque('a', Void.class);
+ vh.setOpaque('\u0123', Void.class);
});
@@ -501,11 +962,227 @@
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease('a', Void.class);
+ vh.setRelease('\u0123', Void.class);
+ });
+
+
+ // CompareAndSet
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.compareAndSet(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.compareAndSet('\u0123', Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.compareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.compareAndSet('\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSet
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSet(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSet('\u0123', Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSet('\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSetVolatile
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetVolatile('\u0123', Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetVolatile('\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSetAcquire
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetAcquire('\u0123', Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetAcquire('\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSetRelease
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetRelease(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetRelease('\u0123', Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetRelease('\u0123', '\u0123', Void.class);
});
+ // CompareAndExchangeVolatile
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ char x = (char) vh.compareAndExchangeVolatile(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) vh.compareAndExchangeVolatile('\u0123', Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeVolatile('\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeVolatile('\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.compareAndExchangeVolatile();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.compareAndExchangeVolatile('\u0123', '\u0123', Void.class);
+ });
+
+ // CompareAndExchangeAcquire
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ char x = (char) vh.compareAndExchangeAcquire(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) vh.compareAndExchangeAcquire('\u0123', Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeAcquire('\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeAcquire('\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.compareAndExchangeAcquire();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.compareAndExchangeAcquire('\u0123', '\u0123', Void.class);
+ });
+
+
+ // CompareAndExchangeRelease
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ char x = (char) vh.compareAndExchangeRelease(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) vh.compareAndExchangeRelease('\u0123', Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeRelease('\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeRelease('\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.compareAndExchangeRelease();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.compareAndExchangeRelease('\u0123', '\u0123', Void.class);
+ });
+
+
+ // GetAndSet
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ char x = (char) vh.getAndSet(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndSet('\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndSet('\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.getAndSet();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.getAndSet('\u0123', Void.class);
+ });
+
+ // GetAndAdd
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ char x = (char) vh.getAndAdd(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndAdd('\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndAdd('\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.getAndAdd();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.getAndAdd('\u0123', Void.class);
+ });
+
+
+ // AddAndGet
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ char x = (char) vh.addAndGet(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.addAndGet('\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.addAndGet('\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.addAndGet();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.addAndGet('\u0123', Void.class);
+ });
}
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
@@ -540,16 +1217,117 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, char.class, Class.class)).
- invokeExact('a', Void.class);
+ invokeExact('\u0123', Void.class);
+ });
+ }
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, char.class)).
+ invokeExact(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, char.class, Class.class)).
+ invokeExact('\u0123', Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, char.class, char.class, Class.class)).
+ invokeExact('\u0123', '\u0123', Void.class);
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ char x = (char) hs.get(am, methodType(char.class, Class.class, char.class)).
+ invokeExact(Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) hs.get(am, methodType(char.class, char.class, Class.class)).
+ invokeExact('\u0123', Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, char.class, char.class)).
+ invokeExact('\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, char.class, char.class)).
+ invokeExact('\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) hs.get(am, methodType(char.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) hs.get(am, methodType(char.class, char.class, char.class, Class.class)).
+ invokeExact('\u0123', '\u0123', Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ char x = (char) hs.get(am, methodType(char.class, Class.class)).
+ invokeExact(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, char.class)).
+ invokeExact('\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, char.class)).
+ invokeExact('\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) hs.get(am, methodType(char.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) hs.get(am, methodType(char.class, char.class, Class.class)).
+ invokeExact('\u0123', Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ char x = (char) hs.get(am, methodType(char.class, Class.class)).
+ invokeExact(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, char.class)).
+ invokeExact('\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, char.class)).
+ invokeExact('\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) hs.get(am, methodType(char.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) hs.get(am, methodType(char.class, char.class, Class.class)).
+ invokeExact('\u0123', Void.class);
+ });
+ }
}
static void testArrayWrongMethodType(VarHandle vh) throws Throwable {
char[] array = new char[10];
- Arrays.fill(array, 'a');
+ Arrays.fill(array, '\u0123');
// Get
// Incorrect argument types
@@ -584,26 +1362,26 @@
// Set
// Incorrect argument types
checkNPE(() -> { // null array
- vh.set(null, 0, 'a');
+ vh.set(null, 0, '\u0123');
});
checkCCE(() -> { // array reference class
- vh.set(Void.class, 0, 'a');
+ vh.set(Void.class, 0, '\u0123');
});
checkWMTE(() -> { // value reference class
vh.set(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.set(0, 0, 'a');
+ vh.set(0, 0, '\u0123');
});
checkWMTE(() -> { // index reference class
- vh.set(array, Void.class, 'a');
+ vh.set(array, Void.class, '\u0123');
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.set();
});
checkWMTE(() -> { // >
- vh.set(array, 0, 'a', Void.class);
+ vh.set(array, 0, '\u0123', Void.class);
});
@@ -640,26 +1418,26 @@
// SetVolatile
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setVolatile(null, 0, 'a');
+ vh.setVolatile(null, 0, '\u0123');
});
checkCCE(() -> { // array reference class
- vh.setVolatile(Void.class, 0, 'a');
+ vh.setVolatile(Void.class, 0, '\u0123');
});
checkWMTE(() -> { // value reference class
vh.setVolatile(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setVolatile(0, 0, 'a');
+ vh.setVolatile(0, 0, '\u0123');
});
checkWMTE(() -> { // index reference class
- vh.setVolatile(array, Void.class, 'a');
+ vh.setVolatile(array, Void.class, '\u0123');
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile(array, 0, 'a', Void.class);
+ vh.setVolatile(array, 0, '\u0123', Void.class);
});
@@ -696,26 +1474,26 @@
// SetOpaque
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setOpaque(null, 0, 'a');
+ vh.setOpaque(null, 0, '\u0123');
});
checkCCE(() -> { // array reference class
- vh.setOpaque(Void.class, 0, 'a');
+ vh.setOpaque(Void.class, 0, '\u0123');
});
checkWMTE(() -> { // value reference class
vh.setOpaque(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setOpaque(0, 0, 'a');
+ vh.setOpaque(0, 0, '\u0123');
});
checkWMTE(() -> { // index reference class
- vh.setOpaque(array, Void.class, 'a');
+ vh.setOpaque(array, Void.class, '\u0123');
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque(array, 0, 'a', Void.class);
+ vh.setOpaque(array, 0, '\u0123', Void.class);
});
@@ -752,35 +1530,383 @@
// SetRelease
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setRelease(null, 0, 'a');
+ vh.setRelease(null, 0, '\u0123');
});
checkCCE(() -> { // array reference class
- vh.setRelease(Void.class, 0, 'a');
+ vh.setRelease(Void.class, 0, '\u0123');
});
checkWMTE(() -> { // value reference class
vh.setRelease(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setRelease(0, 0, 'a');
+ vh.setRelease(0, 0, '\u0123');
});
checkWMTE(() -> { // index reference class
- vh.setRelease(array, Void.class, 'a');
+ vh.setRelease(array, Void.class, '\u0123');
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease(array, 0, 'a', Void.class);
+ vh.setRelease(array, 0, '\u0123', Void.class);
+ });
+
+
+ // CompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.compareAndSet(null, 0, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.compareAndSet(Void.class, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.compareAndSet(array, 0, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.compareAndSet(array, 0, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.compareAndSet(0, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.compareAndSet(array, Void.class, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.compareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.compareAndSet(array, 0, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSet(null, 0, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSet(Void.class, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSet(array, 0, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSet(array, 0, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSet(0, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSet(array, Void.class, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSet(array, 0, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSetVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetVolatile(null, 0, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetVolatile(0, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSetVolatile(array, Void.class, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSetAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetAcquire(null, 0, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetAcquire(0, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, Void.class, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // WeakCompareAndSetRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetRelease(null, 0, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetRelease(Void.class, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetRelease(array, 0, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetRelease(array, 0, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetRelease(0, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSetRelease(array, Void.class, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetRelease(array, 0, '\u0123', '\u0123', Void.class);
});
+ // CompareAndExchangeVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ char x = (char) vh.compareAndExchangeVolatile(null, 0, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // array reference class
+ char x = (char) vh.compareAndExchangeVolatile(Void.class, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ char x = (char) vh.compareAndExchangeVolatile(array, 0, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) vh.compareAndExchangeVolatile(array, 0, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ char x = (char) vh.compareAndExchangeVolatile(0, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ char x = (char) vh.compareAndExchangeVolatile(array, Void.class, '\u0123', '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeVolatile(array, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.compareAndExchangeVolatile();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.compareAndExchangeVolatile(array, 0, '\u0123', '\u0123', Void.class);
+ });
+
+ // CompareAndExchangeAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ char x = (char) vh.compareAndExchangeAcquire(null, 0, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // array reference class
+ char x = (char) vh.compareAndExchangeAcquire(Void.class, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ char x = (char) vh.compareAndExchangeAcquire(array, 0, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) vh.compareAndExchangeAcquire(array, 0, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ char x = (char) vh.compareAndExchangeAcquire(0, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ char x = (char) vh.compareAndExchangeAcquire(array, Void.class, '\u0123', '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeAcquire(array, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.compareAndExchangeAcquire();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.compareAndExchangeAcquire(array, 0, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // CompareAndExchangeRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ char x = (char) vh.compareAndExchangeRelease(null, 0, '\u0123', '\u0123');
+ });
+ checkCCE(() -> { // array reference class
+ char x = (char) vh.compareAndExchangeRelease(Void.class, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ char x = (char) vh.compareAndExchangeRelease(array, 0, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) vh.compareAndExchangeRelease(array, 0, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ char x = (char) vh.compareAndExchangeRelease(0, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ char x = (char) vh.compareAndExchangeRelease(array, Void.class, '\u0123', '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeRelease(array, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.compareAndExchangeRelease();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.compareAndExchangeRelease(array, 0, '\u0123', '\u0123', Void.class);
+ });
+
+
+ // GetAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ char x = (char) vh.getAndSet(null, 0, '\u0123');
+ });
+ checkCCE(() -> { // array reference class
+ char x = (char) vh.getAndSet(Void.class, 0, '\u0123');
+ });
+ checkWMTE(() -> { // value reference class
+ char x = (char) vh.getAndSet(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // reciarrayever primitive class
+ char x = (char) vh.getAndSet(0, 0, '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ char x = (char) vh.getAndSet(array, Void.class, '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndSet(array, 0, '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndSet(array, 0, '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.getAndSet();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.getAndSet(array, 0, '\u0123', Void.class);
+ });
+
+ // GetAndAdd
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ char x = (char) vh.getAndAdd(null, 0, '\u0123');
+ });
+ checkCCE(() -> { // array reference class
+ char x = (char) vh.getAndAdd(Void.class, 0, '\u0123');
+ });
+ checkWMTE(() -> { // value reference class
+ char x = (char) vh.getAndAdd(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ char x = (char) vh.getAndAdd(0, 0, '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ char x = (char) vh.getAndAdd(array, Void.class, '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndAdd(array, 0, '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndAdd(array, 0, '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.getAndAdd();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.getAndAdd(array, 0, '\u0123', Void.class);
+ });
+
+
+ // AddAndGet
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ char x = (char) vh.addAndGet(null, 0, '\u0123');
+ });
+ checkCCE(() -> { // array reference class
+ char x = (char) vh.addAndGet(Void.class, 0, '\u0123');
+ });
+ checkWMTE(() -> { // value reference class
+ char x = (char) vh.addAndGet(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ char x = (char) vh.addAndGet(0, 0, '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ char x = (char) vh.addAndGet(array, Void.class, '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.addAndGet(array, 0, '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.addAndGet(array, 0, '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) vh.addAndGet();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) vh.addAndGet(array, 0, '\u0123', Void.class);
+ });
}
static void testArrayWrongMethodType(Handles hs) throws Throwable {
char[] array = new char[10];
- Arrays.fill(array, 'a');
+ Arrays.fill(array, '\u0123');
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
@@ -824,11 +1950,11 @@
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, char[].class, int.class, char.class)).
- invokeExact((char[]) null, 0, 'a');
+ invokeExact((char[]) null, 0, '\u0123');
});
hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, char.class)).
- invokeExact(Void.class, 0, 'a');
+ invokeExact(Void.class, 0, '\u0123');
});
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, char[].class, int.class, Class.class)).
@@ -836,11 +1962,11 @@
});
checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, char.class)).
- invokeExact(0, 0, 'a');
+ invokeExact(0, 0, '\u0123');
});
checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, char[].class, Class.class, char.class)).
- invokeExact(array, Void.class, 'a');
+ invokeExact(array, Void.class, '\u0123');
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -849,10 +1975,175 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, char[].class, int.class, Class.class)).
- invokeExact(array, 0, 'a', Void.class);
+ invokeExact(array, 0, '\u0123', 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, char[].class, int.class, char.class, char.class)).
+ invokeExact((char[]) null, 0, '\u0123', '\u0123');
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, char.class, char.class)).
+ invokeExact(Void.class, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class, Class.class, char.class)).
+ invokeExact(array, 0, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class, char.class, Class.class)).
+ invokeExact(array, 0, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, char.class, char.class)).
+ invokeExact(0, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, char[].class, Class.class, char.class, char.class)).
+ invokeExact(array, Void.class, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class, char.class, char.class, Class.class)).
+ invokeExact(array, 0, '\u0123', '\u0123', Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, char.class, char.class)).
+ invokeExact((char[]) null, 0, '\u0123', '\u0123');
+ });
+ hs.checkWMTEOrCCE(() -> { // array reference class
+ char x = (char) hs.get(am, methodType(char.class, Class.class, int.class, char.class, char.class)).
+ invokeExact(Void.class, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // expected reference class
+ char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, Class.class, char.class)).
+ invokeExact(array, 0, Void.class, '\u0123');
+ });
+ checkWMTE(() -> { // actual reference class
+ char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, char.class, Class.class)).
+ invokeExact(array, 0, '\u0123', Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ char x = (char) hs.get(am, methodType(char.class, int.class, int.class, char.class, char.class)).
+ invokeExact(0, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ char x = (char) hs.get(am, methodType(char.class, char[].class, Class.class, char.class, char.class)).
+ invokeExact(array, Void.class, '\u0123', '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, char[].class, int.class, char.class, char.class)).
+ invokeExact(array, 0, '\u0123', '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class, char.class, char.class)).
+ invokeExact(array, 0, '\u0123', '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) hs.get(am, methodType(char.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, char.class, char.class, Class.class)).
+ invokeExact(array, 0, '\u0123', '\u0123', Void.class);
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, char.class)).
+ invokeExact((char[]) null, 0, '\u0123');
+ });
+ hs.checkWMTEOrCCE(() -> { // array reference class
+ char x = (char) hs.get(am, methodType(char.class, Class.class, int.class, char.class)).
+ invokeExact(Void.class, 0, '\u0123');
+ });
+ checkWMTE(() -> { // value reference class
+ char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, Class.class)).
+ invokeExact(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ char x = (char) hs.get(am, methodType(char.class, int.class, int.class, char.class)).
+ invokeExact(0, 0, '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ char x = (char) hs.get(am, methodType(char.class, char[].class, Class.class, char.class)).
+ invokeExact(array, Void.class, '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, char[].class, int.class, char.class)).
+ invokeExact(array, 0, '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class, char.class)).
+ invokeExact(array, 0, '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) hs.get(am, methodType(char.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, char.class, Class.class)).
+ invokeExact(array, 0, '\u0123', Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, char.class)).
+ invokeExact((char[]) null, 0, '\u0123');
+ });
+ hs.checkWMTEOrCCE(() -> { // array reference class
+ char x = (char) hs.get(am, methodType(char.class, Class.class, int.class, char.class)).
+ invokeExact(Void.class, 0, '\u0123');
+ });
+ checkWMTE(() -> { // value reference class
+ char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, Class.class)).
+ invokeExact(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ char x = (char) hs.get(am, methodType(char.class, int.class, int.class, char.class)).
+ invokeExact(0, 0, '\u0123');
+ });
+ checkWMTE(() -> { // index reference class
+ char x = (char) hs.get(am, methodType(char.class, char[].class, Class.class, char.class)).
+ invokeExact(array, Void.class, '\u0123');
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, char[].class, int.class, char.class)).
+ invokeExact(array, 0, '\u0123');
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class, char.class)).
+ invokeExact(array, 0, '\u0123');
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ char x = (char) hs.get(am, methodType(char.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, char.class, Class.class)).
+ invokeExact(array, 0, '\u0123', Void.class);
+ });
+ }
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java Wed Jun 15 11:20:15 2016 +0300
@@ -43,13 +43,13 @@
import static java.lang.invoke.MethodType.*;
public class VarHandleTestMethodTypeInt extends VarHandleBaseTest {
- static final int static_final_v = 1;
+ static final int static_final_v = 0x01234567;
- static int static_v = 1;
+ static int static_v = 0x01234567;
- final int final_v = 1;
+ final int final_v = 0x01234567;
- int v = 1;
+ int v = 0x01234567;
VarHandle vhFinalField;
@@ -154,23 +154,23 @@
// Set
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.set(null, 1);
+ vh.set(null, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- vh.set(Void.class, 1);
+ vh.set(Void.class, 0x01234567);
});
checkWMTE(() -> { // value reference class
vh.set(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.set(0, 1);
+ vh.set(0, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.set();
});
checkWMTE(() -> { // >
- vh.set(recv, 1, Void.class);
+ vh.set(recv, 0x01234567, Void.class);
});
@@ -204,23 +204,23 @@
// SetVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setVolatile(null, 1);
+ vh.setVolatile(null, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- vh.setVolatile(Void.class, 1);
+ vh.setVolatile(Void.class, 0x01234567);
});
checkWMTE(() -> { // value reference class
vh.setVolatile(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setVolatile(0, 1);
+ vh.setVolatile(0, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile(recv, 1, Void.class);
+ vh.setVolatile(recv, 0x01234567, Void.class);
});
@@ -254,23 +254,23 @@
// SetOpaque
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setOpaque(null, 1);
+ vh.setOpaque(null, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- vh.setOpaque(Void.class, 1);
+ vh.setOpaque(Void.class, 0x01234567);
});
checkWMTE(() -> { // value reference class
vh.setOpaque(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setOpaque(0, 1);
+ vh.setOpaque(0, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque(recv, 1, Void.class);
+ vh.setOpaque(recv, 0x01234567, Void.class);
});
@@ -304,341 +304,341 @@
// SetRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setRelease(null, 1);
+ vh.setRelease(null, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- vh.setRelease(Void.class, 1);
+ vh.setRelease(Void.class, 0x01234567);
});
checkWMTE(() -> { // value reference class
vh.setRelease(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setRelease(0, 1);
+ vh.setRelease(0, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease(recv, 1, Void.class);
+ vh.setRelease(recv, 0x01234567, Void.class);
});
// CompareAndSet
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.compareAndSet(null, 1, 1);
+ boolean r = vh.compareAndSet(null, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.compareAndSet(Void.class, 1, 1);
+ boolean r = vh.compareAndSet(Void.class, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.compareAndSet(recv, Void.class, 1);
+ boolean r = vh.compareAndSet(recv, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.compareAndSet(recv, 1, Void.class);
+ boolean r = vh.compareAndSet(recv, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.compareAndSet(0, 1, 1);
+ boolean r = vh.compareAndSet(0, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.compareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.compareAndSet(recv, 1, 1, Void.class);
+ boolean r = vh.compareAndSet(recv, 0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSet
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSet(null, 1, 1);
+ boolean r = vh.weakCompareAndSet(null, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSet(Void.class, 1, 1);
+ boolean r = vh.weakCompareAndSet(Void.class, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSet(recv, Void.class, 1);
+ boolean r = vh.weakCompareAndSet(recv, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSet(recv, 1, Void.class);
+ boolean r = vh.weakCompareAndSet(recv, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSet(0, 1, 1);
+ boolean r = vh.weakCompareAndSet(0, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSet(recv, 1, 1, Void.class);
+ boolean r = vh.weakCompareAndSet(recv, 0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSetVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetVolatile(null, 1, 1);
+ boolean r = vh.weakCompareAndSetVolatile(null, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetVolatile(Void.class, 1, 1);
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 1);
+ boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetVolatile(recv, 1, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(recv, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetVolatile(0, 1, 1);
+ boolean r = vh.weakCompareAndSetVolatile(0, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetVolatile();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetVolatile(recv, 1, 1, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(recv, 0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSetAcquire
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetAcquire(null, 1, 1);
+ boolean r = vh.weakCompareAndSetAcquire(null, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetAcquire(Void.class, 1, 1);
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetAcquire(recv, Void.class, 1);
+ boolean r = vh.weakCompareAndSetAcquire(recv, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetAcquire(recv, 1, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(recv, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetAcquire(0, 1, 1);
+ boolean r = vh.weakCompareAndSetAcquire(0, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetAcquire();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetAcquire(recv, 1, 1, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(recv, 0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSetRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetRelease(null, 1, 1);
+ boolean r = vh.weakCompareAndSetRelease(null, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetRelease(Void.class, 1, 1);
+ boolean r = vh.weakCompareAndSetRelease(Void.class, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetRelease(recv, Void.class, 1);
+ boolean r = vh.weakCompareAndSetRelease(recv, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetRelease(recv, 1, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(recv, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetRelease(0, 1, 1);
+ boolean r = vh.weakCompareAndSetRelease(0, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetRelease();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetRelease(recv, 1, 1, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(recv, 0x01234567, 0x01234567, Void.class);
});
// CompareAndExchangeVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- int x = (int) vh.compareAndExchangeVolatile(null, 1, 1);
+ int x = (int) vh.compareAndExchangeVolatile(null, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- int x = (int) vh.compareAndExchangeVolatile(Void.class, 1, 1);
+ int x = (int) vh.compareAndExchangeVolatile(Void.class, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- int x = (int) vh.compareAndExchangeVolatile(recv, Void.class, 1);
+ int x = (int) vh.compareAndExchangeVolatile(recv, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- int x = (int) vh.compareAndExchangeVolatile(recv, 1, Void.class);
+ int x = (int) vh.compareAndExchangeVolatile(recv, 0x01234567, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- int x = (int) vh.compareAndExchangeVolatile(0, 1, 1);
+ int x = (int) vh.compareAndExchangeVolatile(0, 0x01234567, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeVolatile(recv, 1, 1);
+ Void r = (Void) vh.compareAndExchangeVolatile(recv, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeVolatile(recv, 1, 1);
+ boolean x = (boolean) vh.compareAndExchangeVolatile(recv, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.compareAndExchangeVolatile();
});
checkWMTE(() -> { // >
- int x = (int) vh.compareAndExchangeVolatile(recv, 1, 1, Void.class);
+ int x = (int) vh.compareAndExchangeVolatile(recv, 0x01234567, 0x01234567, Void.class);
});
// CompareAndExchangeVolatileAcquire
// Incorrect argument types
checkNPE(() -> { // null receiver
- int x = (int) vh.compareAndExchangeAcquire(null, 1, 1);
+ int x = (int) vh.compareAndExchangeAcquire(null, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- int x = (int) vh.compareAndExchangeAcquire(Void.class, 1, 1);
+ int x = (int) vh.compareAndExchangeAcquire(Void.class, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- int x = (int) vh.compareAndExchangeAcquire(recv, Void.class, 1);
+ int x = (int) vh.compareAndExchangeAcquire(recv, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- int x = (int) vh.compareAndExchangeAcquire(recv, 1, Void.class);
+ int x = (int) vh.compareAndExchangeAcquire(recv, 0x01234567, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- int x = (int) vh.compareAndExchangeAcquire(0, 1, 1);
+ int x = (int) vh.compareAndExchangeAcquire(0, 0x01234567, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeAcquire(recv, 1, 1);
+ Void r = (Void) vh.compareAndExchangeAcquire(recv, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeAcquire(recv, 1, 1);
+ boolean x = (boolean) vh.compareAndExchangeAcquire(recv, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.compareAndExchangeAcquire();
});
checkWMTE(() -> { // >
- int x = (int) vh.compareAndExchangeAcquire(recv, 1, 1, Void.class);
+ int x = (int) vh.compareAndExchangeAcquire(recv, 0x01234567, 0x01234567, Void.class);
});
// CompareAndExchangeRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- int x = (int) vh.compareAndExchangeRelease(null, 1, 1);
+ int x = (int) vh.compareAndExchangeRelease(null, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- int x = (int) vh.compareAndExchangeRelease(Void.class, 1, 1);
+ int x = (int) vh.compareAndExchangeRelease(Void.class, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- int x = (int) vh.compareAndExchangeRelease(recv, Void.class, 1);
+ int x = (int) vh.compareAndExchangeRelease(recv, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- int x = (int) vh.compareAndExchangeRelease(recv, 1, Void.class);
+ int x = (int) vh.compareAndExchangeRelease(recv, 0x01234567, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- int x = (int) vh.compareAndExchangeRelease(0, 1, 1);
+ int x = (int) vh.compareAndExchangeRelease(0, 0x01234567, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeRelease(recv, 1, 1);
+ Void r = (Void) vh.compareAndExchangeRelease(recv, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeRelease(recv, 1, 1);
+ boolean x = (boolean) vh.compareAndExchangeRelease(recv, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.compareAndExchangeRelease();
});
checkWMTE(() -> { // >
- int x = (int) vh.compareAndExchangeRelease(recv, 1, 1, Void.class);
+ int x = (int) vh.compareAndExchangeRelease(recv, 0x01234567, 0x01234567, Void.class);
});
// GetAndSet
// Incorrect argument types
checkNPE(() -> { // null receiver
- int x = (int) vh.getAndSet(null, 1);
+ int x = (int) vh.getAndSet(null, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- int x = (int) vh.getAndSet(Void.class, 1);
+ int x = (int) vh.getAndSet(Void.class, 0x01234567);
});
checkWMTE(() -> { // value reference class
int x = (int) vh.getAndSet(recv, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- int x = (int) vh.getAndSet(0, 1);
+ int x = (int) vh.getAndSet(0, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndSet(recv, 1);
+ Void r = (Void) vh.getAndSet(recv, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndSet(recv, 1);
+ boolean x = (boolean) vh.getAndSet(recv, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.getAndSet();
});
checkWMTE(() -> { // >
- int x = (int) vh.getAndSet(recv, 1, Void.class);
+ int x = (int) vh.getAndSet(recv, 0x01234567, Void.class);
});
// GetAndAdd
// Incorrect argument types
checkNPE(() -> { // null receiver
- int x = (int) vh.getAndAdd(null, 1);
+ int x = (int) vh.getAndAdd(null, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- int x = (int) vh.getAndAdd(Void.class, 1);
+ int x = (int) vh.getAndAdd(Void.class, 0x01234567);
});
checkWMTE(() -> { // value reference class
int x = (int) vh.getAndAdd(recv, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- int x = (int) vh.getAndAdd(0, 1);
+ int x = (int) vh.getAndAdd(0, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndAdd(recv, 1);
+ Void r = (Void) vh.getAndAdd(recv, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndAdd(recv, 1);
+ boolean x = (boolean) vh.getAndAdd(recv, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.getAndAdd();
});
checkWMTE(() -> { // >
- int x = (int) vh.getAndAdd(recv, 1, Void.class);
+ int x = (int) vh.getAndAdd(recv, 0x01234567, Void.class);
});
// AddAndGet
// Incorrect argument types
checkNPE(() -> { // null receiver
- int x = (int) vh.addAndGet(null, 1);
+ int x = (int) vh.addAndGet(null, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- int x = (int) vh.addAndGet(Void.class, 1);
+ int x = (int) vh.addAndGet(Void.class, 0x01234567);
});
checkWMTE(() -> { // value reference class
int x = (int) vh.addAndGet(recv, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- int x = (int) vh.addAndGet(0, 1);
+ int x = (int) vh.addAndGet(0, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.addAndGet(recv, 1);
+ Void r = (Void) vh.addAndGet(recv, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.addAndGet(recv, 1);
+ boolean x = (boolean) vh.addAndGet(recv, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.addAndGet();
});
checkWMTE(() -> { // >
- int x = (int) vh.addAndGet(recv, 1, Void.class);
+ int x = (int) vh.addAndGet(recv, 0x01234567, Void.class);
});
}
@@ -681,11 +681,11 @@
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class)).
- invokeExact((VarHandleTestMethodTypeInt) null, 1);
+ invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, int.class)).
- invokeExact(Void.class, 1);
+ invokeExact(Void.class, 0x01234567);
});
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, Class.class)).
@@ -693,7 +693,7 @@
});
checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class)).
- invokeExact(0, 1);
+ invokeExact(0, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -702,7 +702,7 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
- invokeExact(recv, 1, Void.class);
+ invokeExact(recv, 0x01234567, Void.class);
});
}
@@ -710,23 +710,23 @@
// Incorrect argument types
checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class)).
- invokeExact((VarHandleTestMethodTypeInt) null, 1, 1);
+ invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567, 0x01234567);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class)).
- invokeExact(Void.class, 1, 1);
+ invokeExact(Void.class, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)).
- invokeExact(recv, Void.class, 1);
+ invokeExact(recv, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
- invokeExact(recv, 1, Void.class);
+ invokeExact(recv, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , int.class, int.class)).
- invokeExact(0, 1, 1);
+ invokeExact(0, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -735,39 +735,39 @@
});
checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)).
- invokeExact(recv, 1, 1, Void.class);
+ invokeExact(recv, 0x01234567, 0x01234567, Void.class);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class)).
- invokeExact((VarHandleTestMethodTypeInt) null, 1, 1);
+ invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567, 0x01234567);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
- invokeExact(Void.class, 1, 1);
+ invokeExact(Void.class, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)).
- invokeExact(recv, Void.class, 1);
+ invokeExact(recv, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)).
- invokeExact(recv, 1, Void.class);
+ invokeExact(recv, 0x01234567, Void.class);
});
checkWMTE(() -> { // reciever primitive class
int x = (int) hs.get(am, methodType(int.class, int.class , int.class, int.class)).
- invokeExact(0, 1, 1);
+ invokeExact(0, 0x01234567, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class , int.class, int.class)).
- invokeExact(recv, 1, 1);
+ invokeExact(recv, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class , int.class, int.class)).
- invokeExact(recv, 1, 1);
+ invokeExact(recv, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -776,18 +776,18 @@
});
checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)).
- invokeExact(recv, 1, 1, Void.class);
+ invokeExact(recv, 0x01234567, 0x01234567, Void.class);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
- invokeExact((VarHandleTestMethodTypeInt) null, 1);
+ invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
- invokeExact(Void.class, 1);
+ invokeExact(Void.class, 0x01234567);
});
checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
@@ -795,16 +795,16 @@
});
checkWMTE(() -> { // reciever primitive class
int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
- invokeExact(0, 1);
+ invokeExact(0, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)).
- invokeExact(recv, 1);
+ invokeExact(recv, 0x01234567);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)).
- invokeExact(recv, 1);
+ invokeExact(recv, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -813,18 +813,18 @@
});
checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
- invokeExact(recv, 1, Void.class);
+ invokeExact(recv, 0x01234567, Void.class);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
- invokeExact((VarHandleTestMethodTypeInt) null, 1);
+ invokeExact((VarHandleTestMethodTypeInt) null, 0x01234567);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
- invokeExact(Void.class, 1);
+ invokeExact(Void.class, 0x01234567);
});
checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)).
@@ -832,16 +832,16 @@
});
checkWMTE(() -> { // reciever primitive class
int x = (int) hs.get(am, methodType(int.class, int.class, int.class)).
- invokeExact(0, 1);
+ invokeExact(0, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)).
- invokeExact(recv, 1);
+ invokeExact(recv, 0x01234567);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)).
- invokeExact(recv, 1);
+ invokeExact(recv, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -850,7 +850,7 @@
});
checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)).
- invokeExact(recv, 1, Void.class);
+ invokeExact(recv, 0x01234567, Void.class);
});
}
}
@@ -881,7 +881,7 @@
vh.set();
});
checkWMTE(() -> { // >
- vh.set(1, Void.class);
+ vh.set(0x01234567, Void.class);
});
@@ -908,7 +908,7 @@
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile(1, Void.class);
+ vh.setVolatile(0x01234567, Void.class);
});
@@ -935,7 +935,7 @@
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque(1, Void.class);
+ vh.setOpaque(0x01234567, Void.class);
});
@@ -962,164 +962,164 @@
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease(1, Void.class);
+ vh.setRelease(0x01234567, Void.class);
});
// CompareAndSet
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- boolean r = vh.compareAndSet(Void.class, 1);
+ boolean r = vh.compareAndSet(Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.compareAndSet(1, Void.class);
+ boolean r = vh.compareAndSet(0x01234567, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.compareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.compareAndSet(1, 1, Void.class);
+ boolean r = vh.compareAndSet(0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSet
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSet(Void.class, 1);
+ boolean r = vh.weakCompareAndSet(Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSet(1, Void.class);
+ boolean r = vh.weakCompareAndSet(0x01234567, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSet(1, 1, Void.class);
+ boolean r = vh.weakCompareAndSet(0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSetVolatile
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetVolatile(Void.class, 1);
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetVolatile(1, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(0x01234567, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetVolatile();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetVolatile(1, 1, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSetAcquire
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetAcquire(Void.class, 1);
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetAcquire(1, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(0x01234567, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetAcquire();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetAcquire(1, 1, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSetRelease
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetRelease(Void.class, 1);
+ boolean r = vh.weakCompareAndSetRelease(Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetRelease(1, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(0x01234567, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetRelease();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetRelease(1, 1, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(0x01234567, 0x01234567, Void.class);
});
// CompareAndExchangeVolatile
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- int x = (int) vh.compareAndExchangeVolatile(Void.class, 1);
+ int x = (int) vh.compareAndExchangeVolatile(Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- int x = (int) vh.compareAndExchangeVolatile(1, Void.class);
+ int x = (int) vh.compareAndExchangeVolatile(0x01234567, Void.class);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeVolatile(1, 1);
+ Void r = (Void) vh.compareAndExchangeVolatile(0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeVolatile(1, 1);
+ boolean x = (boolean) vh.compareAndExchangeVolatile(0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.compareAndExchangeVolatile();
});
checkWMTE(() -> { // >
- int x = (int) vh.compareAndExchangeVolatile(1, 1, Void.class);
+ int x = (int) vh.compareAndExchangeVolatile(0x01234567, 0x01234567, Void.class);
});
// CompareAndExchangeAcquire
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- int x = (int) vh.compareAndExchangeAcquire(Void.class, 1);
+ int x = (int) vh.compareAndExchangeAcquire(Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- int x = (int) vh.compareAndExchangeAcquire(1, Void.class);
+ int x = (int) vh.compareAndExchangeAcquire(0x01234567, Void.class);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeAcquire(1, 1);
+ Void r = (Void) vh.compareAndExchangeAcquire(0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeAcquire(1, 1);
+ boolean x = (boolean) vh.compareAndExchangeAcquire(0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.compareAndExchangeAcquire();
});
checkWMTE(() -> { // >
- int x = (int) vh.compareAndExchangeAcquire(1, 1, Void.class);
+ int x = (int) vh.compareAndExchangeAcquire(0x01234567, 0x01234567, Void.class);
});
// CompareAndExchangeRelease
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- int x = (int) vh.compareAndExchangeRelease(Void.class, 1);
+ int x = (int) vh.compareAndExchangeRelease(Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- int x = (int) vh.compareAndExchangeRelease(1, Void.class);
+ int x = (int) vh.compareAndExchangeRelease(0x01234567, Void.class);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeRelease(1, 1);
+ Void r = (Void) vh.compareAndExchangeRelease(0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeRelease(1, 1);
+ boolean x = (boolean) vh.compareAndExchangeRelease(0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.compareAndExchangeRelease();
});
checkWMTE(() -> { // >
- int x = (int) vh.compareAndExchangeRelease(1, 1, Void.class);
+ int x = (int) vh.compareAndExchangeRelease(0x01234567, 0x01234567, Void.class);
});
@@ -1130,17 +1130,17 @@
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndSet(1);
+ Void r = (Void) vh.getAndSet(0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndSet(1);
+ boolean x = (boolean) vh.getAndSet(0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.getAndSet();
});
checkWMTE(() -> { // >
- int x = (int) vh.getAndSet(1, Void.class);
+ int x = (int) vh.getAndSet(0x01234567, Void.class);
});
// GetAndAdd
@@ -1150,17 +1150,17 @@
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndAdd(1);
+ Void r = (Void) vh.getAndAdd(0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndAdd(1);
+ boolean x = (boolean) vh.getAndAdd(0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.getAndAdd();
});
checkWMTE(() -> { // >
- int x = (int) vh.getAndAdd(1, Void.class);
+ int x = (int) vh.getAndAdd(0x01234567, Void.class);
});
@@ -1171,17 +1171,17 @@
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.addAndGet(1);
+ Void r = (Void) vh.addAndGet(0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.addAndGet(1);
+ boolean x = (boolean) vh.addAndGet(0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.addAndGet();
});
checkWMTE(() -> { // >
- int x = (int) vh.addAndGet(1, Void.class);
+ int x = (int) vh.addAndGet(0x01234567, Void.class);
});
}
@@ -1217,18 +1217,18 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, int.class, Class.class)).
- invokeExact(1, Void.class);
+ invokeExact(0x01234567, Void.class);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)).
- invokeExact(Void.class, 1);
+ invokeExact(Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, Class.class)).
- invokeExact(1, Void.class);
+ invokeExact(0x01234567, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -1237,7 +1237,7 @@
});
checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, Class.class)).
- invokeExact(1, 1, Void.class);
+ invokeExact(0x01234567, 0x01234567, Void.class);
});
}
@@ -1245,20 +1245,20 @@
// Incorrect argument types
checkWMTE(() -> { // expected reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)).
- invokeExact(Void.class, 1);
+ invokeExact(Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
- invokeExact(1, Void.class);
+ invokeExact(0x01234567, Void.class);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int.class, int.class)).
- invokeExact(1, 1);
+ invokeExact(0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)).
- invokeExact(1, 1);
+ invokeExact(0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -1267,7 +1267,7 @@
});
checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int.class, int.class, Class.class)).
- invokeExact(1, 1, Void.class);
+ invokeExact(0x01234567, 0x01234567, Void.class);
});
}
@@ -1280,11 +1280,11 @@
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int.class)).
- invokeExact(1);
+ invokeExact(0x01234567);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
- invokeExact(1);
+ invokeExact(0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -1293,7 +1293,7 @@
});
checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
- invokeExact(1, Void.class);
+ invokeExact(0x01234567, Void.class);
});
}
@@ -1306,11 +1306,11 @@
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int.class)).
- invokeExact(1);
+ invokeExact(0x01234567);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)).
- invokeExact(1);
+ invokeExact(0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -1319,7 +1319,7 @@
});
checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)).
- invokeExact(1, Void.class);
+ invokeExact(0x01234567, Void.class);
});
}
}
@@ -1327,7 +1327,7 @@
static void testArrayWrongMethodType(VarHandle vh) throws Throwable {
int[] array = new int[10];
- Arrays.fill(array, 1);
+ Arrays.fill(array, 0x01234567);
// Get
// Incorrect argument types
@@ -1362,26 +1362,26 @@
// Set
// Incorrect argument types
checkNPE(() -> { // null array
- vh.set(null, 0, 1);
+ vh.set(null, 0, 0x01234567);
});
checkCCE(() -> { // array reference class
- vh.set(Void.class, 0, 1);
+ vh.set(Void.class, 0, 0x01234567);
});
checkWMTE(() -> { // value reference class
vh.set(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.set(0, 0, 1);
+ vh.set(0, 0, 0x01234567);
});
checkWMTE(() -> { // index reference class
- vh.set(array, Void.class, 1);
+ vh.set(array, Void.class, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.set();
});
checkWMTE(() -> { // >
- vh.set(array, 0, 1, Void.class);
+ vh.set(array, 0, 0x01234567, Void.class);
});
@@ -1418,26 +1418,26 @@
// SetVolatile
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setVolatile(null, 0, 1);
+ vh.setVolatile(null, 0, 0x01234567);
});
checkCCE(() -> { // array reference class
- vh.setVolatile(Void.class, 0, 1);
+ vh.setVolatile(Void.class, 0, 0x01234567);
});
checkWMTE(() -> { // value reference class
vh.setVolatile(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setVolatile(0, 0, 1);
+ vh.setVolatile(0, 0, 0x01234567);
});
checkWMTE(() -> { // index reference class
- vh.setVolatile(array, Void.class, 1);
+ vh.setVolatile(array, Void.class, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile(array, 0, 1, Void.class);
+ vh.setVolatile(array, 0, 0x01234567, Void.class);
});
@@ -1474,26 +1474,26 @@
// SetOpaque
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setOpaque(null, 0, 1);
+ vh.setOpaque(null, 0, 0x01234567);
});
checkCCE(() -> { // array reference class
- vh.setOpaque(Void.class, 0, 1);
+ vh.setOpaque(Void.class, 0, 0x01234567);
});
checkWMTE(() -> { // value reference class
vh.setOpaque(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setOpaque(0, 0, 1);
+ vh.setOpaque(0, 0, 0x01234567);
});
checkWMTE(() -> { // index reference class
- vh.setOpaque(array, Void.class, 1);
+ vh.setOpaque(array, Void.class, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque(array, 0, 1, Void.class);
+ vh.setOpaque(array, 0, 0x01234567, Void.class);
});
@@ -1530,383 +1530,383 @@
// SetRelease
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setRelease(null, 0, 1);
+ vh.setRelease(null, 0, 0x01234567);
});
checkCCE(() -> { // array reference class
- vh.setRelease(Void.class, 0, 1);
+ vh.setRelease(Void.class, 0, 0x01234567);
});
checkWMTE(() -> { // value reference class
vh.setRelease(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setRelease(0, 0, 1);
+ vh.setRelease(0, 0, 0x01234567);
});
checkWMTE(() -> { // index reference class
- vh.setRelease(array, Void.class, 1);
+ vh.setRelease(array, Void.class, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease(array, 0, 1, Void.class);
+ vh.setRelease(array, 0, 0x01234567, Void.class);
});
// CompareAndSet
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.compareAndSet(null, 0, 1, 1);
+ boolean r = vh.compareAndSet(null, 0, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.compareAndSet(Void.class, 0, 1, 1);
+ boolean r = vh.compareAndSet(Void.class, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.compareAndSet(array, 0, Void.class, 1);
+ boolean r = vh.compareAndSet(array, 0, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.compareAndSet(array, 0, 1, Void.class);
+ boolean r = vh.compareAndSet(array, 0, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.compareAndSet(0, 0, 1, 1);
+ boolean r = vh.compareAndSet(0, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // index reference class
- boolean r = vh.compareAndSet(array, Void.class, 1, 1);
+ boolean r = vh.compareAndSet(array, Void.class, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.compareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.compareAndSet(array, 0, 1, 1, Void.class);
+ boolean r = vh.compareAndSet(array, 0, 0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSet
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSet(null, 0, 1, 1);
+ boolean r = vh.weakCompareAndSet(null, 0, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSet(Void.class, 0, 1, 1);
+ boolean r = vh.weakCompareAndSet(Void.class, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSet(array, 0, Void.class, 1);
+ boolean r = vh.weakCompareAndSet(array, 0, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSet(array, 0, 1, Void.class);
+ boolean r = vh.weakCompareAndSet(array, 0, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSet(0, 0, 1, 1);
+ boolean r = vh.weakCompareAndSet(0, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // index reference class
- boolean r = vh.weakCompareAndSet(array, Void.class, 1, 1);
+ boolean r = vh.weakCompareAndSet(array, Void.class, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSet(array, 0, 1, 1, Void.class);
+ boolean r = vh.weakCompareAndSet(array, 0, 0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSetVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetVolatile(null, 0, 1, 1);
+ boolean r = vh.weakCompareAndSetVolatile(null, 0, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 1, 1);
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 1);
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetVolatile(array, 0, 1, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetVolatile(0, 0, 1, 1);
+ boolean r = vh.weakCompareAndSetVolatile(0, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // index reference class
- boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 1, 1);
+ boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetVolatile();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetVolatile(array, 0, 1, 1, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSetAcquire
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetAcquire(null, 0, 1, 1);
+ boolean r = vh.weakCompareAndSetAcquire(null, 0, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, 1, 1);
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, 1);
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetAcquire(array, 0, 1, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetAcquire(0, 0, 1, 1);
+ boolean r = vh.weakCompareAndSetAcquire(0, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // index reference class
- boolean r = vh.weakCompareAndSetAcquire(array, Void.class, 1, 1);
+ boolean r = vh.weakCompareAndSetAcquire(array, Void.class, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetAcquire();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetAcquire(array, 0, 1, 1, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, 0x01234567, 0x01234567, Void.class);
});
// WeakCompareAndSetRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetRelease(null, 0, 1, 1);
+ boolean r = vh.weakCompareAndSetRelease(null, 0, 0x01234567, 0x01234567);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetRelease(Void.class, 0, 1, 1);
+ boolean r = vh.weakCompareAndSetRelease(Void.class, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetRelease(array, 0, Void.class, 1);
+ boolean r = vh.weakCompareAndSetRelease(array, 0, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetRelease(array, 0, 1, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(array, 0, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetRelease(0, 0, 1, 1);
+ boolean r = vh.weakCompareAndSetRelease(0, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // index reference class
- boolean r = vh.weakCompareAndSetRelease(array, Void.class, 1, 1);
+ boolean r = vh.weakCompareAndSetRelease(array, Void.class, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetRelease();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetRelease(array, 0, 1, 1, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(array, 0, 0x01234567, 0x01234567, Void.class);
});
// CompareAndExchangeVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- int x = (int) vh.compareAndExchangeVolatile(null, 0, 1, 1);
+ int x = (int) vh.compareAndExchangeVolatile(null, 0, 0x01234567, 0x01234567);
});
checkCCE(() -> { // array reference class
- int x = (int) vh.compareAndExchangeVolatile(Void.class, 0, 1, 1);
+ int x = (int) vh.compareAndExchangeVolatile(Void.class, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- int x = (int) vh.compareAndExchangeVolatile(array, 0, Void.class, 1);
+ int x = (int) vh.compareAndExchangeVolatile(array, 0, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- int x = (int) vh.compareAndExchangeVolatile(array, 0, 1, Void.class);
+ int x = (int) vh.compareAndExchangeVolatile(array, 0, 0x01234567, Void.class);
});
checkWMTE(() -> { // array primitive class
- int x = (int) vh.compareAndExchangeVolatile(0, 0, 1, 1);
+ int x = (int) vh.compareAndExchangeVolatile(0, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // index reference class
- int x = (int) vh.compareAndExchangeVolatile(array, Void.class, 1, 1);
+ int x = (int) vh.compareAndExchangeVolatile(array, Void.class, 0x01234567, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeVolatile(array, 0, 1, 1);
+ Void r = (Void) vh.compareAndExchangeVolatile(array, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, 1, 1);
+ boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.compareAndExchangeVolatile();
});
checkWMTE(() -> { // >
- int x = (int) vh.compareAndExchangeVolatile(array, 0, 1, 1, Void.class);
+ int x = (int) vh.compareAndExchangeVolatile(array, 0, 0x01234567, 0x01234567, Void.class);
});
// CompareAndExchangeAcquire
// Incorrect argument types
checkNPE(() -> { // null receiver
- int x = (int) vh.compareAndExchangeAcquire(null, 0, 1, 1);
+ int x = (int) vh.compareAndExchangeAcquire(null, 0, 0x01234567, 0x01234567);
});
checkCCE(() -> { // array reference class
- int x = (int) vh.compareAndExchangeAcquire(Void.class, 0, 1, 1);
+ int x = (int) vh.compareAndExchangeAcquire(Void.class, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- int x = (int) vh.compareAndExchangeAcquire(array, 0, Void.class, 1);
+ int x = (int) vh.compareAndExchangeAcquire(array, 0, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- int x = (int) vh.compareAndExchangeAcquire(array, 0, 1, Void.class);
+ int x = (int) vh.compareAndExchangeAcquire(array, 0, 0x01234567, Void.class);
});
checkWMTE(() -> { // array primitive class
- int x = (int) vh.compareAndExchangeAcquire(0, 0, 1, 1);
+ int x = (int) vh.compareAndExchangeAcquire(0, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // index reference class
- int x = (int) vh.compareAndExchangeAcquire(array, Void.class, 1, 1);
+ int x = (int) vh.compareAndExchangeAcquire(array, Void.class, 0x01234567, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeAcquire(array, 0, 1, 1);
+ Void r = (Void) vh.compareAndExchangeAcquire(array, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, 1, 1);
+ boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.compareAndExchangeAcquire();
});
checkWMTE(() -> { // >
- int x = (int) vh.compareAndExchangeAcquire(array, 0, 1, 1, Void.class);
+ int x = (int) vh.compareAndExchangeAcquire(array, 0, 0x01234567, 0x01234567, Void.class);
});
// CompareAndExchangeRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- int x = (int) vh.compareAndExchangeRelease(null, 0, 1, 1);
+ int x = (int) vh.compareAndExchangeRelease(null, 0, 0x01234567, 0x01234567);
});
checkCCE(() -> { // array reference class
- int x = (int) vh.compareAndExchangeRelease(Void.class, 0, 1, 1);
+ int x = (int) vh.compareAndExchangeRelease(Void.class, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
- int x = (int) vh.compareAndExchangeRelease(array, 0, Void.class, 1);
+ int x = (int) vh.compareAndExchangeRelease(array, 0, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
- int x = (int) vh.compareAndExchangeRelease(array, 0, 1, Void.class);
+ int x = (int) vh.compareAndExchangeRelease(array, 0, 0x01234567, Void.class);
});
checkWMTE(() -> { // array primitive class
- int x = (int) vh.compareAndExchangeRelease(0, 0, 1, 1);
+ int x = (int) vh.compareAndExchangeRelease(0, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // index reference class
- int x = (int) vh.compareAndExchangeRelease(array, Void.class, 1, 1);
+ int x = (int) vh.compareAndExchangeRelease(array, Void.class, 0x01234567, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeRelease(array, 0, 1, 1);
+ Void r = (Void) vh.compareAndExchangeRelease(array, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, 1, 1);
+ boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.compareAndExchangeRelease();
});
checkWMTE(() -> { // >
- int x = (int) vh.compareAndExchangeRelease(array, 0, 1, 1, Void.class);
+ int x = (int) vh.compareAndExchangeRelease(array, 0, 0x01234567, 0x01234567, Void.class);
});
// GetAndSet
// Incorrect argument types
checkNPE(() -> { // null array
- int x = (int) vh.getAndSet(null, 0, 1);
+ int x = (int) vh.getAndSet(null, 0, 0x01234567);
});
checkCCE(() -> { // array reference class
- int x = (int) vh.getAndSet(Void.class, 0, 1);
+ int x = (int) vh.getAndSet(Void.class, 0, 0x01234567);
});
checkWMTE(() -> { // value reference class
int x = (int) vh.getAndSet(array, 0, Void.class);
});
checkWMTE(() -> { // reciarrayever primitive class
- int x = (int) vh.getAndSet(0, 0, 1);
+ int x = (int) vh.getAndSet(0, 0, 0x01234567);
});
checkWMTE(() -> { // index reference class
- int x = (int) vh.getAndSet(array, Void.class, 1);
+ int x = (int) vh.getAndSet(array, Void.class, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndSet(array, 0, 1);
+ Void r = (Void) vh.getAndSet(array, 0, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndSet(array, 0, 1);
+ boolean x = (boolean) vh.getAndSet(array, 0, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.getAndSet();
});
checkWMTE(() -> { // >
- int x = (int) vh.getAndSet(array, 0, 1, Void.class);
+ int x = (int) vh.getAndSet(array, 0, 0x01234567, Void.class);
});
// GetAndAdd
// Incorrect argument types
checkNPE(() -> { // null array
- int x = (int) vh.getAndAdd(null, 0, 1);
+ int x = (int) vh.getAndAdd(null, 0, 0x01234567);
});
checkCCE(() -> { // array reference class
- int x = (int) vh.getAndAdd(Void.class, 0, 1);
+ int x = (int) vh.getAndAdd(Void.class, 0, 0x01234567);
});
checkWMTE(() -> { // value reference class
int x = (int) vh.getAndAdd(array, 0, Void.class);
});
checkWMTE(() -> { // array primitive class
- int x = (int) vh.getAndAdd(0, 0, 1);
+ int x = (int) vh.getAndAdd(0, 0, 0x01234567);
});
checkWMTE(() -> { // index reference class
- int x = (int) vh.getAndAdd(array, Void.class, 1);
+ int x = (int) vh.getAndAdd(array, Void.class, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndAdd(array, 0, 1);
+ Void r = (Void) vh.getAndAdd(array, 0, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndAdd(array, 0, 1);
+ boolean x = (boolean) vh.getAndAdd(array, 0, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.getAndAdd();
});
checkWMTE(() -> { // >
- int x = (int) vh.getAndAdd(array, 0, 1, Void.class);
+ int x = (int) vh.getAndAdd(array, 0, 0x01234567, Void.class);
});
// AddAndGet
// Incorrect argument types
checkNPE(() -> { // null array
- int x = (int) vh.addAndGet(null, 0, 1);
+ int x = (int) vh.addAndGet(null, 0, 0x01234567);
});
checkCCE(() -> { // array reference class
- int x = (int) vh.addAndGet(Void.class, 0, 1);
+ int x = (int) vh.addAndGet(Void.class, 0, 0x01234567);
});
checkWMTE(() -> { // value reference class
int x = (int) vh.addAndGet(array, 0, Void.class);
});
checkWMTE(() -> { // array primitive class
- int x = (int) vh.addAndGet(0, 0, 1);
+ int x = (int) vh.addAndGet(0, 0, 0x01234567);
});
checkWMTE(() -> { // index reference class
- int x = (int) vh.addAndGet(array, Void.class, 1);
+ int x = (int) vh.addAndGet(array, Void.class, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.addAndGet(array, 0, 1);
+ Void r = (Void) vh.addAndGet(array, 0, 0x01234567);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.addAndGet(array, 0, 1);
+ boolean x = (boolean) vh.addAndGet(array, 0, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
int x = (int) vh.addAndGet();
});
checkWMTE(() -> { // >
- int x = (int) vh.addAndGet(array, 0, 1, Void.class);
+ int x = (int) vh.addAndGet(array, 0, 0x01234567, Void.class);
});
}
static void testArrayWrongMethodType(Handles hs) throws Throwable {
int[] array = new int[10];
- Arrays.fill(array, 1);
+ Arrays.fill(array, 0x01234567);
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
@@ -1950,11 +1950,11 @@
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, int[].class, int.class, int.class)).
- invokeExact((int[]) null, 0, 1);
+ invokeExact((int[]) null, 0, 0x01234567);
});
hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, int.class)).
- invokeExact(Void.class, 0, 1);
+ invokeExact(Void.class, 0, 0x01234567);
});
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, int[].class, int.class, Class.class)).
@@ -1962,11 +1962,11 @@
});
checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, int.class)).
- invokeExact(0, 0, 1);
+ invokeExact(0, 0, 0x01234567);
});
checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, int[].class, Class.class, int.class)).
- invokeExact(array, Void.class, 1);
+ invokeExact(array, Void.class, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -1975,34 +1975,34 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, int[].class, int.class, Class.class)).
- invokeExact(array, 0, 1, Void.class);
+ invokeExact(array, 0, 0x01234567, 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, int[].class, int.class, int.class, int.class)).
- invokeExact((int[]) null, 0, 1, 1);
+ invokeExact((int[]) null, 0, 0x01234567, 0x01234567);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class, int.class)).
- invokeExact(Void.class, 0, 1, 1);
+ invokeExact(Void.class, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, Class.class, int.class)).
- invokeExact(array, 0, Void.class, 1);
+ invokeExact(array, 0, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, Class.class)).
- invokeExact(array, 0, 1, Void.class);
+ invokeExact(array, 0, 0x01234567, Void.class);
});
checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, int.class, int.class)).
- invokeExact(0, 0, 1, 1);
+ invokeExact(0, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // index reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, Class.class, int.class, int.class)).
- invokeExact(array, Void.class, 1, 1);
+ invokeExact(array, Void.class, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -2011,7 +2011,7 @@
});
checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class, Class.class)).
- invokeExact(array, 0, 1, 1, Void.class);
+ invokeExact(array, 0, 0x01234567, 0x01234567, Void.class);
});
}
@@ -2019,36 +2019,36 @@
// Incorrect argument types
checkNPE(() -> { // null receiver
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class)).
- invokeExact((int[]) null, 0, 1, 1);
+ invokeExact((int[]) null, 0, 0x01234567, 0x01234567);
});
hs.checkWMTEOrCCE(() -> { // array reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class, int.class)).
- invokeExact(Void.class, 0, 1, 1);
+ invokeExact(Void.class, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // expected reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class, int.class)).
- invokeExact(array, 0, Void.class, 1);
+ invokeExact(array, 0, Void.class, 0x01234567);
});
checkWMTE(() -> { // actual reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
- invokeExact(array, 0, 1, Void.class);
+ invokeExact(array, 0, 0x01234567, Void.class);
});
checkWMTE(() -> { // array primitive class
int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class, int.class)).
- invokeExact(0, 0, 1, 1);
+ invokeExact(0, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // index reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class, int.class)).
- invokeExact(array, Void.class, 1, 1);
+ invokeExact(array, Void.class, 0x01234567, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class, int.class)).
- invokeExact(array, 0, 1, 1);
+ invokeExact(array, 0, 0x01234567, 0x01234567);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)).
- invokeExact(array, 0, 1, 1);
+ invokeExact(array, 0, 0x01234567, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -2057,7 +2057,7 @@
});
checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class, Class.class)).
- invokeExact(array, 0, 1, 1, Void.class);
+ invokeExact(array, 0, 0x01234567, 0x01234567, Void.class);
});
}
@@ -2065,11 +2065,11 @@
// Incorrect argument types
checkNPE(() -> { // null array
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)).
- invokeExact((int[]) null, 0, 1);
+ invokeExact((int[]) null, 0, 0x01234567);
});
hs.checkWMTEOrCCE(() -> { // array reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
- invokeExact(Void.class, 0, 1);
+ invokeExact(Void.class, 0, 0x01234567);
});
checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
@@ -2077,20 +2077,20 @@
});
checkWMTE(() -> { // array primitive class
int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)).
- invokeExact(0, 0, 1);
+ invokeExact(0, 0, 0x01234567);
});
checkWMTE(() -> { // index reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)).
- invokeExact(array, Void.class, 1);
+ invokeExact(array, Void.class, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)).
- invokeExact(array, 0, 1);
+ invokeExact(array, 0, 0x01234567);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)).
- invokeExact(array, 0, 1);
+ invokeExact(array, 0, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -2099,7 +2099,7 @@
});
checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
- invokeExact(array, 0, 1, Void.class);
+ invokeExact(array, 0, 0x01234567, Void.class);
});
}
@@ -2107,11 +2107,11 @@
// Incorrect argument types
checkNPE(() -> { // null array
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)).
- invokeExact((int[]) null, 0, 1);
+ invokeExact((int[]) null, 0, 0x01234567);
});
hs.checkWMTEOrCCE(() -> { // array reference class
int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)).
- invokeExact(Void.class, 0, 1);
+ invokeExact(Void.class, 0, 0x01234567);
});
checkWMTE(() -> { // value reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)).
@@ -2119,20 +2119,20 @@
});
checkWMTE(() -> { // array primitive class
int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)).
- invokeExact(0, 0, 1);
+ invokeExact(0, 0, 0x01234567);
});
checkWMTE(() -> { // index reference class
int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)).
- invokeExact(array, Void.class, 1);
+ invokeExact(array, Void.class, 0x01234567);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)).
- invokeExact(array, 0, 1);
+ invokeExact(array, 0, 0x01234567);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)).
- invokeExact(array, 0, 1);
+ invokeExact(array, 0, 0x01234567);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -2141,7 +2141,7 @@
});
checkWMTE(() -> { // >
int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)).
- invokeExact(array, 0, 1, Void.class);
+ invokeExact(array, 0, 0x01234567, Void.class);
});
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java Wed Jun 15 11:20:15 2016 +0300
@@ -43,13 +43,13 @@
import static java.lang.invoke.MethodType.*;
public class VarHandleTestMethodTypeLong extends VarHandleBaseTest {
- static final long static_final_v = 1L;
+ static final long static_final_v = 0x0123456789ABCDEFL;
- static long static_v = 1L;
+ static long static_v = 0x0123456789ABCDEFL;
- final long final_v = 1L;
+ final long final_v = 0x0123456789ABCDEFL;
- long v = 1L;
+ long v = 0x0123456789ABCDEFL;
VarHandle vhFinalField;
@@ -154,23 +154,23 @@
// Set
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.set(null, 1L);
+ vh.set(null, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- vh.set(Void.class, 1L);
+ vh.set(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
vh.set(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.set(0, 1L);
+ vh.set(0, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.set();
});
checkWMTE(() -> { // >
- vh.set(recv, 1L, Void.class);
+ vh.set(recv, 0x0123456789ABCDEFL, Void.class);
});
@@ -204,23 +204,23 @@
// SetVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setVolatile(null, 1L);
+ vh.setVolatile(null, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- vh.setVolatile(Void.class, 1L);
+ vh.setVolatile(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
vh.setVolatile(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setVolatile(0, 1L);
+ vh.setVolatile(0, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile(recv, 1L, Void.class);
+ vh.setVolatile(recv, 0x0123456789ABCDEFL, Void.class);
});
@@ -254,23 +254,23 @@
// SetOpaque
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setOpaque(null, 1L);
+ vh.setOpaque(null, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- vh.setOpaque(Void.class, 1L);
+ vh.setOpaque(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
vh.setOpaque(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setOpaque(0, 1L);
+ vh.setOpaque(0, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque(recv, 1L, Void.class);
+ vh.setOpaque(recv, 0x0123456789ABCDEFL, Void.class);
});
@@ -304,341 +304,341 @@
// SetRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setRelease(null, 1L);
+ vh.setRelease(null, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- vh.setRelease(Void.class, 1L);
+ vh.setRelease(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
vh.setRelease(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setRelease(0, 1L);
+ vh.setRelease(0, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease(recv, 1L, Void.class);
+ vh.setRelease(recv, 0x0123456789ABCDEFL, Void.class);
});
// CompareAndSet
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.compareAndSet(null, 1L, 1L);
+ boolean r = vh.compareAndSet(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.compareAndSet(Void.class, 1L, 1L);
+ boolean r = vh.compareAndSet(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.compareAndSet(recv, Void.class, 1L);
+ boolean r = vh.compareAndSet(recv, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.compareAndSet(recv, 1L, Void.class);
+ boolean r = vh.compareAndSet(recv, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.compareAndSet(0, 1L, 1L);
+ boolean r = vh.compareAndSet(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.compareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.compareAndSet(recv, 1L, 1L, Void.class);
+ boolean r = vh.compareAndSet(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSet
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSet(null, 1L, 1L);
+ boolean r = vh.weakCompareAndSet(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSet(Void.class, 1L, 1L);
+ boolean r = vh.weakCompareAndSet(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSet(recv, Void.class, 1L);
+ boolean r = vh.weakCompareAndSet(recv, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSet(recv, 1L, Void.class);
+ boolean r = vh.weakCompareAndSet(recv, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSet(0, 1L, 1L);
+ boolean r = vh.weakCompareAndSet(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSet(recv, 1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSet(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSetVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetVolatile(null, 1L, 1L);
+ boolean r = vh.weakCompareAndSetVolatile(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetVolatile(Void.class, 1L, 1L);
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 1L);
+ boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetVolatile(recv, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(recv, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetVolatile(0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetVolatile(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetVolatile();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetVolatile(recv, 1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSetAcquire
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetAcquire(null, 1L, 1L);
+ boolean r = vh.weakCompareAndSetAcquire(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetAcquire(Void.class, 1L, 1L);
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetAcquire(recv, Void.class, 1L);
+ boolean r = vh.weakCompareAndSetAcquire(recv, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetAcquire(recv, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(recv, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetAcquire(0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetAcquire(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetAcquire();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetAcquire(recv, 1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSetRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetRelease(null, 1L, 1L);
+ boolean r = vh.weakCompareAndSetRelease(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetRelease(Void.class, 1L, 1L);
+ boolean r = vh.weakCompareAndSetRelease(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetRelease(recv, Void.class, 1L);
+ boolean r = vh.weakCompareAndSetRelease(recv, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetRelease(recv, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(recv, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetRelease(0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetRelease(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetRelease();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetRelease(recv, 1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// CompareAndExchangeVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- long x = (long) vh.compareAndExchangeVolatile(null, 1L, 1L);
+ long x = (long) vh.compareAndExchangeVolatile(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- long x = (long) vh.compareAndExchangeVolatile(Void.class, 1L, 1L);
+ long x = (long) vh.compareAndExchangeVolatile(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- long x = (long) vh.compareAndExchangeVolatile(recv, Void.class, 1L);
+ long x = (long) vh.compareAndExchangeVolatile(recv, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- long x = (long) vh.compareAndExchangeVolatile(recv, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeVolatile(recv, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- long x = (long) vh.compareAndExchangeVolatile(0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeVolatile(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeVolatile(recv, 1L, 1L);
+ Void r = (Void) vh.compareAndExchangeVolatile(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeVolatile(recv, 1L, 1L);
+ boolean x = (boolean) vh.compareAndExchangeVolatile(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.compareAndExchangeVolatile();
});
checkWMTE(() -> { // >
- long x = (long) vh.compareAndExchangeVolatile(recv, 1L, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeVolatile(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// CompareAndExchangeVolatileAcquire
// Incorrect argument types
checkNPE(() -> { // null receiver
- long x = (long) vh.compareAndExchangeAcquire(null, 1L, 1L);
+ long x = (long) vh.compareAndExchangeAcquire(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- long x = (long) vh.compareAndExchangeAcquire(Void.class, 1L, 1L);
+ long x = (long) vh.compareAndExchangeAcquire(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- long x = (long) vh.compareAndExchangeAcquire(recv, Void.class, 1L);
+ long x = (long) vh.compareAndExchangeAcquire(recv, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- long x = (long) vh.compareAndExchangeAcquire(recv, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeAcquire(recv, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- long x = (long) vh.compareAndExchangeAcquire(0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeAcquire(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeAcquire(recv, 1L, 1L);
+ Void r = (Void) vh.compareAndExchangeAcquire(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeAcquire(recv, 1L, 1L);
+ boolean x = (boolean) vh.compareAndExchangeAcquire(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.compareAndExchangeAcquire();
});
checkWMTE(() -> { // >
- long x = (long) vh.compareAndExchangeAcquire(recv, 1L, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeAcquire(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// CompareAndExchangeRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- long x = (long) vh.compareAndExchangeRelease(null, 1L, 1L);
+ long x = (long) vh.compareAndExchangeRelease(null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- long x = (long) vh.compareAndExchangeRelease(Void.class, 1L, 1L);
+ long x = (long) vh.compareAndExchangeRelease(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- long x = (long) vh.compareAndExchangeRelease(recv, Void.class, 1L);
+ long x = (long) vh.compareAndExchangeRelease(recv, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- long x = (long) vh.compareAndExchangeRelease(recv, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeRelease(recv, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- long x = (long) vh.compareAndExchangeRelease(0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeRelease(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeRelease(recv, 1L, 1L);
+ Void r = (Void) vh.compareAndExchangeRelease(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeRelease(recv, 1L, 1L);
+ boolean x = (boolean) vh.compareAndExchangeRelease(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.compareAndExchangeRelease();
});
checkWMTE(() -> { // >
- long x = (long) vh.compareAndExchangeRelease(recv, 1L, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeRelease(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// GetAndSet
// Incorrect argument types
checkNPE(() -> { // null receiver
- long x = (long) vh.getAndSet(null, 1L);
+ long x = (long) vh.getAndSet(null, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- long x = (long) vh.getAndSet(Void.class, 1L);
+ long x = (long) vh.getAndSet(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
long x = (long) vh.getAndSet(recv, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- long x = (long) vh.getAndSet(0, 1L);
+ long x = (long) vh.getAndSet(0, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndSet(recv, 1L);
+ Void r = (Void) vh.getAndSet(recv, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndSet(recv, 1L);
+ boolean x = (boolean) vh.getAndSet(recv, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.getAndSet();
});
checkWMTE(() -> { // >
- long x = (long) vh.getAndSet(recv, 1L, Void.class);
+ long x = (long) vh.getAndSet(recv, 0x0123456789ABCDEFL, Void.class);
});
// GetAndAdd
// Incorrect argument types
checkNPE(() -> { // null receiver
- long x = (long) vh.getAndAdd(null, 1L);
+ long x = (long) vh.getAndAdd(null, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- long x = (long) vh.getAndAdd(Void.class, 1L);
+ long x = (long) vh.getAndAdd(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
long x = (long) vh.getAndAdd(recv, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- long x = (long) vh.getAndAdd(0, 1L);
+ long x = (long) vh.getAndAdd(0, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndAdd(recv, 1L);
+ Void r = (Void) vh.getAndAdd(recv, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndAdd(recv, 1L);
+ boolean x = (boolean) vh.getAndAdd(recv, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.getAndAdd();
});
checkWMTE(() -> { // >
- long x = (long) vh.getAndAdd(recv, 1L, Void.class);
+ long x = (long) vh.getAndAdd(recv, 0x0123456789ABCDEFL, Void.class);
});
// AddAndGet
// Incorrect argument types
checkNPE(() -> { // null receiver
- long x = (long) vh.addAndGet(null, 1L);
+ long x = (long) vh.addAndGet(null, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- long x = (long) vh.addAndGet(Void.class, 1L);
+ long x = (long) vh.addAndGet(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
long x = (long) vh.addAndGet(recv, Void.class);
});
checkWMTE(() -> { // reciever primitive class
- long x = (long) vh.addAndGet(0, 1L);
+ long x = (long) vh.addAndGet(0, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.addAndGet(recv, 1L);
+ Void r = (Void) vh.addAndGet(recv, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.addAndGet(recv, 1L);
+ boolean x = (boolean) vh.addAndGet(recv, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.addAndGet();
});
checkWMTE(() -> { // >
- long x = (long) vh.addAndGet(recv, 1L, Void.class);
+ long x = (long) vh.addAndGet(recv, 0x0123456789ABCDEFL, Void.class);
});
}
@@ -681,11 +681,11 @@
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, long.class)).
- invokeExact((VarHandleTestMethodTypeLong) null, 1L);
+ invokeExact((VarHandleTestMethodTypeLong) null, 0x0123456789ABCDEFL);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, long.class)).
- invokeExact(Void.class, 1L);
+ invokeExact(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, Class.class)).
@@ -693,7 +693,7 @@
});
checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, long.class)).
- invokeExact(0, 1L);
+ invokeExact(0, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -702,7 +702,7 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
- invokeExact(recv, 1L, Void.class);
+ invokeExact(recv, 0x0123456789ABCDEFL, Void.class);
});
}
@@ -710,23 +710,23 @@
// Incorrect argument types
checkNPE(() -> { // null receiver
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, long.class)).
- invokeExact((VarHandleTestMethodTypeLong) null, 1L, 1L);
+ invokeExact((VarHandleTestMethodTypeLong) null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class, long.class)).
- invokeExact(Void.class, 1L, 1L);
+ invokeExact(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)).
- invokeExact(recv, Void.class, 1L);
+ invokeExact(recv, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
- invokeExact(recv, 1L, Void.class);
+ invokeExact(recv, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , long.class, long.class)).
- invokeExact(0, 1L, 1L);
+ invokeExact(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -735,39 +735,39 @@
});
checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)).
- invokeExact(recv, 1L, 1L, Void.class);
+ invokeExact(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, long.class)).
- invokeExact((VarHandleTestMethodTypeLong) null, 1L, 1L);
+ invokeExact((VarHandleTestMethodTypeLong) null, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, long.class, long.class)).
- invokeExact(Void.class, 1L, 1L);
+ invokeExact(Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)).
- invokeExact(recv, Void.class, 1L);
+ invokeExact(recv, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)).
- invokeExact(recv, 1L, Void.class);
+ invokeExact(recv, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // reciever primitive class
long x = (long) hs.get(am, methodType(long.class, int.class , long.class, long.class)).
- invokeExact(0, 1L, 1L);
+ invokeExact(0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class , long.class, long.class)).
- invokeExact(recv, 1L, 1L);
+ invokeExact(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class , long.class, long.class)).
- invokeExact(recv, 1L, 1L);
+ invokeExact(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -776,18 +776,18 @@
});
checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)).
- invokeExact(recv, 1L, 1L, Void.class);
+ invokeExact(recv, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
- invokeExact((VarHandleTestMethodTypeLong) null, 1L);
+ invokeExact((VarHandleTestMethodTypeLong) null, 0x0123456789ABCDEFL);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
- invokeExact(Void.class, 1L);
+ invokeExact(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)).
@@ -795,16 +795,16 @@
});
checkWMTE(() -> { // reciever primitive class
long x = (long) hs.get(am, methodType(long.class, int.class, long.class)).
- invokeExact(0, 1L);
+ invokeExact(0, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)).
- invokeExact(recv, 1L);
+ invokeExact(recv, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)).
- invokeExact(recv, 1L);
+ invokeExact(recv, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -813,18 +813,18 @@
});
checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
- invokeExact(recv, 1L, Void.class);
+ invokeExact(recv, 0x0123456789ABCDEFL, Void.class);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
- invokeExact((VarHandleTestMethodTypeLong) null, 1L);
+ invokeExact((VarHandleTestMethodTypeLong) null, 0x0123456789ABCDEFL);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
- invokeExact(Void.class, 1L);
+ invokeExact(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)).
@@ -832,16 +832,16 @@
});
checkWMTE(() -> { // reciever primitive class
long x = (long) hs.get(am, methodType(long.class, int.class, long.class)).
- invokeExact(0, 1L);
+ invokeExact(0, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)).
- invokeExact(recv, 1L);
+ invokeExact(recv, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)).
- invokeExact(recv, 1L);
+ invokeExact(recv, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -850,7 +850,7 @@
});
checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)).
- invokeExact(recv, 1L, Void.class);
+ invokeExact(recv, 0x0123456789ABCDEFL, Void.class);
});
}
}
@@ -881,7 +881,7 @@
vh.set();
});
checkWMTE(() -> { // >
- vh.set(1L, Void.class);
+ vh.set(0x0123456789ABCDEFL, Void.class);
});
@@ -908,7 +908,7 @@
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile(1L, Void.class);
+ vh.setVolatile(0x0123456789ABCDEFL, Void.class);
});
@@ -935,7 +935,7 @@
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque(1L, Void.class);
+ vh.setOpaque(0x0123456789ABCDEFL, Void.class);
});
@@ -962,164 +962,164 @@
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease(1L, Void.class);
+ vh.setRelease(0x0123456789ABCDEFL, Void.class);
});
// CompareAndSet
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- boolean r = vh.compareAndSet(Void.class, 1L);
+ boolean r = vh.compareAndSet(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.compareAndSet(1L, Void.class);
+ boolean r = vh.compareAndSet(0x0123456789ABCDEFL, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.compareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.compareAndSet(1L, 1L, Void.class);
+ boolean r = vh.compareAndSet(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSet
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSet(Void.class, 1L);
+ boolean r = vh.weakCompareAndSet(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSet(1L, Void.class);
+ boolean r = vh.weakCompareAndSet(0x0123456789ABCDEFL, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSet(1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSet(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSetVolatile
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetVolatile(Void.class, 1L);
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetVolatile(1L, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(0x0123456789ABCDEFL, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetVolatile();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetVolatile(1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSetAcquire
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetAcquire(Void.class, 1L);
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetAcquire(1L, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(0x0123456789ABCDEFL, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetAcquire();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetAcquire(1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSetRelease
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetRelease(Void.class, 1L);
+ boolean r = vh.weakCompareAndSetRelease(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetRelease(1L, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(0x0123456789ABCDEFL, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetRelease();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetRelease(1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// CompareAndExchangeVolatile
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- long x = (long) vh.compareAndExchangeVolatile(Void.class, 1L);
+ long x = (long) vh.compareAndExchangeVolatile(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- long x = (long) vh.compareAndExchangeVolatile(1L, Void.class);
+ long x = (long) vh.compareAndExchangeVolatile(0x0123456789ABCDEFL, Void.class);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeVolatile(1L, 1L);
+ Void r = (Void) vh.compareAndExchangeVolatile(0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeVolatile(1L, 1L);
+ boolean x = (boolean) vh.compareAndExchangeVolatile(0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.compareAndExchangeVolatile();
});
checkWMTE(() -> { // >
- long x = (long) vh.compareAndExchangeVolatile(1L, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeVolatile(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// CompareAndExchangeAcquire
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- long x = (long) vh.compareAndExchangeAcquire(Void.class, 1L);
+ long x = (long) vh.compareAndExchangeAcquire(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- long x = (long) vh.compareAndExchangeAcquire(1L, Void.class);
+ long x = (long) vh.compareAndExchangeAcquire(0x0123456789ABCDEFL, Void.class);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeAcquire(1L, 1L);
+ Void r = (Void) vh.compareAndExchangeAcquire(0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeAcquire(1L, 1L);
+ boolean x = (boolean) vh.compareAndExchangeAcquire(0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.compareAndExchangeAcquire();
});
checkWMTE(() -> { // >
- long x = (long) vh.compareAndExchangeAcquire(1L, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeAcquire(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// CompareAndExchangeRelease
// Incorrect argument types
checkWMTE(() -> { // expected reference class
- long x = (long) vh.compareAndExchangeRelease(Void.class, 1L);
+ long x = (long) vh.compareAndExchangeRelease(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- long x = (long) vh.compareAndExchangeRelease(1L, Void.class);
+ long x = (long) vh.compareAndExchangeRelease(0x0123456789ABCDEFL, Void.class);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeRelease(1L, 1L);
+ Void r = (Void) vh.compareAndExchangeRelease(0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeRelease(1L, 1L);
+ boolean x = (boolean) vh.compareAndExchangeRelease(0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.compareAndExchangeRelease();
});
checkWMTE(() -> { // >
- long x = (long) vh.compareAndExchangeRelease(1L, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeRelease(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
@@ -1130,17 +1130,17 @@
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndSet(1L);
+ Void r = (Void) vh.getAndSet(0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndSet(1L);
+ boolean x = (boolean) vh.getAndSet(0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.getAndSet();
});
checkWMTE(() -> { // >
- long x = (long) vh.getAndSet(1L, Void.class);
+ long x = (long) vh.getAndSet(0x0123456789ABCDEFL, Void.class);
});
// GetAndAdd
@@ -1150,17 +1150,17 @@
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndAdd(1L);
+ Void r = (Void) vh.getAndAdd(0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndAdd(1L);
+ boolean x = (boolean) vh.getAndAdd(0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.getAndAdd();
});
checkWMTE(() -> { // >
- long x = (long) vh.getAndAdd(1L, Void.class);
+ long x = (long) vh.getAndAdd(0x0123456789ABCDEFL, Void.class);
});
@@ -1171,17 +1171,17 @@
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.addAndGet(1L);
+ Void r = (Void) vh.addAndGet(0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.addAndGet(1L);
+ boolean x = (boolean) vh.addAndGet(0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.addAndGet();
});
checkWMTE(() -> { // >
- long x = (long) vh.addAndGet(1L, Void.class);
+ long x = (long) vh.addAndGet(0x0123456789ABCDEFL, Void.class);
});
}
@@ -1217,18 +1217,18 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, long.class, Class.class)).
- invokeExact(1L, Void.class);
+ invokeExact(0x0123456789ABCDEFL, Void.class);
});
}
for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
// Incorrect argument types
checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class)).
- invokeExact(Void.class, 1L);
+ invokeExact(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, Class.class)).
- invokeExact(1L, Void.class);
+ invokeExact(0x0123456789ABCDEFL, Void.class);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -1237,7 +1237,7 @@
});
checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class, Class.class)).
- invokeExact(1L, 1L, Void.class);
+ invokeExact(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
}
@@ -1245,20 +1245,20 @@
// Incorrect argument types
checkWMTE(() -> { // expected reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)).
- invokeExact(Void.class, 1L);
+ invokeExact(Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
- invokeExact(1L, Void.class);
+ invokeExact(0x0123456789ABCDEFL, Void.class);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long.class, long.class)).
- invokeExact(1L, 1L);
+ invokeExact(0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class)).
- invokeExact(1L, 1L);
+ invokeExact(0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -1267,7 +1267,7 @@
});
checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long.class, long.class, Class.class)).
- invokeExact(1L, 1L, Void.class);
+ invokeExact(0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
}
@@ -1280,11 +1280,11 @@
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long.class)).
- invokeExact(1L);
+ invokeExact(0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)).
- invokeExact(1L);
+ invokeExact(0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -1293,7 +1293,7 @@
});
checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
- invokeExact(1L, Void.class);
+ invokeExact(0x0123456789ABCDEFL, Void.class);
});
}
@@ -1306,11 +1306,11 @@
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long.class)).
- invokeExact(1L);
+ invokeExact(0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)).
- invokeExact(1L);
+ invokeExact(0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -1319,7 +1319,7 @@
});
checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)).
- invokeExact(1L, Void.class);
+ invokeExact(0x0123456789ABCDEFL, Void.class);
});
}
}
@@ -1327,7 +1327,7 @@
static void testArrayWrongMethodType(VarHandle vh) throws Throwable {
long[] array = new long[10];
- Arrays.fill(array, 1L);
+ Arrays.fill(array, 0x0123456789ABCDEFL);
// Get
// Incorrect argument types
@@ -1362,26 +1362,26 @@
// Set
// Incorrect argument types
checkNPE(() -> { // null array
- vh.set(null, 0, 1L);
+ vh.set(null, 0, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // array reference class
- vh.set(Void.class, 0, 1L);
+ vh.set(Void.class, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
vh.set(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.set(0, 0, 1L);
+ vh.set(0, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- vh.set(array, Void.class, 1L);
+ vh.set(array, Void.class, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.set();
});
checkWMTE(() -> { // >
- vh.set(array, 0, 1L, Void.class);
+ vh.set(array, 0, 0x0123456789ABCDEFL, Void.class);
});
@@ -1418,26 +1418,26 @@
// SetVolatile
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setVolatile(null, 0, 1L);
+ vh.setVolatile(null, 0, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // array reference class
- vh.setVolatile(Void.class, 0, 1L);
+ vh.setVolatile(Void.class, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
vh.setVolatile(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setVolatile(0, 0, 1L);
+ vh.setVolatile(0, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- vh.setVolatile(array, Void.class, 1L);
+ vh.setVolatile(array, Void.class, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile(array, 0, 1L, Void.class);
+ vh.setVolatile(array, 0, 0x0123456789ABCDEFL, Void.class);
});
@@ -1474,26 +1474,26 @@
// SetOpaque
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setOpaque(null, 0, 1L);
+ vh.setOpaque(null, 0, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // array reference class
- vh.setOpaque(Void.class, 0, 1L);
+ vh.setOpaque(Void.class, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
vh.setOpaque(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setOpaque(0, 0, 1L);
+ vh.setOpaque(0, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- vh.setOpaque(array, Void.class, 1L);
+ vh.setOpaque(array, Void.class, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque(array, 0, 1L, Void.class);
+ vh.setOpaque(array, 0, 0x0123456789ABCDEFL, Void.class);
});
@@ -1530,383 +1530,383 @@
// SetRelease
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setRelease(null, 0, 1L);
+ vh.setRelease(null, 0, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // array reference class
- vh.setRelease(Void.class, 0, 1L);
+ vh.setRelease(Void.class, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
vh.setRelease(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setRelease(0, 0, 1L);
+ vh.setRelease(0, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- vh.setRelease(array, Void.class, 1L);
+ vh.setRelease(array, Void.class, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease(array, 0, 1L, Void.class);
+ vh.setRelease(array, 0, 0x0123456789ABCDEFL, Void.class);
});
// CompareAndSet
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.compareAndSet(null, 0, 1L, 1L);
+ boolean r = vh.compareAndSet(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.compareAndSet(Void.class, 0, 1L, 1L);
+ boolean r = vh.compareAndSet(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.compareAndSet(array, 0, Void.class, 1L);
+ boolean r = vh.compareAndSet(array, 0, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.compareAndSet(array, 0, 1L, Void.class);
+ boolean r = vh.compareAndSet(array, 0, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.compareAndSet(0, 0, 1L, 1L);
+ boolean r = vh.compareAndSet(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- boolean r = vh.compareAndSet(array, Void.class, 1L, 1L);
+ boolean r = vh.compareAndSet(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.compareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.compareAndSet(array, 0, 1L, 1L, Void.class);
+ boolean r = vh.compareAndSet(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSet
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSet(null, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSet(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSet(Void.class, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSet(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSet(array, 0, Void.class, 1L);
+ boolean r = vh.weakCompareAndSet(array, 0, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSet(array, 0, 1L, Void.class);
+ boolean r = vh.weakCompareAndSet(array, 0, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSet(0, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSet(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- boolean r = vh.weakCompareAndSet(array, Void.class, 1L, 1L);
+ boolean r = vh.weakCompareAndSet(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSet();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSet(array, 0, 1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSet(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSetVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetVolatile(null, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetVolatile(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 1L);
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetVolatile(array, 0, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetVolatile(0, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetVolatile(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 1L, 1L);
+ boolean r = vh.weakCompareAndSetVolatile(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetVolatile();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetVolatile(array, 0, 1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSetAcquire
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetAcquire(null, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetAcquire(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, 1L);
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetAcquire(array, 0, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetAcquire(0, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetAcquire(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- boolean r = vh.weakCompareAndSetAcquire(array, Void.class, 1L, 1L);
+ boolean r = vh.weakCompareAndSetAcquire(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetAcquire();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetAcquire(array, 0, 1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// WeakCompareAndSetRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- boolean r = vh.weakCompareAndSetRelease(null, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetRelease(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // receiver reference class
- boolean r = vh.weakCompareAndSetRelease(Void.class, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetRelease(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- boolean r = vh.weakCompareAndSetRelease(array, 0, Void.class, 1L);
+ boolean r = vh.weakCompareAndSetRelease(array, 0, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- boolean r = vh.weakCompareAndSetRelease(array, 0, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(array, 0, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- boolean r = vh.weakCompareAndSetRelease(0, 0, 1L, 1L);
+ boolean r = vh.weakCompareAndSetRelease(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- boolean r = vh.weakCompareAndSetRelease(array, Void.class, 1L, 1L);
+ boolean r = vh.weakCompareAndSetRelease(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
boolean r = vh.weakCompareAndSetRelease();
});
checkWMTE(() -> { // >
- boolean r = vh.weakCompareAndSetRelease(array, 0, 1L, 1L, Void.class);
+ boolean r = vh.weakCompareAndSetRelease(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// CompareAndExchangeVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- long x = (long) vh.compareAndExchangeVolatile(null, 0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeVolatile(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // array reference class
- long x = (long) vh.compareAndExchangeVolatile(Void.class, 0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeVolatile(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- long x = (long) vh.compareAndExchangeVolatile(array, 0, Void.class, 1L);
+ long x = (long) vh.compareAndExchangeVolatile(array, 0, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- long x = (long) vh.compareAndExchangeVolatile(array, 0, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeVolatile(array, 0, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // array primitive class
- long x = (long) vh.compareAndExchangeVolatile(0, 0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeVolatile(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- long x = (long) vh.compareAndExchangeVolatile(array, Void.class, 1L, 1L);
+ long x = (long) vh.compareAndExchangeVolatile(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeVolatile(array, 0, 1L, 1L);
+ Void r = (Void) vh.compareAndExchangeVolatile(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, 1L, 1L);
+ boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.compareAndExchangeVolatile();
});
checkWMTE(() -> { // >
- long x = (long) vh.compareAndExchangeVolatile(array, 0, 1L, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeVolatile(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// CompareAndExchangeAcquire
// Incorrect argument types
checkNPE(() -> { // null receiver
- long x = (long) vh.compareAndExchangeAcquire(null, 0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeAcquire(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // array reference class
- long x = (long) vh.compareAndExchangeAcquire(Void.class, 0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeAcquire(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- long x = (long) vh.compareAndExchangeAcquire(array, 0, Void.class, 1L);
+ long x = (long) vh.compareAndExchangeAcquire(array, 0, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- long x = (long) vh.compareAndExchangeAcquire(array, 0, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeAcquire(array, 0, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // array primitive class
- long x = (long) vh.compareAndExchangeAcquire(0, 0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeAcquire(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- long x = (long) vh.compareAndExchangeAcquire(array, Void.class, 1L, 1L);
+ long x = (long) vh.compareAndExchangeAcquire(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeAcquire(array, 0, 1L, 1L);
+ Void r = (Void) vh.compareAndExchangeAcquire(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, 1L, 1L);
+ boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.compareAndExchangeAcquire();
});
checkWMTE(() -> { // >
- long x = (long) vh.compareAndExchangeAcquire(array, 0, 1L, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeAcquire(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// CompareAndExchangeRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- long x = (long) vh.compareAndExchangeRelease(null, 0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeRelease(null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // array reference class
- long x = (long) vh.compareAndExchangeRelease(Void.class, 0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeRelease(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
- long x = (long) vh.compareAndExchangeRelease(array, 0, Void.class, 1L);
+ long x = (long) vh.compareAndExchangeRelease(array, 0, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
- long x = (long) vh.compareAndExchangeRelease(array, 0, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeRelease(array, 0, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // array primitive class
- long x = (long) vh.compareAndExchangeRelease(0, 0, 1L, 1L);
+ long x = (long) vh.compareAndExchangeRelease(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- long x = (long) vh.compareAndExchangeRelease(array, Void.class, 1L, 1L);
+ long x = (long) vh.compareAndExchangeRelease(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.compareAndExchangeRelease(array, 0, 1L, 1L);
+ Void r = (Void) vh.compareAndExchangeRelease(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, 1L, 1L);
+ boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.compareAndExchangeRelease();
});
checkWMTE(() -> { // >
- long x = (long) vh.compareAndExchangeRelease(array, 0, 1L, 1L, Void.class);
+ long x = (long) vh.compareAndExchangeRelease(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
// GetAndSet
// Incorrect argument types
checkNPE(() -> { // null array
- long x = (long) vh.getAndSet(null, 0, 1L);
+ long x = (long) vh.getAndSet(null, 0, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // array reference class
- long x = (long) vh.getAndSet(Void.class, 0, 1L);
+ long x = (long) vh.getAndSet(Void.class, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
long x = (long) vh.getAndSet(array, 0, Void.class);
});
checkWMTE(() -> { // reciarrayever primitive class
- long x = (long) vh.getAndSet(0, 0, 1L);
+ long x = (long) vh.getAndSet(0, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- long x = (long) vh.getAndSet(array, Void.class, 1L);
+ long x = (long) vh.getAndSet(array, Void.class, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndSet(array, 0, 1L);
+ Void r = (Void) vh.getAndSet(array, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndSet(array, 0, 1L);
+ boolean x = (boolean) vh.getAndSet(array, 0, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.getAndSet();
});
checkWMTE(() -> { // >
- long x = (long) vh.getAndSet(array, 0, 1L, Void.class);
+ long x = (long) vh.getAndSet(array, 0, 0x0123456789ABCDEFL, Void.class);
});
// GetAndAdd
// Incorrect argument types
checkNPE(() -> { // null array
- long x = (long) vh.getAndAdd(null, 0, 1L);
+ long x = (long) vh.getAndAdd(null, 0, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // array reference class
- long x = (long) vh.getAndAdd(Void.class, 0, 1L);
+ long x = (long) vh.getAndAdd(Void.class, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
long x = (long) vh.getAndAdd(array, 0, Void.class);
});
checkWMTE(() -> { // array primitive class
- long x = (long) vh.getAndAdd(0, 0, 1L);
+ long x = (long) vh.getAndAdd(0, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- long x = (long) vh.getAndAdd(array, Void.class, 1L);
+ long x = (long) vh.getAndAdd(array, Void.class, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.getAndAdd(array, 0, 1L);
+ Void r = (Void) vh.getAndAdd(array, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.getAndAdd(array, 0, 1L);
+ boolean x = (boolean) vh.getAndAdd(array, 0, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.getAndAdd();
});
checkWMTE(() -> { // >
- long x = (long) vh.getAndAdd(array, 0, 1L, Void.class);
+ long x = (long) vh.getAndAdd(array, 0, 0x0123456789ABCDEFL, Void.class);
});
// AddAndGet
// Incorrect argument types
checkNPE(() -> { // null array
- long x = (long) vh.addAndGet(null, 0, 1L);
+ long x = (long) vh.addAndGet(null, 0, 0x0123456789ABCDEFL);
});
checkCCE(() -> { // array reference class
- long x = (long) vh.addAndGet(Void.class, 0, 1L);
+ long x = (long) vh.addAndGet(Void.class, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
long x = (long) vh.addAndGet(array, 0, Void.class);
});
checkWMTE(() -> { // array primitive class
- long x = (long) vh.addAndGet(0, 0, 1L);
+ long x = (long) vh.addAndGet(0, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
- long x = (long) vh.addAndGet(array, Void.class, 1L);
+ long x = (long) vh.addAndGet(array, Void.class, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
- Void r = (Void) vh.addAndGet(array, 0, 1L);
+ Void r = (Void) vh.addAndGet(array, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
- boolean x = (boolean) vh.addAndGet(array, 0, 1L);
+ boolean x = (boolean) vh.addAndGet(array, 0, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
long x = (long) vh.addAndGet();
});
checkWMTE(() -> { // >
- long x = (long) vh.addAndGet(array, 0, 1L, Void.class);
+ long x = (long) vh.addAndGet(array, 0, 0x0123456789ABCDEFL, Void.class);
});
}
static void testArrayWrongMethodType(Handles hs) throws Throwable {
long[] array = new long[10];
- Arrays.fill(array, 1L);
+ Arrays.fill(array, 0x0123456789ABCDEFL);
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
@@ -1950,11 +1950,11 @@
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, long[].class, int.class, long.class)).
- invokeExact((long[]) null, 0, 1L);
+ invokeExact((long[]) null, 0, 0x0123456789ABCDEFL);
});
hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, long.class)).
- invokeExact(Void.class, 0, 1L);
+ invokeExact(Void.class, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, long[].class, int.class, Class.class)).
@@ -1962,11 +1962,11 @@
});
checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, long.class)).
- invokeExact(0, 0, 1L);
+ invokeExact(0, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, long[].class, Class.class, long.class)).
- invokeExact(array, Void.class, 1L);
+ invokeExact(array, Void.class, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -1975,34 +1975,34 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, long[].class, int.class, Class.class)).
- invokeExact(array, 0, 1L, Void.class);
+ invokeExact(array, 0, 0x0123456789ABCDEFL, 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, long[].class, int.class, long.class, long.class)).
- invokeExact((long[]) null, 0, 1L, 1L);
+ invokeExact((long[]) null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, long.class, long.class)).
- invokeExact(Void.class, 0, 1L, 1L);
+ invokeExact(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, Class.class, long.class)).
- invokeExact(array, 0, Void.class, 1L);
+ invokeExact(array, 0, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, Class.class)).
- invokeExact(array, 0, 1L, Void.class);
+ invokeExact(array, 0, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // receiver primitive class
boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, long.class, long.class)).
- invokeExact(0, 0, 1L, 1L);
+ invokeExact(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, Class.class, long.class, long.class)).
- invokeExact(array, Void.class, 1L, 1L);
+ invokeExact(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -2011,7 +2011,7 @@
});
checkWMTE(() -> { // >
boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class, Class.class)).
- invokeExact(array, 0, 1L, 1L, Void.class);
+ invokeExact(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
}
@@ -2019,36 +2019,36 @@
// Incorrect argument types
checkNPE(() -> { // null receiver
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, long.class)).
- invokeExact((long[]) null, 0, 1L, 1L);
+ invokeExact((long[]) null, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
hs.checkWMTEOrCCE(() -> { // array reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class, long.class)).
- invokeExact(Void.class, 0, 1L, 1L);
+ invokeExact(Void.class, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // expected reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class, long.class)).
- invokeExact(array, 0, Void.class, 1L);
+ invokeExact(array, 0, Void.class, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // actual reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
- invokeExact(array, 0, 1L, Void.class);
+ invokeExact(array, 0, 0x0123456789ABCDEFL, Void.class);
});
checkWMTE(() -> { // array primitive class
long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class, long.class)).
- invokeExact(0, 0, 1L, 1L);
+ invokeExact(0, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class, long.class)).
- invokeExact(array, Void.class, 1L, 1L);
+ invokeExact(array, Void.class, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class, long.class)).
- invokeExact(array, 0, 1L, 1L);
+ invokeExact(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class)).
- invokeExact(array, 0, 1L, 1L);
+ invokeExact(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -2057,7 +2057,7 @@
});
checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, long.class, Class.class)).
- invokeExact(array, 0, 1L, 1L, Void.class);
+ invokeExact(array, 0, 0x0123456789ABCDEFL, 0x0123456789ABCDEFL, Void.class);
});
}
@@ -2065,11 +2065,11 @@
// Incorrect argument types
checkNPE(() -> { // null array
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)).
- invokeExact((long[]) null, 0, 1L);
+ invokeExact((long[]) null, 0, 0x0123456789ABCDEFL);
});
hs.checkWMTEOrCCE(() -> { // array reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)).
- invokeExact(Void.class, 0, 1L);
+ invokeExact(Void.class, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)).
@@ -2077,20 +2077,20 @@
});
checkWMTE(() -> { // array primitive class
long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)).
- invokeExact(0, 0, 1L);
+ invokeExact(0, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)).
- invokeExact(array, Void.class, 1L);
+ invokeExact(array, Void.class, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)).
- invokeExact(array, 0, 1L);
+ invokeExact(array, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)).
- invokeExact(array, 0, 1L);
+ invokeExact(array, 0, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -2099,7 +2099,7 @@
});
checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
- invokeExact(array, 0, 1L, Void.class);
+ invokeExact(array, 0, 0x0123456789ABCDEFL, Void.class);
});
}
@@ -2107,11 +2107,11 @@
// Incorrect argument types
checkNPE(() -> { // null array
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)).
- invokeExact((long[]) null, 0, 1L);
+ invokeExact((long[]) null, 0, 0x0123456789ABCDEFL);
});
hs.checkWMTEOrCCE(() -> { // array reference class
long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)).
- invokeExact(Void.class, 0, 1L);
+ invokeExact(Void.class, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // value reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)).
@@ -2119,20 +2119,20 @@
});
checkWMTE(() -> { // array primitive class
long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)).
- invokeExact(0, 0, 1L);
+ invokeExact(0, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // index reference class
long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)).
- invokeExact(array, Void.class, 1L);
+ invokeExact(array, Void.class, 0x0123456789ABCDEFL);
});
// Incorrect return type
checkWMTE(() -> { // reference class
Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)).
- invokeExact(array, 0, 1L);
+ invokeExact(array, 0, 0x0123456789ABCDEFL);
});
checkWMTE(() -> { // primitive class
boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)).
- invokeExact(array, 0, 1L);
+ invokeExact(array, 0, 0x0123456789ABCDEFL);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -2141,7 +2141,7 @@
});
checkWMTE(() -> { // >
long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)).
- invokeExact(array, 0, 1L, Void.class);
+ invokeExact(array, 0, 0x0123456789ABCDEFL, Void.class);
});
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java Wed Jun 15 11:20:15 2016 +0300
@@ -43,13 +43,13 @@
import static java.lang.invoke.MethodType.*;
public class VarHandleTestMethodTypeShort extends VarHandleBaseTest {
- static final short static_final_v = (short)1;
+ static final short static_final_v = (short)0x0123;
- static short static_v = (short)1;
+ static short static_v = (short)0x0123;
- final short final_v = (short)1;
+ final short final_v = (short)0x0123;
- short v = (short)1;
+ short v = (short)0x0123;
VarHandle vhFinalField;
@@ -154,23 +154,23 @@
// Set
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.set(null, (short)1);
+ vh.set(null, (short)0x0123);
});
checkCCE(() -> { // receiver reference class
- vh.set(Void.class, (short)1);
+ vh.set(Void.class, (short)0x0123);
});
checkWMTE(() -> { // value reference class
vh.set(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.set(0, (short)1);
+ vh.set(0, (short)0x0123);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.set();
});
checkWMTE(() -> { // >
- vh.set(recv, (short)1, Void.class);
+ vh.set(recv, (short)0x0123, Void.class);
});
@@ -204,23 +204,23 @@
// SetVolatile
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setVolatile(null, (short)1);
+ vh.setVolatile(null, (short)0x0123);
});
checkCCE(() -> { // receiver reference class
- vh.setVolatile(Void.class, (short)1);
+ vh.setVolatile(Void.class, (short)0x0123);
});
checkWMTE(() -> { // value reference class
vh.setVolatile(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setVolatile(0, (short)1);
+ vh.setVolatile(0, (short)0x0123);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile(recv, (short)1, Void.class);
+ vh.setVolatile(recv, (short)0x0123, Void.class);
});
@@ -254,23 +254,23 @@
// SetOpaque
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setOpaque(null, (short)1);
+ vh.setOpaque(null, (short)0x0123);
});
checkCCE(() -> { // receiver reference class
- vh.setOpaque(Void.class, (short)1);
+ vh.setOpaque(Void.class, (short)0x0123);
});
checkWMTE(() -> { // value reference class
vh.setOpaque(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setOpaque(0, (short)1);
+ vh.setOpaque(0, (short)0x0123);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque(recv, (short)1, Void.class);
+ vh.setOpaque(recv, (short)0x0123, Void.class);
});
@@ -304,27 +304,342 @@
// SetRelease
// Incorrect argument types
checkNPE(() -> { // null receiver
- vh.setRelease(null, (short)1);
+ vh.setRelease(null, (short)0x0123);
});
checkCCE(() -> { // receiver reference class
- vh.setRelease(Void.class, (short)1);
+ vh.setRelease(Void.class, (short)0x0123);
});
checkWMTE(() -> { // value reference class
vh.setRelease(recv, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setRelease(0, (short)1);
+ vh.setRelease(0, (short)0x0123);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease(recv, (short)1, Void.class);
+ vh.setRelease(recv, (short)0x0123, Void.class);
+ });
+
+
+ // CompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.compareAndSet(null, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.compareAndSet(Void.class, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.compareAndSet(recv, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.compareAndSet(recv, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.compareAndSet(0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.compareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.compareAndSet(recv, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSet(null, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSet(Void.class, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSet(recv, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSet(recv, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSet(0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSet(recv, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSetVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetVolatile(null, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetVolatile(recv, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetVolatile(recv, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetVolatile(0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetVolatile(recv, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSetAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetAcquire(null, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetAcquire(recv, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetAcquire(recv, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetAcquire(0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetAcquire(recv, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSetRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetRelease(null, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetRelease(Void.class, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetRelease(recv, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetRelease(recv, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetRelease(0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetRelease(recv, (short)0x0123, (short)0x0123, Void.class);
});
+ // CompareAndExchangeVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ short x = (short) vh.compareAndExchangeVolatile(null, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ short x = (short) vh.compareAndExchangeVolatile(Void.class, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ short x = (short) vh.compareAndExchangeVolatile(recv, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) vh.compareAndExchangeVolatile(recv, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ short x = (short) vh.compareAndExchangeVolatile(0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeVolatile(recv, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(recv, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.compareAndExchangeVolatile();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.compareAndExchangeVolatile(recv, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+ // CompareAndExchangeVolatileAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ short x = (short) vh.compareAndExchangeAcquire(null, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ short x = (short) vh.compareAndExchangeAcquire(Void.class, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ short x = (short) vh.compareAndExchangeAcquire(recv, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) vh.compareAndExchangeAcquire(recv, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ short x = (short) vh.compareAndExchangeAcquire(0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeAcquire(recv, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(recv, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.compareAndExchangeAcquire();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.compareAndExchangeAcquire(recv, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // CompareAndExchangeRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ short x = (short) vh.compareAndExchangeRelease(null, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ short x = (short) vh.compareAndExchangeRelease(Void.class, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ short x = (short) vh.compareAndExchangeRelease(recv, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) vh.compareAndExchangeRelease(recv, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ short x = (short) vh.compareAndExchangeRelease(0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeRelease(recv, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeRelease(recv, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.compareAndExchangeRelease();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.compareAndExchangeRelease(recv, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // GetAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ short x = (short) vh.getAndSet(null, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ short x = (short) vh.getAndSet(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // value reference class
+ short x = (short) vh.getAndSet(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ short x = (short) vh.getAndSet(0, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndSet(recv, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndSet(recv, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.getAndSet();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.getAndSet(recv, (short)0x0123, Void.class);
+ });
+
+ // GetAndAdd
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ short x = (short) vh.getAndAdd(null, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ short x = (short) vh.getAndAdd(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // value reference class
+ short x = (short) vh.getAndAdd(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ short x = (short) vh.getAndAdd(0, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndAdd(recv, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndAdd(recv, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.getAndAdd();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.getAndAdd(recv, (short)0x0123, Void.class);
+ });
+
+
+ // AddAndGet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ short x = (short) vh.addAndGet(null, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ short x = (short) vh.addAndGet(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // value reference class
+ short x = (short) vh.addAndGet(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ short x = (short) vh.addAndGet(0, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.addAndGet(recv, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.addAndGet(recv, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.addAndGet();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.addAndGet(recv, (short)0x0123, Void.class);
+ });
}
static void testInstanceFieldWrongMethodType(VarHandleTestMethodTypeShort recv, Handles hs) throws Throwable {
@@ -366,11 +681,11 @@
// Incorrect argument types
checkNPE(() -> { // null receiver
hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, short.class)).
- invokeExact((VarHandleTestMethodTypeShort) null, (short)1);
+ invokeExact((VarHandleTestMethodTypeShort) null, (short)0x0123);
});
hs.checkWMTEOrCCE(() -> { // receiver reference class
hs.get(am, methodType(void.class, Class.class, short.class)).
- invokeExact(Void.class, (short)1);
+ invokeExact(Void.class, (short)0x0123);
});
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, Class.class)).
@@ -378,7 +693,7 @@
});
checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, short.class)).
- invokeExact(0, (short)1);
+ invokeExact(0, (short)0x0123);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -387,11 +702,157 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, short.class, Class.class)).
- invokeExact(recv, (short)1, Void.class);
+ invokeExact(recv, (short)0x0123, 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, VarHandleTestMethodTypeShort.class, short.class, short.class)).
+ invokeExact((VarHandleTestMethodTypeShort) null, (short)0x0123, (short)0x0123);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, short.class, short.class)).
+ invokeExact(Void.class, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class, Class.class, short.class)).
+ invokeExact(recv, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class, short.class, Class.class)).
+ invokeExact(recv, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , short.class, short.class)).
+ invokeExact(0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class, short.class, short.class, Class.class)).
+ invokeExact(recv, (short)0x0123, (short)0x0123, Void.class);
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ checkNPE(() -> { // null receiver
+ short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, short.class, short.class)).
+ invokeExact((VarHandleTestMethodTypeShort) null, (short)0x0123, (short)0x0123);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ short x = (short) hs.get(am, methodType(short.class, Class.class, short.class, short.class)).
+ invokeExact(Void.class, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, Class.class, short.class)).
+ invokeExact(recv, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, short.class, Class.class)).
+ invokeExact(recv, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ short x = (short) hs.get(am, methodType(short.class, int.class , short.class, short.class)).
+ invokeExact(0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeShort.class , short.class, short.class)).
+ invokeExact(recv, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class , short.class, short.class)).
+ invokeExact(recv, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) hs.get(am, methodType(short.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, short.class, short.class, Class.class)).
+ invokeExact(recv, (short)0x0123, (short)0x0123, Void.class);
+ });
+ }
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ checkNPE(() -> { // null receiver
+ short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, short.class)).
+ invokeExact((VarHandleTestMethodTypeShort) null, (short)0x0123);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ short x = (short) hs.get(am, methodType(short.class, Class.class, short.class)).
+ invokeExact(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // value reference class
+ short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, Class.class)).
+ invokeExact(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ short x = (short) hs.get(am, methodType(short.class, int.class, short.class)).
+ invokeExact(0, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeShort.class, short.class)).
+ invokeExact(recv, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class, short.class)).
+ invokeExact(recv, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) hs.get(am, methodType(short.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, short.class)).
+ invokeExact(recv, (short)0x0123, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ checkNPE(() -> { // null receiver
+ short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, short.class)).
+ invokeExact((VarHandleTestMethodTypeShort) null, (short)0x0123);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ short x = (short) hs.get(am, methodType(short.class, Class.class, short.class)).
+ invokeExact(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // value reference class
+ short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, Class.class)).
+ invokeExact(recv, Void.class);
+ });
+ checkWMTE(() -> { // reciever primitive class
+ short x = (short) hs.get(am, methodType(short.class, int.class, short.class)).
+ invokeExact(0, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeShort.class, short.class)).
+ invokeExact(recv, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class, short.class)).
+ invokeExact(recv, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) hs.get(am, methodType(short.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, short.class)).
+ invokeExact(recv, (short)0x0123, Void.class);
+ });
+ }
}
@@ -420,7 +881,7 @@
vh.set();
});
checkWMTE(() -> { // >
- vh.set((short)1, Void.class);
+ vh.set((short)0x0123, Void.class);
});
@@ -447,7 +908,7 @@
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile((short)1, Void.class);
+ vh.setVolatile((short)0x0123, Void.class);
});
@@ -474,7 +935,7 @@
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque((short)1, Void.class);
+ vh.setOpaque((short)0x0123, Void.class);
});
@@ -501,11 +962,227 @@
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease((short)1, Void.class);
+ vh.setRelease((short)0x0123, Void.class);
+ });
+
+
+ // CompareAndSet
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.compareAndSet(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.compareAndSet((short)0x0123, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.compareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.compareAndSet((short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSet
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSet(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSet((short)0x0123, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSet((short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSetVolatile
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetVolatile((short)0x0123, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetVolatile((short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSetAcquire
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetAcquire((short)0x0123, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetAcquire((short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSetRelease
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetRelease(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetRelease((short)0x0123, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetRelease((short)0x0123, (short)0x0123, Void.class);
});
+ // CompareAndExchangeVolatile
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ short x = (short) vh.compareAndExchangeVolatile(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) vh.compareAndExchangeVolatile((short)0x0123, Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeVolatile((short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeVolatile((short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.compareAndExchangeVolatile();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.compareAndExchangeVolatile((short)0x0123, (short)0x0123, Void.class);
+ });
+
+ // CompareAndExchangeAcquire
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ short x = (short) vh.compareAndExchangeAcquire(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) vh.compareAndExchangeAcquire((short)0x0123, Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeAcquire((short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeAcquire((short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.compareAndExchangeAcquire();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.compareAndExchangeAcquire((short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // CompareAndExchangeRelease
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ short x = (short) vh.compareAndExchangeRelease(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) vh.compareAndExchangeRelease((short)0x0123, Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeRelease((short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeRelease((short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.compareAndExchangeRelease();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.compareAndExchangeRelease((short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // GetAndSet
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ short x = (short) vh.getAndSet(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndSet((short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndSet((short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.getAndSet();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.getAndSet((short)0x0123, Void.class);
+ });
+
+ // GetAndAdd
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ short x = (short) vh.getAndAdd(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndAdd((short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndAdd((short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.getAndAdd();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.getAndAdd((short)0x0123, Void.class);
+ });
+
+
+ // AddAndGet
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ short x = (short) vh.addAndGet(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.addAndGet((short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.addAndGet((short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.addAndGet();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.addAndGet((short)0x0123, Void.class);
+ });
}
static void testStaticFieldWrongMethodType(Handles hs) throws Throwable {
@@ -540,16 +1217,117 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, short.class, Class.class)).
- invokeExact((short)1, Void.class);
+ invokeExact((short)0x0123, Void.class);
+ });
+ }
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, short.class)).
+ invokeExact(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, short.class, Class.class)).
+ invokeExact((short)0x0123, Void.class);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, short.class, short.class, Class.class)).
+ invokeExact((short)0x0123, (short)0x0123, Void.class);
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // expected reference class
+ short x = (short) hs.get(am, methodType(short.class, Class.class, short.class)).
+ invokeExact(Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) hs.get(am, methodType(short.class, short.class, Class.class)).
+ invokeExact((short)0x0123, Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, short.class, short.class)).
+ invokeExact((short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, short.class, short.class)).
+ invokeExact((short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) hs.get(am, methodType(short.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) hs.get(am, methodType(short.class, short.class, short.class, Class.class)).
+ invokeExact((short)0x0123, (short)0x0123, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ short x = (short) hs.get(am, methodType(short.class, Class.class)).
+ invokeExact(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, short.class)).
+ invokeExact((short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, short.class)).
+ invokeExact((short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) hs.get(am, methodType(short.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) hs.get(am, methodType(short.class, short.class, Class.class)).
+ invokeExact((short)0x0123, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ // Incorrect argument types
+ checkWMTE(() -> { // value reference class
+ short x = (short) hs.get(am, methodType(short.class, Class.class)).
+ invokeExact(Void.class);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, short.class)).
+ invokeExact((short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, short.class)).
+ invokeExact((short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) hs.get(am, methodType(short.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) hs.get(am, methodType(short.class, short.class, Class.class)).
+ invokeExact((short)0x0123, Void.class);
+ });
+ }
}
static void testArrayWrongMethodType(VarHandle vh) throws Throwable {
short[] array = new short[10];
- Arrays.fill(array, (short)1);
+ Arrays.fill(array, (short)0x0123);
// Get
// Incorrect argument types
@@ -584,26 +1362,26 @@
// Set
// Incorrect argument types
checkNPE(() -> { // null array
- vh.set(null, 0, (short)1);
+ vh.set(null, 0, (short)0x0123);
});
checkCCE(() -> { // array reference class
- vh.set(Void.class, 0, (short)1);
+ vh.set(Void.class, 0, (short)0x0123);
});
checkWMTE(() -> { // value reference class
vh.set(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.set(0, 0, (short)1);
+ vh.set(0, 0, (short)0x0123);
});
checkWMTE(() -> { // index reference class
- vh.set(array, Void.class, (short)1);
+ vh.set(array, Void.class, (short)0x0123);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.set();
});
checkWMTE(() -> { // >
- vh.set(array, 0, (short)1, Void.class);
+ vh.set(array, 0, (short)0x0123, Void.class);
});
@@ -640,26 +1418,26 @@
// SetVolatile
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setVolatile(null, 0, (short)1);
+ vh.setVolatile(null, 0, (short)0x0123);
});
checkCCE(() -> { // array reference class
- vh.setVolatile(Void.class, 0, (short)1);
+ vh.setVolatile(Void.class, 0, (short)0x0123);
});
checkWMTE(() -> { // value reference class
vh.setVolatile(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setVolatile(0, 0, (short)1);
+ vh.setVolatile(0, 0, (short)0x0123);
});
checkWMTE(() -> { // index reference class
- vh.setVolatile(array, Void.class, (short)1);
+ vh.setVolatile(array, Void.class, (short)0x0123);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setVolatile();
});
checkWMTE(() -> { // >
- vh.setVolatile(array, 0, (short)1, Void.class);
+ vh.setVolatile(array, 0, (short)0x0123, Void.class);
});
@@ -696,26 +1474,26 @@
// SetOpaque
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setOpaque(null, 0, (short)1);
+ vh.setOpaque(null, 0, (short)0x0123);
});
checkCCE(() -> { // array reference class
- vh.setOpaque(Void.class, 0, (short)1);
+ vh.setOpaque(Void.class, 0, (short)0x0123);
});
checkWMTE(() -> { // value reference class
vh.setOpaque(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setOpaque(0, 0, (short)1);
+ vh.setOpaque(0, 0, (short)0x0123);
});
checkWMTE(() -> { // index reference class
- vh.setOpaque(array, Void.class, (short)1);
+ vh.setOpaque(array, Void.class, (short)0x0123);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setOpaque();
});
checkWMTE(() -> { // >
- vh.setOpaque(array, 0, (short)1, Void.class);
+ vh.setOpaque(array, 0, (short)0x0123, Void.class);
});
@@ -752,35 +1530,383 @@
// SetRelease
// Incorrect argument types
checkNPE(() -> { // null array
- vh.setRelease(null, 0, (short)1);
+ vh.setRelease(null, 0, (short)0x0123);
});
checkCCE(() -> { // array reference class
- vh.setRelease(Void.class, 0, (short)1);
+ vh.setRelease(Void.class, 0, (short)0x0123);
});
checkWMTE(() -> { // value reference class
vh.setRelease(array, 0, Void.class);
});
checkWMTE(() -> { // receiver primitive class
- vh.setRelease(0, 0, (short)1);
+ vh.setRelease(0, 0, (short)0x0123);
});
checkWMTE(() -> { // index reference class
- vh.setRelease(array, Void.class, (short)1);
+ vh.setRelease(array, Void.class, (short)0x0123);
});
// Incorrect arity
checkWMTE(() -> { // 0
vh.setRelease();
});
checkWMTE(() -> { // >
- vh.setRelease(array, 0, (short)1, Void.class);
+ vh.setRelease(array, 0, (short)0x0123, Void.class);
+ });
+
+
+ // CompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.compareAndSet(null, 0, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.compareAndSet(Void.class, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.compareAndSet(array, 0, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.compareAndSet(array, 0, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.compareAndSet(0, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.compareAndSet(array, Void.class, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.compareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.compareAndSet(array, 0, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSet(null, 0, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSet(Void.class, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSet(array, 0, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSet(array, 0, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSet(0, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSet(array, Void.class, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSet();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSet(array, 0, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSetVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetVolatile(null, 0, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetVolatile(Void.class, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetVolatile(0, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSetVolatile(array, Void.class, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetVolatile();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetVolatile(array, 0, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSetAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetAcquire(null, 0, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetAcquire(Void.class, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetAcquire(0, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSetAcquire(array, Void.class, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetAcquire();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetAcquire(array, 0, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // WeakCompareAndSetRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ boolean r = vh.weakCompareAndSetRelease(null, 0, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // receiver reference class
+ boolean r = vh.weakCompareAndSetRelease(Void.class, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = vh.weakCompareAndSetRelease(array, 0, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = vh.weakCompareAndSetRelease(array, 0, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = vh.weakCompareAndSetRelease(0, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = vh.weakCompareAndSetRelease(array, Void.class, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = vh.weakCompareAndSetRelease();
+ });
+ checkWMTE(() -> { // >
+ boolean r = vh.weakCompareAndSetRelease(array, 0, (short)0x0123, (short)0x0123, Void.class);
});
+ // CompareAndExchangeVolatile
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ short x = (short) vh.compareAndExchangeVolatile(null, 0, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // array reference class
+ short x = (short) vh.compareAndExchangeVolatile(Void.class, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ short x = (short) vh.compareAndExchangeVolatile(array, 0, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) vh.compareAndExchangeVolatile(array, 0, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ short x = (short) vh.compareAndExchangeVolatile(0, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ short x = (short) vh.compareAndExchangeVolatile(array, Void.class, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeVolatile(array, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeVolatile(array, 0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.compareAndExchangeVolatile();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.compareAndExchangeVolatile(array, 0, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+ // CompareAndExchangeAcquire
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ short x = (short) vh.compareAndExchangeAcquire(null, 0, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // array reference class
+ short x = (short) vh.compareAndExchangeAcquire(Void.class, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ short x = (short) vh.compareAndExchangeAcquire(array, 0, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) vh.compareAndExchangeAcquire(array, 0, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ short x = (short) vh.compareAndExchangeAcquire(0, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ short x = (short) vh.compareAndExchangeAcquire(array, Void.class, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeAcquire(array, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeAcquire(array, 0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.compareAndExchangeAcquire();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.compareAndExchangeAcquire(array, 0, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // CompareAndExchangeRelease
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ short x = (short) vh.compareAndExchangeRelease(null, 0, (short)0x0123, (short)0x0123);
+ });
+ checkCCE(() -> { // array reference class
+ short x = (short) vh.compareAndExchangeRelease(Void.class, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ short x = (short) vh.compareAndExchangeRelease(array, 0, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) vh.compareAndExchangeRelease(array, 0, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ short x = (short) vh.compareAndExchangeRelease(0, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ short x = (short) vh.compareAndExchangeRelease(array, Void.class, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.compareAndExchangeRelease(array, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.compareAndExchangeRelease(array, 0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.compareAndExchangeRelease();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.compareAndExchangeRelease(array, 0, (short)0x0123, (short)0x0123, Void.class);
+ });
+
+
+ // GetAndSet
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ short x = (short) vh.getAndSet(null, 0, (short)0x0123);
+ });
+ checkCCE(() -> { // array reference class
+ short x = (short) vh.getAndSet(Void.class, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // value reference class
+ short x = (short) vh.getAndSet(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // reciarrayever primitive class
+ short x = (short) vh.getAndSet(0, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ short x = (short) vh.getAndSet(array, Void.class, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndSet(array, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndSet(array, 0, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.getAndSet();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.getAndSet(array, 0, (short)0x0123, Void.class);
+ });
+
+ // GetAndAdd
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ short x = (short) vh.getAndAdd(null, 0, (short)0x0123);
+ });
+ checkCCE(() -> { // array reference class
+ short x = (short) vh.getAndAdd(Void.class, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // value reference class
+ short x = (short) vh.getAndAdd(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ short x = (short) vh.getAndAdd(0, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ short x = (short) vh.getAndAdd(array, Void.class, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.getAndAdd(array, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.getAndAdd(array, 0, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.getAndAdd();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.getAndAdd(array, 0, (short)0x0123, Void.class);
+ });
+
+
+ // AddAndGet
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ short x = (short) vh.addAndGet(null, 0, (short)0x0123);
+ });
+ checkCCE(() -> { // array reference class
+ short x = (short) vh.addAndGet(Void.class, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // value reference class
+ short x = (short) vh.addAndGet(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ short x = (short) vh.addAndGet(0, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ short x = (short) vh.addAndGet(array, Void.class, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) vh.addAndGet(array, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) vh.addAndGet(array, 0, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) vh.addAndGet();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) vh.addAndGet(array, 0, (short)0x0123, Void.class);
+ });
}
static void testArrayWrongMethodType(Handles hs) throws Throwable {
short[] array = new short[10];
- Arrays.fill(array, (short)1);
+ Arrays.fill(array, (short)0x0123);
for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) {
// Incorrect argument types
@@ -824,11 +1950,11 @@
// Incorrect argument types
checkNPE(() -> { // null array
hs.get(am, methodType(void.class, short[].class, int.class, short.class)).
- invokeExact((short[]) null, 0, (short)1);
+ invokeExact((short[]) null, 0, (short)0x0123);
});
hs.checkWMTEOrCCE(() -> { // array reference class
hs.get(am, methodType(void.class, Class.class, int.class, short.class)).
- invokeExact(Void.class, 0, (short)1);
+ invokeExact(Void.class, 0, (short)0x0123);
});
checkWMTE(() -> { // value reference class
hs.get(am, methodType(void.class, short[].class, int.class, Class.class)).
@@ -836,11 +1962,11 @@
});
checkWMTE(() -> { // receiver primitive class
hs.get(am, methodType(void.class, int.class, int.class, short.class)).
- invokeExact(0, 0, (short)1);
+ invokeExact(0, 0, (short)0x0123);
});
checkWMTE(() -> { // index reference class
hs.get(am, methodType(void.class, short[].class, Class.class, short.class)).
- invokeExact(array, Void.class, (short)1);
+ invokeExact(array, Void.class, (short)0x0123);
});
// Incorrect arity
checkWMTE(() -> { // 0
@@ -849,10 +1975,175 @@
});
checkWMTE(() -> { // >
hs.get(am, methodType(void.class, short[].class, int.class, Class.class)).
- invokeExact(array, 0, (short)1, Void.class);
+ invokeExact(array, 0, (short)0x0123, 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, short[].class, int.class, short.class, short.class)).
+ invokeExact((short[]) null, 0, (short)0x0123, (short)0x0123);
+ });
+ hs.checkWMTEOrCCE(() -> { // receiver reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, short.class, short.class)).
+ invokeExact(Void.class, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class, Class.class, short.class)).
+ invokeExact(array, 0, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class, short.class, Class.class)).
+ invokeExact(array, 0, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // receiver primitive class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, short.class, short.class)).
+ invokeExact(0, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, short[].class, Class.class, short.class, short.class)).
+ invokeExact(array, Void.class, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ boolean r = (boolean) hs.get(am, methodType(boolean.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ boolean r = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class, short.class, short.class, Class.class)).
+ invokeExact(array, 0, (short)0x0123, (short)0x0123, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) {
+ // Incorrect argument types
+ checkNPE(() -> { // null receiver
+ short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, short.class, short.class)).
+ invokeExact((short[]) null, 0, (short)0x0123, (short)0x0123);
+ });
+ hs.checkWMTEOrCCE(() -> { // array reference class
+ short x = (short) hs.get(am, methodType(short.class, Class.class, int.class, short.class, short.class)).
+ invokeExact(Void.class, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // expected reference class
+ short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, Class.class, short.class)).
+ invokeExact(array, 0, Void.class, (short)0x0123);
+ });
+ checkWMTE(() -> { // actual reference class
+ short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, short.class, Class.class)).
+ invokeExact(array, 0, (short)0x0123, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ short x = (short) hs.get(am, methodType(short.class, int.class, int.class, short.class, short.class)).
+ invokeExact(0, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ short x = (short) hs.get(am, methodType(short.class, short[].class, Class.class, short.class, short.class)).
+ invokeExact(array, Void.class, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, short[].class, int.class, short.class, short.class)).
+ invokeExact(array, 0, (short)0x0123, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class, short.class, short.class)).
+ invokeExact(array, 0, (short)0x0123, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) hs.get(am, methodType(short.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, short.class, short.class, Class.class)).
+ invokeExact(array, 0, (short)0x0123, (short)0x0123, Void.class);
});
}
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) {
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, short.class)).
+ invokeExact((short[]) null, 0, (short)0x0123);
+ });
+ hs.checkWMTEOrCCE(() -> { // array reference class
+ short x = (short) hs.get(am, methodType(short.class, Class.class, int.class, short.class)).
+ invokeExact(Void.class, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // value reference class
+ short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, Class.class)).
+ invokeExact(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ short x = (short) hs.get(am, methodType(short.class, int.class, int.class, short.class)).
+ invokeExact(0, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ short x = (short) hs.get(am, methodType(short.class, short[].class, Class.class, short.class)).
+ invokeExact(array, Void.class, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, short[].class, int.class, short.class)).
+ invokeExact(array, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class, short.class)).
+ invokeExact(array, 0, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) hs.get(am, methodType(short.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, short.class, Class.class)).
+ invokeExact(array, 0, (short)0x0123, Void.class);
+ });
+ }
+
+ for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) {
+ // Incorrect argument types
+ checkNPE(() -> { // null array
+ short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, short.class)).
+ invokeExact((short[]) null, 0, (short)0x0123);
+ });
+ hs.checkWMTEOrCCE(() -> { // array reference class
+ short x = (short) hs.get(am, methodType(short.class, Class.class, int.class, short.class)).
+ invokeExact(Void.class, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // value reference class
+ short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, Class.class)).
+ invokeExact(array, 0, Void.class);
+ });
+ checkWMTE(() -> { // array primitive class
+ short x = (short) hs.get(am, methodType(short.class, int.class, int.class, short.class)).
+ invokeExact(0, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // index reference class
+ short x = (short) hs.get(am, methodType(short.class, short[].class, Class.class, short.class)).
+ invokeExact(array, Void.class, (short)0x0123);
+ });
+ // Incorrect return type
+ checkWMTE(() -> { // reference class
+ Void r = (Void) hs.get(am, methodType(Void.class, short[].class, int.class, short.class)).
+ invokeExact(array, 0, (short)0x0123);
+ });
+ checkWMTE(() -> { // primitive class
+ boolean x = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class, short.class)).
+ invokeExact(array, 0, (short)0x0123);
+ });
+ // Incorrect arity
+ checkWMTE(() -> { // 0
+ short x = (short) hs.get(am, methodType(short.class)).
+ invokeExact();
+ });
+ checkWMTE(() -> { // >
+ short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, short.class, Class.class)).
+ invokeExact(array, 0, (short)0x0123, Void.class);
+ });
+ }
}
}
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template Wed Jun 15 11:20:15 2016 +0300
@@ -568,7 +568,7 @@
$type$ o = ($type$) vh.getAndAdd(recv, $value3$);
assertEquals(o, $value1$, "getAndAdd $type$");
$type$ c = ($type$) vh.addAndGet(recv, $value3$);
- assertEquals(c, $value1$ + $value3$ + $value3$, "getAndAdd $type$ value");
+ assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value");
}
#end[AtomicAdd]
}
@@ -771,7 +771,7 @@
$type$ o = ($type$) vh.getAndAdd( $value3$);
assertEquals(o, $value1$, "getAndAdd $type$");
$type$ c = ($type$) vh.addAndGet($value3$);
- assertEquals(c, $value1$ + $value3$ + $value3$, "getAndAdd $type$ value");
+ assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value");
}
#end[AtomicAdd]
}
@@ -977,7 +977,7 @@
$type$ o = ($type$) vh.getAndAdd(array, i, $value3$);
assertEquals(o, $value1$, "getAndAdd $type$");
$type$ c = ($type$) vh.addAndGet(array, i, $value3$);
- assertEquals(c, $value1$ + $value3$ + $value3$, "getAndAdd $type$ value");
+ assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value");
}
#end[AtomicAdd]
}
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template Wed Jun 15 11:20:15 2016 +0300
@@ -265,7 +265,7 @@
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(recv, $value3$);
assertEquals(o, $value1$, "getAndAdd $type$");
$type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(recv, $value3$);
- assertEquals(c, $value1$ + $value3$ + $value3$, "getAndAdd $type$ value");
+ assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value");
}
#end[AtomicAdd]
}
@@ -448,7 +448,7 @@
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact( $value3$);
assertEquals(o, $value1$, "getAndAdd $type$");
$type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact($value3$);
- assertEquals(c, $value1$ + $value3$ + $value3$, "getAndAdd $type$ value");
+ assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value");
}
#end[AtomicAdd]
}
@@ -634,7 +634,7 @@
$type$ o = ($type$) hs.get(TestAccessMode.GET_AND_ADD).invokeExact(array, i, $value3$);
assertEquals(o, $value1$, "getAndAdd $type$");
$type$ c = ($type$) hs.get(TestAccessMode.ADD_AND_GET).invokeExact(array, i, $value3$);
- assertEquals(c, $value1$ + $value3$ + $value3$, "getAndAdd $type$ value");
+ assertEquals(c, ($type$)($value1$ + $value3$ + $value3$), "getAndAdd $type$ value");
}
#end[AtomicAdd]
}
--- a/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh Mon Jun 06 16:18:01 2016 -0700
+++ b/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh Wed Jun 15 11:20:15 2016 +0300
@@ -15,13 +15,13 @@
args="-K$type -Dtype=$type -DType=$Type"
case $type in
- String|int|long)
+ String|boolean|byte|short|char|int|long)
args="$args -KCAS"
;;
esac
case $type in
- int|long)
+ byte|short|char|int|long)
args="$args -KAtomicAdd"
;;
esac
@@ -36,29 +36,29 @@
wrong_primitive_type=int
;;
byte)
- value1=(byte)1
- value2=(byte)2
- value3=(byte)3
+ value1=(byte)0x01
+ value2=(byte)0x23
+ value3=(byte)0x45
;;
short)
- value1=(short)1
- value2=(short)2
- value3=(short)3
+ value1=(short)0x0123
+ value2=(short)0x4567
+ value3=(short)0x89AB
;;
char)
- value1=\'a\'
- value2=\'b\'
- value3=\'c\'
+ value1=\'\\\\u0123\'
+ value2=\'\\\\u4567\'
+ value3=\'\\\\u89AB\'
;;
int)
- value1=1
- value2=2
- value3=3
+ value1=0x01234567
+ value2=0x89ABCDEF
+ value3=0xCAFEBABE
;;
long)
- value1=1L
- value2=2L
- value3=3L
+ value1=0x0123456789ABCDEFL
+ value2=0xCAFEBABECAFEBABEL
+ value3=0xDEADBEEFDEADBEEFL
;;
float)
value1=1.0f