oracle/graal · error · UnsupportedOperationException

This VM does not support identity hashcode preservation.

Error message

This VM does not support identity hashcode preservation.

What it means

UnsupportedOperationException from IdentityHashCodes.checkIsSupported: Continuation.isSupported() returned false on the current VM. Identity-hashcode preservation is implemented via native methods (isInitialized0/setIHashcode0) that only exist when the VM ships GraalVM continuation support; on a stock JDK or a GraalVM build without continuations enabled there is no native machinery behind these calls, so every public method of IdentityHashCodes (has, trySet, set) refuses up front.

Source

Thrown at espresso/src/org.graalvm.continuations/src/org/graalvm/continuations/IdentityHashCodes.java:101

    /**
     * Sets the identity hashcode of the given object if it is not already initialized, and throws
     * {@link IllegalStateException} otherwise.
     *
     * @throws UnsupportedOperationException If this VM does not support continuations.
     * @throws NullPointerException if {@code o} is {@code null}.
     * @throws IllegalArgumentException if {@code hashcode <= 0}.
     * @throws IllegalStateException if the identity hashcode of the given object is already
     *             initialized.
     */
    public static void set(Object o, int hashcode) {
        if (!trySet(o, hashcode)) {
            throw new IllegalStateException("Setting ihashcode of an object whose ihashcode is already initialized.");
        }
    }

    private static void checkIsSupported() {
        if (!Continuation.isSupported()) {
            throw new UnsupportedOperationException("This VM does not support identity hashcode preservation.");
        }
    }

    private static native boolean isInitialized0(Object o);

    private static native boolean setIHashcode0(Object o, int hashcode);

    private IdentityHashCodes() {
    }
}

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Run on a GraalVM release that supports continuations, with the required flags enabled (e.g. -Dgraal.Continuations=true for libgraal-based builds).
  2. Feature-detect before use: guard all IdentityHashCodes calls with Continuation.isSupported().
  3. Fix the runtime in CI/deployment so the same GraalVM distribution is used as in development.
  4. Provide an application-level fallback (accept newly assigned hashcodes) when continuations are unsupported.

Example fix

// before
IdentityHashCodes.set(o, recordedHash); // throws UnsupportedOperationException on stock JDK

// after
if (Continuation.isSupported()) {
    if (!IdentityHashCodes.has(o)) IdentityHashCodes.trySet(o, recordedHash);
} else {
    // identity hashcode restoration unavailable: proceed with VM-assigned hashcode
}
Defensive patterns

Strategy: validation

Validate before calling

if (!Continuation.isSupported()) {
    throw new IllegalStateException("Identity-hashcode preservation requires a GraalVM build with continuations enabled");
}

Prevention

When it happens

Trigger: Calling IdentityHashCodes.has/trySet/set on a regular HotSpot JDK or a GraalVM where continuations are not available/enabled; deserializing continuations on a runtime that lacks the required native support.

Common situations: Code developed on GraalVM but run in CI or production on a vanilla OpenJDK; unit tests executed under a plain JRE; mixing runtimes so that the continuation library loads but the native layer does not.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/2ded3c8d241cd03b. Report an issue: GitHub.