{"record":{"id":"2d4f9ec943fc4e1f","repo":"quarkusio/quarkus","slug":"reflection-invocation-error","errorCode":null,"errorMessage":"Reflection invocation error","messagePattern":"Reflection invocation error","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/qute/core/src/main/java/io/quarkus/qute/FieldAccessor.java","lineNumber":23,"sourceCode":"\n/**\n *\n * @see ReflectionValueResolver\n */\nclass FieldAccessor implements ValueAccessor, AccessorCandidate {\n\n    private final Field field;\n\n    FieldAccessor(Field field) {\n        this.field = field;\n    }\n\n    @Override\n    public CompletionStage<Object> getValue(Object instance) {\n        try {\n            return CompletionStageSupport.toCompletionStage(field.get(instance));\n        } catch (Exception e) {\n            throw new IllegalStateException(\"Reflection invocation error\", e);\n        }\n    }\n\n    @Override\n    public ValueAccessor getAccessor(EvalContext context) {\n        return this;\n    }\n\n}\n","sourceCodeStart":5,"sourceCodeEnd":33,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/qute/core/src/main/java/io/quarkus/qute/FieldAccessor.java#L5-L33","documentation":"FieldAccessor.getValue() reads a field reflectively via field.get(instance) and wraps any reflective failure (IllegalAccessException, NPE on null instance, IllegalArgumentException for wrong type) in an IllegalStateException with message \"Reflection invocation error\". It indicates the accessor could not read the field at runtime.","triggerScenarios":"Value resolvers falling back to reflection (e.g. in dev mode, tests, or native image without generated accessors) when the field is not accessible, the instance is null, or the field's class was reloaded/changed (dev mode hot reload).","commonSituations":"Native-image builds missing reflection registration for the target class; dev-mode class redefinition invalidating cached Field objects; accessing a field on the wrong instance type.","solutions":["Ensure the class/field is registered for reflection when running in native mode (@RegisterForReflection or reflect-config.json).","Check that the instance being evaluated is of the expected type and not null.","In dev mode, trigger a clean restart so cached reflection accessors are rebuilt.","Prefer generated value resolvers (compile-time) over reflection fallback by having proper bean classes/records accessible."],"exampleFix":"// before (native image)\n// no reflection config\n// after\n@RegisterForReflection\nclass MyDto { String name; }\n// or add to reflect-config.json:\n// {\"name\":\"MyDto\",\"allPublicFields\":true}","handlingStrategy":"try-catch","validationCode":"Field f = instance.getClass().getDeclaredField(name);\nif (!f.isAccessible() /* or try setAccessible */) { /* register for reflection */ }","typeGuard":"boolean canReadReflectively(Object instance, String field) {\n    if (instance == null) return false;\n    try { instance.getClass().getDeclaredField(field); return true; }\n    catch (NoSuchFieldException e) { return false; }\n}","tryCatchPattern":"try {\n    Object v = accessor.getValue(instance).toCompletableFuture().join();\n} catch (IllegalStateException ex) {\n    LOGGER.warn(\"reflective field read failed\", ex.getCause());\n    // fallback resolver or rethrow with context\n}","preventionTips":["Register classes for reflection (@RegisterForReflection / reflect-config.json) for native builds","Keep generated value resolvers in play by avoiding unnecessary reflection fallbacks","Clean-restart dev mode after class redefinition errors","Null-check the instance before property resolution"],"tags":["qute","reflection","native-image","illegal-state"],"backgroundTag":"reflection-invocation-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}