{"record":{"id":"91fb86ca842d9eb2","repo":"oracle/graal","slug":"object-is-not-a-static-object","errorCode":null,"errorMessage":"object {} is not a static object","messagePattern":"object (.+?) is not a static object","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/JDWPContextImpl.java","lineNumber":353,"sourceCode":"            return (String) UNCACHED.toDisplayString(staticObject, false);\n        }\n        return object.toString();\n    }\n\n    @Override\n    public MethodVersionRef getMethodFromRootNode(RootNode root) {\n        if (root instanceof EspressoRootNode) {\n            return ((EspressoRootNode) root).getMethodVersion();\n        }\n        return null;\n    }\n\n    @Override\n    public KlassRef getRefType(Object object) {\n        if (object instanceof StaticObject) {\n            return ((StaticObject) object).getKlass();\n        } else {\n            throw new IllegalStateException(\"object \" + object + \" is not a static object\");\n        }\n    }\n\n    @Override\n    public KlassRef getReflectedType(Object classObject) {\n        if (classObject instanceof StaticObject staticObject) {\n            if (staticObject.getKlass().getType() == Types.java_lang_Class) {\n                return (KlassRef) context.getMeta().java_lang_Class_0klass.getHiddenObject(staticObject);\n            }\n        }\n        return null;\n    }\n\n    @Override\n    public KlassRef[] getNestedTypes(KlassRef klass) {\n        if (klass instanceof ObjectKlass objectKlass) {\n            ArrayList<KlassRef> result = new ArrayList<>();\n            List<Symbol<Name>> nestedTypeNames = objectKlass.getNestedTypeNames();","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso/src/com.oracle.truffle.espresso/src/com/oracle/truffle/espresso/runtime/JDWPContextImpl.java#L335-L371","documentation":"JDWPContextImpl.getRefType(Object) expects its argument to be an Espresso StaticObject (the guest object representation) and returns its Klass; any other Java object is a caller bug, so it throws IllegalStateException. This is an internal debugger API contract, not a user-facing boundary.","triggerScenarios":"Calling getRefType with a host object, a boxed value, null-adjacent wrapper, or a polyglot Value's host receiver instead of the guest StaticObject; usually inside custom JDWP extensions or code that reached into Espresso internals.","commonSituations":"Tooling that reflects over Espresso runtime values and assumes raw java.lang.Object semantics; mixing host and guest object models in a debugger integration.","solutions":["Pass only guest objects obtained from Espresso runtime APIs (StaticObject) to this method.","Add an instanceof StaticObject check before calling and skip/handle non-guest values.","Prefer the public JDWP/polyglot APIs instead of Espresso-internal classes."],"exampleFix":"// before\nKlassRef ref = jdwp.getRefType(maybeHostObject); // throws for host objects\n\n// after\nif (maybeHostObject instanceof StaticObject so) {\n    KlassRef ref = jdwp.getRefType(so);\n} else {\n    // handle host-side value separately\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean isGuestObject(Object o) { return o instanceof com.oracle.truffle.espresso.runtime.StaticObject; }","tryCatchPattern":null,"preventionTips":["Treat JDWPContextImpl as internal API; use public JDWP/polyglot interfaces.","Always instanceof-check StaticObject before calling getRefType."],"tags":["espresso","jdwp","internal-api","type-check"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}