{"record":{"id":"fff008510e5d225b","repo":"pinpoint-apm/pinpoint","slug":"fieldname-access-error","errorCode":null,"errorMessage":"<fieldName> access error","messagePattern":"<fieldName> access error","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"commons-config/src/main/java/com/navercorp/pinpoint/common/config/util/ValueAnnotationProcessor.java","lineNumber":190,"sourceCode":"\n    private char parseChar(String value) {\n        if (value.length() != 1) {\n            throw new IllegalArgumentException(\"Invalid value:\" + value);\n        }\n        return value.charAt(0);\n    }\n\n    private void injectField(Field field, Object target, String value) {\n        final Class<?> fieldType = field.getType();\n\n        try {\n            final Object parsedValue = parse(fieldType, value);\n            if (parsedValue != null) {\n                try {\n                    setAccessible(field);\n                    field.set(target, parsedValue);\n                } catch (ReflectiveOperationException e) {\n                    throw new ConfigurationException(getFieldName(target, field) + \" access error\", e);\n                }\n            }\n        } catch (Exception ex) {\n            throw new RuntimeException(\"injectField error field:\" + field + \" value:\" + value, ex);\n        }\n    }\n\n    private String getFieldName(Object instance, Member field) {\n        return instance.getClass().getSimpleName() + \".\" + field.getName();\n    }\n\n}\n","sourceCodeStart":172,"sourceCodeEnd":203,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-config/src/main/java/com/navercorp/pinpoint/common/config/util/ValueAnnotationProcessor.java#L172-L203","documentation":"After successfully parsing the value, injectField() uses field.set(target, parsedValue) to write it into the @Value-annotated field. If this reflective operation fails (IllegalAccessException, or an exception due to final/static constraints), a ConfigurationException named 'ClassName.fieldName access error' is thrown with the original exception as cause. Note parse() never returns null, so this wrapper only fires on reflection failures.","triggerScenarios":"field.set() fails for the annotated field — typically because the field is static final, lives under a package that blocks setAccessible under the module system / SecurityManager, or is otherwise inaccessible even after setAccessible(true).","commonSituations":"Running on JDK 9+ strong encapsulation where the config class package is not open to the processor's module; annotating a static final field expecting injection; security policies denying reflectAccess.","solutions":["Remove the final/static modifiers from the @Value-annotated field","Ensure the config class package is under com.navercorp.pinpoint and opened to the processor (add opens directives if using modules / --add-opens on the JVM)","Convert the field to a package-private non-final field with a matching setter so handleMethods can inject via method.invoke instead"],"exampleFix":"// before\n@Value(\"${log.level}\")\nprivate static final String logLevel;\n// after\n@Value(\"${log.level}\")\nprivate String logLevel;","handlingStrategy":"type-guard","validationCode":"int mods = field.getModifiers();\nif (java.lang.reflect.Modifier.isStatic(mods) || java.lang.reflect.Modifier.isFinal(mods)) {\n    throw new IllegalStateException(\"@Value field must not be static/final: \" + field);\n}","typeGuard":null,"tryCatchPattern":"try {\n    processor.process(configInstance, resolver);\n} catch (ConfigurationException e) {\n    log.error(\"Reflection access failed for {}: cause={}\", e.getMessage(), e.getCause(), e);\n    throw e;\n}","preventionTips":["Never declare @Value-annotated fields static or final","Keep config classes in com.navercorp.pinpoint packages (process() rejects others)","On JDK 9+, add the required --add-opens / opens directives if packages are encapsulated","Prefer annotated setters over fields to avoid setAccessible issues"],"tags":["java","reflection","accessibility","configuration"],"backgroundTag":"permission-denied","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}