{"record":{"id":"b3fd18537d43cd49","repo":"apache/dubbo","slug":"get-attribute-value-of-annotation-failed-method","errorCode":null,"errorMessage":"get attribute value of annotation failed: {method}","messagePattern":"get attribute value of annotation failed: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/utils/AnnotationUtils.java","lineNumber":575,"sourceCode":"     * @param annotation\n     * @return\n     */\n    static Map<String, Object> getAttributes(Annotation annotation, boolean filterDefaultValue) {\n        Class<?> annotationType = annotation.annotationType();\n        Method[] methods = annotationType.getMethods();\n        Map<String, Object> attributes = new LinkedHashMap<>(methods.length);\n        for (Method method : methods) {\n            try {\n                if (method.getDeclaringClass() == Annotation.class) {\n                    continue;\n                }\n                String name = method.getName();\n                Object value = method.invoke(annotation);\n                if (!filterDefaultValue || !Objects.deepEquals(value, method.getDefaultValue())) {\n                    attributes.put(name, value);\n                }\n            } catch (Exception e) {\n                throw new IllegalStateException(\"get attribute value of annotation failed: \" + method, e);\n            }\n        }\n        return attributes;\n    }\n}\n","sourceCodeStart":557,"sourceCodeEnd":581,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/AnnotationUtils.java#L557-L581","documentation":"Thrown by AnnotationUtils.getAttributes when invoking an annotation's method via reflection (method.invoke) throws any exception. getAttributes iterates every declared method of an annotation type and reads its value; any reflective failure (access denied, annotation proxy broken, exception thrown inside the attribute method) is wrapped in this IllegalStateException.","triggerScenarios":"getAttributes(annotation, filterDefaultValue) is called and method.invoke(annotation) throws — e.g. InvocationTargetException from the attribute method, IllegalAccessException under a SecurityManager, or an annotation proxy whose state is corrupted (classpath/serialization issues).","commonSituations":"Running under a restrictive SecurityManager or module boundary that blocks reflective access to annotation members; a custom/serialized annotation instance whose proxy cannot resolve; JVM or annotation-processor edge cases. The underlying cause is chained (the second constructor arg 'e').","solutions":["Read the wrapped cause (the chained Throwable) in the stack trace — the real reason is there, not in the message.","If caused by access restrictions, ensure the calling code has ReflectPermission / module 'opens' for the annotation's package.","If the annotation proxy is malformed (classpath duplication, stale serialized annotation), resolve the classpath conflict and rebuild.","Catch IllegalStateException around the getAttributes call if annotation introspection is best-effort."],"exampleFix":"// before\nMap<String,Object> attrs = AnnotationUtils.getAttributes(anno, true); // may throw\n\n// after\ntry {\n    Map<String,Object> attrs = AnnotationUtils.getAttributes(anno, true);\n} catch (IllegalStateException e) {\n    // log e.getCause() and degrade gracefully\n    log.warn(\"Cannot read annotation attributes\", e.getCause());\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    Map<String,Object> attrs = AnnotationUtils.getAttributes(anno, true);\n} catch (IllegalStateException e) {\n    Throwable cause = e.getCause(); // the real reflective failure\n    log.warn(\"Annotation introspection failed for {}\", anno, cause);\n}","preventionTips":["Read the chained cause (second constructor arg) to find the real reflective error.","Ensure the JVM/module grants reflective access to annotation members.","Avoid serialized annotation proxies; keep a clean classpath for annotation types."],"tags":["reflection","annotation","internal-api"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}