{"record":{"id":"7911680c21ce91b8","repo":"quarkusio/quarkus","slug":"not-an-annotation","errorCode":null,"errorMessage":"Not an annotation: ","messagePattern":"Not an annotation: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Annotations.java","lineNumber":251,"sourceCode":"    @SuppressWarnings(\"unchecked\")\n    private static Class<? extends Annotation> annotationType(Annotation annotation) {\n        Class<? extends Annotation> annotationType = null;\n\n        Queue<Class<?>> candidates = new ArrayDeque<>();\n        candidates.add(annotation.getClass());\n        while (!candidates.isEmpty()) {\n            Class<?> candidate = candidates.remove();\n\n            if (candidate.isAnnotation()) {\n                annotationType = (Class<? extends Annotation>) candidate;\n                break;\n            }\n\n            Collections.addAll(candidates, candidate.getInterfaces());\n        }\n\n        if (annotationType == null) {\n            throw new IllegalArgumentException(\"Not an annotation: \" + annotation);\n        }\n\n        return annotationType;\n    }\n\n    private static <A extends Annotation> org.jboss.jandex.AnnotationValue[] jandexAnnotationValues(\n            Class<A> annotationType, A annotationInstance) {\n        List<org.jboss.jandex.AnnotationValue> result = new ArrayList<>();\n        for (Method member : annotationType.getDeclaredMethods()) {\n            try {\n                // annotation types do not necessarily have to be public (if the annotation type\n                // and the build compatible extension class reside in the same package)\n                if (!member.canAccess(annotationInstance)) {\n                    member.setAccessible(true);\n                }\n                result.add(jandexAnnotationValue(member.getName(), member.invoke(annotationInstance)));\n            } catch (ReflectiveOperationException e) {\n                throw new RuntimeException(e);","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Annotations.java#L233-L269","documentation":"Annotations.annotationType() resolves the annotation interface (Class) for a given object (typically a AnnotationLiteral or annotation instance). It walks the class and its interfaces looking for one that isInterface() && isAnnotation(); if none is found it throws IllegalArgumentException. This guards APIs that require a real annotation instance.","triggerScenarios":"Calling an Arc API with an object that is not an annotation or annotation literal whose class hierarchy contains an annotation interface — e.g. passing a plain Object/subclass to a method expecting an annotation or AnnotationLiteral, or a literal class that fails to be recognized as implementing Annotation.","commonSituations":"Hand-rolled 'annotation literal' classes that extend the wrong base or are generated by bytecode manipulation; passing a qualifier instance of the wrong type; reflection-created proxies losing annotation marker interfaces.","solutions":["Pass a proper jakarta.enterprise.util.AnnotationLiteral subclass or a real annotation instance","Verify the argument's class actually implements java.lang.annotation.Annotation at runtime","Check that custom literal classes extend AnnotationLiteral<AnnotationType> with the correct type parameter","If using proxies/bytecode enhancement, ensure the annotation interface is retained"],"exampleFix":"// before\nObject q = new MyQualifierImpl(); // not an Annotation\n// after\nMyQualifier q = new MyQualifier() { /* AnnotationLiteral impl */ };","handlingStrategy":"type-guard","validationCode":"if (!(candidate instanceof Annotation a)) throw new IllegalArgumentException(\"Not an annotation\");\nif (!a.annotationType().isAnnotation()) throw new IllegalArgumentException(\"No annotation interface\");","typeGuard":"static boolean isAnnotationInstance(Object o) {\n    return o instanceof Annotation a && a.annotationType().isAnnotation();\n}","tryCatchPattern":"try { Class<? extends Annotation> t = Annotations.annotationType(ann); }\ncatch (IllegalArgumentException e) { log.error(\"Not an annotation: pass AnnotationLiteral subclass\", e); }","preventionTips":["Always pass real annotations or AnnotationLiteral subclasses to Arc APIs","Give custom literals the correct generic type parameter","Unit-test literal classes by asserting annotationType() resolves"],"tags":["cdi","arc","annotation","illegal-argument"],"backgroundTag":"not-an-annotation-instance","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"}