{"record":{"id":"676facf4bf621c1a","repo":"quarkusio/quarkus","slug":"error-checking-value-of-member-method-methodname","errorCode":null,"errorMessage":"Error checking value of member method ${methodName} on ${declaringClass}","messagePattern":"Error checking value of member method (.+?) on (.+?)","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Qualifiers.java","lineNumber":147,"sourceCode":"        }\n        return false;\n    }\n\n    boolean isSubset(Set<Annotation> observedQualifiers, Set<Annotation> eventQualifiers) {\n        for (Annotation required : observedQualifiers) {\n            if (!hasQualifier(eventQualifiers, required)) {\n                return false;\n            }\n        }\n        return true;\n    }\n\n    private static Object invoke(Method method, Object instance) {\n        try {\n            method.setAccessible(true);\n            return method.invoke(instance);\n        } catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {\n            throw new RuntimeException(\n                    \"Error checking value of member method \" + method.getName() + \" on \" + method.getDeclaringClass(), e);\n        }\n    }\n\n    private void verifyQualifier(Class<? extends Annotation> annotationType) {\n        if (!allQualifiers.contains(annotationType.getName())) {\n            throw new IllegalArgumentException(\"Annotation is not a registered qualifier: \" + annotationType);\n        }\n    }\n\n    private static class TimesSeenBiFunction implements BiFunction<Class<? extends Annotation>, Integer, Integer> {\n\n        private static final TimesSeenBiFunction INSTANCE = new TimesSeenBiFunction();\n\n        private TimesSeenBiFunction() {\n        }\n\n        @Override","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/runtime/src/main/java/io/quarkus/arc/impl/Qualifiers.java#L129-L165","documentation":"Qualifiers.compareMembers/val1/val2 invoke annotation member methods reflectively to compare qualifier values. If the reflective invocation fails (IllegalArgumentException, IllegalAccessException, or InvocationTargetException), it is wrapped in a RuntimeException with this message and the original cause attached.","triggerScenarios":"A qualifier member method throwing an exception when invoked (e.g. member computes a value and fails), the annotation proxy instance is of the wrong type for the method, or access restrictions (module/JPMS, native-image) block the invocation.","commonSituations":"Custom qualifiers with member values computed by code that throws; comparing qualifier instances across classloaders so the method doesn't belong to the instance's class; native-image/GraalVM reaching methods not registered for reflection.","solutions":["Inspect the wrapped cause (getCause()) — it identifies the real failure (access, wrong instance, or member threw).","Ensure qualifier members are simple constants (String/int/enum/Class/arrays) that cannot throw.","Make sure qualifier annotations on beans and at lookup come from the same classloader/artifact version.","In native mode, verify the qualifier annotation is part of the application's own code (auto-registered) and not built reflectively at runtime."],"exampleFix":"// before\n@Qualifier\n@Retention(RUNTIME)\npublic @interface MyQ { String value() default System.getProperty(\"env\"); } // can throw\n// after\n@Qualifier\n@Retention(RUNTIME)\npublic @interface MyQ { String value(); } // constant at use site","handlingStrategy":"try-catch","validationCode":"// pre-check that qualifier members are plain value members\nfor (Method m : qualifierType.getDeclaredMethods()) {\n    if (m.getParameterCount() != 0 && !m.isDefault()) throw new IllegalStateException(\"Bad member: \" + m);\n}","typeGuard":null,"tryCatchPattern":"try {\n    compareQualifiers(q1, q2);\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof InvocationTargetException) {\n        log.error(\"Qualifier member threw during comparison\", e.getCause().getCause());\n    }\n    throw e;\n}","preventionTips":["Keep qualifier members limited to compile-time constants (String, primitives, enums, Class, arrays)","Ensure bean and lookup qualifiers come from the same classloader/artifact","In native mode, rely on annotations from the application image, not runtime-built proxies"],"tags":["cdi","qualifier","reflection","arc"],"backgroundTag":"reflective-invocation-failed","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"}