{"record":{"id":"313484b0dc72b050","repo":"oracle/graal","slug":"not-in-the-scope-of-an-jni-method-call","errorCode":null,"errorMessage":"Not in the scope of an JNI method call","messagePattern":"Not in the scope of an JNI method call","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdk/src/org.graalvm.jniutils/src/org/graalvm/jniutils/JNIMethodScope.java","lineNumber":106,"sourceCode":"\n    /**\n     * Gets the inner most {@link JNIMethodScope} value for the current thread.\n     */\n    public static JNIMethodScope scopeOrNull() {\n        JNIMethodScope scope = topScope.get();\n        if (scope == null) {\n            return null;\n        }\n        return scope.leaf;\n    }\n\n    /**\n     * Gets the inner most {@link JNIMethodScope} value for the current thread.\n     */\n    public static JNIMethodScope scope() {\n        JNIMethodScope scope = topScope.get();\n        if (scope == null) {\n            throw new IllegalStateException(\"Not in the scope of an JNI method call\");\n        }\n        return scope.leaf;\n    }\n\n    /**\n     * Enters the scope of an native method call.\n     */\n    @SuppressWarnings({\"unchecked\", \"this-escape\"})\n    public JNIMethodScope(String scopeName, JNIEnv env) {\n        Objects.requireNonNull(scopeName, \"ScopeName must be non null.\");\n        this.scopeName = scopeName;\n        JNIMethodScope top = topScope.get();\n        this.env = env;\n        if (top == null) {\n            top = this;\n            parent = null;\n            topScope.set(this);\n        } else {","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/sdk/src/org.graalvm.jniutils/src/org/graalvm/jniutils/JNIMethodScope.java#L88-L124","documentation":"Error \"Not in the scope of an JNI method call\" thrown in oracle/graal.","triggerScenarios":"Thrown at sdk/src/org.graalvm.jniutils/src/org/graalvm/jniutils/JNIMethodScope.java:106 when the library encounters an invalid state.","commonSituations":"Occurs when a caller violates the contract guarded by this check: Not in the scope of an JNI method call","solutions":["Fix the condition reported by the error: Not in the scope of an JNI method call","Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call."],"exampleFix":"Validate inputs and environment so that the failing condition does not occur: Not in the scope of an JNI method call","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}