Skip to content

Commit a5f5a0c

Browse files
authored
Update JNIObjectHandles.java
resolved some grammar mistakes and updated the split point in JNIGlobalHandles and replaced it from bit 62 to bit 30, because it did not fit in the global handles range
1 parent 8a1490e commit a5f5a0c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jni/JNIObjectHandles.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,20 +309,20 @@ final class JNIGlobalHandles {
309309
private static final SignedWord MSB = Word.signed(1L << 63);
310310

311311
// Define the mid-point to split the range in half
312-
private static final SignedWord GLOBAL_RANGE_SPLIT_POINT = Word.signed(1L << 62);
312+
private static final SignedWord HANDLE_RANGE_SPLIT_POINT = Word.signed(1L << 30);
313313

314314
// Strong global handles will occupy the lower half of the global handles range
315-
public static final SignedWord STRONG_GLOBAL_RANGE_MIN = MIN_VALUE;
316-
public static final SignedWord STRONG_GLOBAL_RANGE_MAX = GLOBAL_RANGE_SPLIT_POINT.substract(1);
315+
public static final SignedWord STRONG_GLOBAL_RANGE_MIN = JNIObjectHandles.nullHandle().add(1);;
316+
public static final SignedWord STRONG_GLOBAL_RANGE_MAX = HANDLE_RANGE_SPLIT_POINT.subtract(1);
317317

318318
// Weak global handles will occupy the upper half of the global handles range
319-
public static final SignedWord WEAK_GLOBAL_RANGE_MIN = GLOBAL_RANGE_SPLIT_POINT;
320-
public static final SignedWord WEAK_GLOBAL_RANGE_MAX = MAX_VALUE;
319+
public static final SignedWord WEAK_GLOBAL_RANGE_MIN = HANDLE_RANGE_SPLIT_POINT;
320+
public static final SignedWord WEAK_GLOBAL_RANGE_MAX = HANDLE_BITS_MASK;
321321

322322
private static final ObjectHandlesImpl strongGlobalHandles
323-
= new ObjectHandlesImpl(STRONG_GLOBAL_RANGE_MIN.add(1), STRONG_GLOBAL_RANGE_MAX, JNIObjectHandles.nullHandle());
323+
= new ObjectHandlesImpl(STRONG_GLOBAL_RANGE_MIN, STRONG_GLOBAL_RANGE_MAX, JNIObjectHandles.nullHandle());
324324
private static final ObjectHandlesImpl weakGlobalHandles
325-
= new ObjectHandlesImpl(WEAK_GLOBAL_RANGE_MIN.add(1), WEAK_GLOBAL_RANGE_MAX, JNIObjectHandles.nullHandle());
325+
= new ObjectHandlesImpl(WEAK_GLOBAL_RANGE_MIN, WEAK_GLOBAL_RANGE_MAX, JNIObjectHandles.nullHandle());
326326

327327
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
328328
static boolean isInRange(JNIObjectHandle handle) {
@@ -378,7 +378,7 @@ static <T> T getObject(JNIObjectHandle handle) {
378378
return weakGlobalHandles.get(decode((handle)));
379379
}
380380

381-
throw throwIllegalArgumentException();
381+
throw new IllegalArgumentException("Invalid handle");
382382
}
383383

384384
static JNIObjectRefType getHandleType(JNIObjectHandle handle) {

0 commit comments

Comments
 (0)