oracle/graal · error · IllegalArgumentException
Global JNI handle already exists for object referenced by <h
Error message
Global JNI handle already exists for object referenced by <handle.rawValue()>
What it means
Error "Global JNI handle already exists for object referenced by <handle.rawValue()>" thrown in oracle/graal.
Source
Thrown at sdk/src/org.graalvm.jniutils/src/org/graalvm/jniutils/HSObject.java:181
cleaner.clean(env);
}
}
/**
* Processes {@link #CLEANERS_QUEUE} to release any handles whose objects are now unreachable.
*/
public static void cleanHandles(JNIEnv env) {
Cleaner cleaner;
while ((cleaner = (Cleaner) CLEANERS_QUEUE.poll()) != null) {
cleaner.clean(env);
}
}
private static void checkNonExistingGlobalReference(JNIEnv env, JObject handle) {
for (Cleaner cleaner : CLEANERS) {
synchronized (cleaner) {
if (cleaner.handle.isNonNull() && JNIUtil.IsSameObject(env, handle, cleaner.handle)) {
throw new IllegalArgumentException("Global JNI handle already exists for object referenced by " + handle.rawValue());
}
}
}
}
private static boolean assertionsEnabled() {
boolean res = false;
assert (res = true) == true;
return res;
}
/**
* Strong references to the {@link PhantomReference} objects.
*/
private static final Set<Cleaner> CLEANERS = Collections.newSetFromMap(new ConcurrentHashMap<>());
/**
* Queue into which a {@link Cleaner} is enqueued when its {@link HSObject} referent becomesView on GitHub (pinned to a66e9ccd1d)
Solutions
- Fix the condition reported by the error: Global JNI handle already exists for object referenced by <handle.rawValue()>
- Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call.
Example fix
Validate inputs and environment so that the failing condition does not occur: Global JNI handle already exists for object referenced by <handle.rawValue()>
When it happens
Trigger: Thrown at sdk/src/org.graalvm.jniutils/src/org/graalvm/jniutils/HSObject.java:181 when the library encounters an invalid state.
Common situations: Occurs when a caller violates the contract guarded by this check: Global JNI handle already exists for object referenced by <handle.rawValue()>
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/7ed841e095596129.
Report an issue: GitHub.