{"record":{"id":"4ec866ad4bdea6e0","repo":"quarkusio/quarkus","slug":"cannot-read-field-value-classname-name","errorCode":null,"errorMessage":"Cannot read field value: ${className}#${name}","messagePattern":"Cannot read field value: (.+?)#(.+?)","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Reflections.java","lineNumber":160,"sourceCode":"                // this method is only used to instantiate beans, so throwing `CreationException` is fine\n                throw new CreationException(cause);\n            } catch (InstantiationException | IllegalAccessException | IllegalArgumentException e) {\n                throw new RuntimeException(\"Cannot invoke constructor: \" + clazz.getName(), e);\n            }\n        }\n        throw new RuntimeException(\n                \"No \" + clazz.getName() + \"constructor found for params: \" + Arrays.toString(parameterTypes));\n    }\n\n    public static Object readField(Class<?> clazz, String name, Object instance) {\n        try {\n            Field field = clazz.getDeclaredField(name);\n            if (!field.canAccess(instance)) {\n                field.setAccessible(true);\n            }\n            return field.get(instance);\n        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {\n            throw new RuntimeException(\"Cannot read field value: \" + clazz.getName() + \"#\" + name, e);\n        }\n    }\n\n    public static void writeField(Class<?> clazz, String name, Object instance, Object value) {\n        try {\n            Field field = clazz.getDeclaredField(name);\n            if (!field.canAccess(instance)) {\n                field.setAccessible(true);\n            }\n            field.set(instance, value);\n        } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {\n            throw new RuntimeException(\"Cannot set field value: \" + clazz.getName() + \"#\" + name, e);\n        }\n    }\n\n    public static Object invokeMethod(Class<?> clazz, String name, Class<?>[] paramTypes, Object instance, Object[] args) {\n        try {\n            Method method = clazz.getDeclaredMethod(name, paramTypes);","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Reflections.java#L142-L178","documentation":"Reflections.readField() fetches a declared field's value reflectively, calling setAccessible(true) if needed. Any NoSuchFieldException, SecurityException, IllegalArgumentException, or IllegalAccessException is rethrown as a RuntimeException identifying the class and field name. This typically means the field name is wrong or reflective access was denied.","triggerScenarios":"Calling Reflections.readField(clazz, name, instance) where clazz has no declared field `name`, a security manager / module rules block access, the instance is not of the right type (IllegalArgumentException), or the field cannot be accessed (IllegalAccessException, e.g. final or inaccessible in native mode without configuration).","commonSituations":"Field renamed after a refactor while extension/test code still uses the old name; accessing private fields of JDK/library classes under strong encapsulation; GraalVM native image where the field was not registered for reflection; passing a null or mismatched instance.","solutions":["Verify the field name and that it is declared on the exact class passed in","Register the field/class for reflection when building a native image","Pass an instance compatible with the declaring class (or null for static fields)","Prefer a getter/accessor API over reflective field access when available"],"exampleFix":"// before\nString v = (String) Reflections.readField(Config.class, \"valeu\", config);\n// after\nString v = (String) Reflections.readField(Config.class, \"value\", config);","handlingStrategy":"validation","validationCode":"try { clazz.getDeclaredField(name); } catch (NoSuchFieldException e) {\n    throw new IllegalArgumentException(\"Field \" + name + \" missing on \" + clazz);\n}","typeGuard":"static boolean hasField(Class<?> c, String name) { try { c.getDeclaredField(name); return true; } catch (NoSuchFieldException e) { return false; } }","tryCatchPattern":"try { return Reflections.readField(clazz, name, instance); }\ncatch (RuntimeException e) { log.warn(\"Field read failed: \" + clazz.getName() + \"#\" + name, e); return fallback; }","preventionTips":["Prefer getters over reflective field access","Register classes/fields for reflection in native builds","Verify field names after refactors with tests"],"tags":["cdi","reflection","field-access","quarkus-arc"],"backgroundTag":"reflective-access-denied","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}