{"record":{"id":"2ded3c8d241cd03b","repo":"oracle/graal","slug":"this-vm-does-not-support-identity-hashcode-preserv","errorCode":null,"errorMessage":"This VM does not support identity hashcode preservation.","messagePattern":"This VM does not support identity hashcode preservation\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"espresso/src/org.graalvm.continuations/src/org/graalvm/continuations/IdentityHashCodes.java","lineNumber":101,"sourceCode":"    /**\n     * Sets the identity hashcode of the given object if it is not already initialized, and throws\n     * {@link IllegalStateException} otherwise.\n     *\n     * @throws UnsupportedOperationException If this VM does not support continuations.\n     * @throws NullPointerException if {@code o} is {@code null}.\n     * @throws IllegalArgumentException if {@code hashcode <= 0}.\n     * @throws IllegalStateException if the identity hashcode of the given object is already\n     *             initialized.\n     */\n    public static void set(Object o, int hashcode) {\n        if (!trySet(o, hashcode)) {\n            throw new IllegalStateException(\"Setting ihashcode of an object whose ihashcode is already initialized.\");\n        }\n    }\n\n    private static void checkIsSupported() {\n        if (!Continuation.isSupported()) {\n            throw new UnsupportedOperationException(\"This VM does not support identity hashcode preservation.\");\n        }\n    }\n\n    private static native boolean isInitialized0(Object o);\n\n    private static native boolean setIHashcode0(Object o, int hashcode);\n\n    private IdentityHashCodes() {\n    }\n}\n","sourceCodeStart":83,"sourceCodeEnd":112,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/org.graalvm.continuations/src/org/graalvm/continuations/IdentityHashCodes.java#L83-L112","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run on a GraalVM release that supports continuations, with the required flags enabled (e.g. -Dgraal.Continuations=true for libgraal-based builds).","Feature-detect before use: guard all IdentityHashCodes calls with Continuation.isSupported().","Fix the runtime in CI/deployment so the same GraalVM distribution is used as in development.","Provide an application-level fallback (accept newly assigned hashcodes) when continuations are unsupported."],"exampleFix":"// before\nIdentityHashCodes.set(o, recordedHash); // throws UnsupportedOperationException on stock JDK\n\n// after\nif (Continuation.isSupported()) {\n    if (!IdentityHashCodes.has(o)) IdentityHashCodes.trySet(o, recordedHash);\n} else {\n    // identity hashcode restoration unavailable: proceed with VM-assigned hashcode\n}","handlingStrategy":"validation","validationCode":"if (!Continuation.isSupported()) {\n    throw new IllegalStateException(\"Identity-hashcode preservation requires a GraalVM build with continuations enabled\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard every IdentityHashCodes call with Continuation.isSupported().","Standardize development, CI, and production on the same GraalVM distribution.","Provide a documented fallback (accept VM-assigned hashcodes) when support is absent."],"tags":["continuations","graalvm","unsupported-vm","identity-hashcode"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}