Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8267612; Declare package-private VarHandle.AccessMode/AccessType counts #4164

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/* package */ class IndirectVarHandle extends VarHandle {

@Stable
private final MethodHandle[] handleMap = new MethodHandle[AccessMode.values().length];
private final MethodHandle[] handleMap = new MethodHandle[AccessMode.COUNT];
private final VarHandle directTarget; // cache, for performance reasons
private final VarHandle target;
private final BiFunction<AccessMode, MethodHandle, MethodHandle> handleFactory;
Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/java/lang/invoke/Invokers.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class Invokers {
INV_GENERIC = 1, // MethodHandles.invoker (generic invocation)
INV_BASIC = 2, // MethodHandles.basicInvoker
VH_INV_EXACT = 3, // MethodHandles.varHandleExactInvoker
VH_INV_GENERIC = VH_INV_EXACT + VarHandle.AccessMode.values().length, // MethodHandles.varHandleInvoker
INV_LIMIT = VH_INV_GENERIC + VarHandle.AccessMode.values().length;
VH_INV_GENERIC = VH_INV_EXACT + VarHandle.AccessMode.COUNT, // MethodHandles.varHandleInvoker
INV_LIMIT = VH_INV_GENERIC + VarHandle.AccessMode.COUNT;

/** Compute and cache information common to all collecting adapters
* that implement members of the erasure-family of the given erased type.
Expand Down
6 changes: 3 additions & 3 deletions src/java.base/share/classes/java/lang/invoke/VarForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ final class VarForm {
final @Stable MemberName[] memberName_table;

VarForm(Class<?> implClass, Class<?> receiver, Class<?> value, Class<?>... intermediate) {
this.methodType_table = new MethodType[VarHandle.AccessType.values().length];
this.memberName_table = new MemberName[VarHandle.AccessMode.values().length];
this.methodType_table = new MethodType[VarHandle.AccessType.COUNT];
this.memberName_table = new MemberName[VarHandle.AccessMode.COUNT];
this.implClass = implClass;
if (receiver == null) {
initMethodTypes(value, intermediate);
Expand All @@ -64,7 +64,7 @@ final class VarForm {

// Used by IndirectVarHandle
VarForm(Class<?> value, Class<?>[] coordinates) {
this.methodType_table = new MethodType[VarHandle.AccessType.values().length];
this.methodType_table = new MethodType[VarHandle.AccessType.COUNT];
this.memberName_table = null;
this.implClass = null;
initMethodTypes(value, coordinates);
Expand Down
14 changes: 10 additions & 4 deletions src/java.base/share/classes/java/lang/invoke/VarHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,10 @@ enum AccessType {
COMPARE_AND_EXCHANGE(Object.class),
GET_AND_UPDATE(Object.class);

static final int COUNT = GET_AND_UPDATE.ordinal() + 1;
static {
assert (COUNT == values().length);
}
final Class<?> returnType;
final boolean isMonomorphicInReturnType;

Expand Down Expand Up @@ -1890,6 +1894,10 @@ public enum AccessMode {
GET_AND_BITWISE_XOR_ACQUIRE("getAndBitwiseXorAcquire", AccessType.GET_AND_UPDATE),
;

static final int COUNT = GET_AND_BITWISE_XOR_ACQUIRE.ordinal() + 1;
static {
assert (COUNT == values().length);
}
final String methodName;
final AccessType at;

Expand Down Expand Up @@ -2112,12 +2120,10 @@ public Optional<VarHandleDesc> describeConstable() {

static class TypesAndInvokers {
final @Stable
MethodType[] methodType_table =
new MethodType[VarHandle.AccessType.values().length];
MethodType[] methodType_table = new MethodType[VarHandle.AccessType.COUNT];

final @Stable
MethodHandle[] methodHandle_table =
new MethodHandle[AccessMode.values().length];
MethodHandle[] methodHandle_table = new MethodHandle[AccessMode.COUNT];
}

@ForceInline
Expand Down