32 static VarHandle makeFieldHandle(MemberName f, Class<?> refc, Class<?> type, boolean isWriteAllowedOnFinalFields) { |
32 static VarHandle makeFieldHandle(MemberName f, Class<?> refc, Class<?> type, boolean isWriteAllowedOnFinalFields) { |
33 if (!f.isStatic()) { |
33 if (!f.isStatic()) { |
34 long foffset = MethodHandleNatives.objectFieldOffset(f); |
34 long foffset = MethodHandleNatives.objectFieldOffset(f); |
35 if (!type.isPrimitive()) { |
35 if (!type.isPrimitive()) { |
36 return f.isFinal() && !isWriteAllowedOnFinalFields |
36 return f.isFinal() && !isWriteAllowedOnFinalFields |
37 ? new VarHandleObjects.FieldInstanceReadOnly(refc, foffset, type) |
37 ? new VarHandleReferences.FieldInstanceReadOnly(refc, foffset, type) |
38 : new VarHandleObjects.FieldInstanceReadWrite(refc, foffset, type); |
38 : new VarHandleReferences.FieldInstanceReadWrite(refc, foffset, type); |
39 } |
39 } |
40 else if (type == boolean.class) { |
40 else if (type == boolean.class) { |
41 return f.isFinal() && !isWriteAllowedOnFinalFields |
41 return f.isFinal() && !isWriteAllowedOnFinalFields |
42 ? new VarHandleBooleans.FieldInstanceReadOnly(refc, foffset) |
42 ? new VarHandleBooleans.FieldInstanceReadOnly(refc, foffset) |
43 : new VarHandleBooleans.FieldInstanceReadWrite(refc, foffset); |
43 : new VarHandleBooleans.FieldInstanceReadWrite(refc, foffset); |
93 |
93 |
94 Object base = MethodHandleNatives.staticFieldBase(f); |
94 Object base = MethodHandleNatives.staticFieldBase(f); |
95 long foffset = MethodHandleNatives.staticFieldOffset(f); |
95 long foffset = MethodHandleNatives.staticFieldOffset(f); |
96 if (!type.isPrimitive()) { |
96 if (!type.isPrimitive()) { |
97 return f.isFinal() && !isWriteAllowedOnFinalFields |
97 return f.isFinal() && !isWriteAllowedOnFinalFields |
98 ? new VarHandleObjects.FieldStaticReadOnly(base, foffset, type) |
98 ? new VarHandleReferences.FieldStaticReadOnly(base, foffset, type) |
99 : new VarHandleObjects.FieldStaticReadWrite(base, foffset, type); |
99 : new VarHandleReferences.FieldStaticReadWrite(base, foffset, type); |
100 } |
100 } |
101 else if (type == boolean.class) { |
101 else if (type == boolean.class) { |
102 return f.isFinal() && !isWriteAllowedOnFinalFields |
102 return f.isFinal() && !isWriteAllowedOnFinalFields |
103 ? new VarHandleBooleans.FieldStaticReadOnly(base, foffset) |
103 ? new VarHandleBooleans.FieldStaticReadOnly(base, foffset) |
104 : new VarHandleBooleans.FieldStaticReadWrite(base, foffset); |
104 : new VarHandleBooleans.FieldStaticReadWrite(base, foffset); |
153 int aoffset = UNSAFE.arrayBaseOffset(arrayClass); |
153 int aoffset = UNSAFE.arrayBaseOffset(arrayClass); |
154 int ascale = UNSAFE.arrayIndexScale(arrayClass); |
154 int ascale = UNSAFE.arrayIndexScale(arrayClass); |
155 int ashift = 31 - Integer.numberOfLeadingZeros(ascale); |
155 int ashift = 31 - Integer.numberOfLeadingZeros(ascale); |
156 |
156 |
157 if (!componentType.isPrimitive()) { |
157 if (!componentType.isPrimitive()) { |
158 return new VarHandleObjects.Array(aoffset, ashift, arrayClass); |
158 return new VarHandleReferences.Array(aoffset, ashift, arrayClass); |
159 } |
159 } |
160 else if (componentType == boolean.class) { |
160 else if (componentType == boolean.class) { |
161 return new VarHandleBooleans.Array(aoffset, ashift); |
161 return new VarHandleBooleans.Array(aoffset, ashift); |
162 } |
162 } |
163 else if (componentType == byte.class) { |
163 else if (componentType == byte.class) { |