Skip to content

Commit d700e81

Browse files
committed
Use offset() instead of the field in FieldInfo to get the correct value on JDK 21
1 parent 3d6910b commit d700e81

File tree

1 file changed

+8
-5
lines changed
  • truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object

1 file changed

+8
-5
lines changed

truffle/src/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/FieldInfo.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ final class FieldInfo extends DynamicObjectFieldLocation implements Comparable<F
5555
private static final boolean JDK21 = Runtime.version().feature() == 21;
5656
private static final int UNUSED_OFFSET = 0;
5757

58-
/** Field offset. Used by AtomicFieldUpdaterOffset recomputation. Do not rename! */
58+
/**
59+
* Field offset. Used by AtomicFieldUpdaterOffset recomputation. Do not rename! On JDK21 this is
60+
* 0, so always use {@link #offset()} instead of this field directly.
61+
*/
5962
private final long offset;
6063
/** Declaring class. Used by AtomicFieldUpdaterOffset recomputation. Do not rename! */
6164
private final Class<? extends DynamicObject> tclass;
@@ -116,19 +119,19 @@ public String name() {
116119

117120
@Override
118121
public String toString() {
119-
return name + ":" + offset;
122+
return name + ":" + offset();
120123
}
121124

122125
@Override
123126
public int compareTo(FieldInfo other) {
124-
return Long.compare(this.offset, other.offset);
127+
return Long.compare(this.offset(), other.offset());
125128
}
126129

127130
@Override
128131
public int hashCode() {
129132
final int prime = 31;
130133
int result = 1;
131-
result = prime * result + Long.hashCode(offset);
134+
result = prime * result + Long.hashCode(offset());
132135
result = prime * result + tclass.hashCode();
133136
return result;
134137
}
@@ -141,7 +144,7 @@ public boolean equals(Object obj) {
141144
if (!(obj instanceof FieldInfo other)) {
142145
return false;
143146
}
144-
return this.offset == other.offset && this.tclass == other.tclass;
147+
return this.offset() == other.offset() && this.tclass == other.tclass;
145148
}
146149

147150
void receiverCheck(DynamicObject store) {

0 commit comments

Comments
 (0)