{"record":{"id":"93bc551056d0c6ed","repo":"quarkusio/quarkus","slug":"annotation-does-not-have-retention-runtime","errorCode":null,"errorMessage":"Annotation does not have @Retention(RUNTIME): ","messagePattern":"Annotation does not have @Retention\\(RUNTIME\\): ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationLiteralProcessor.java","lineNumber":88,"sourceCode":"     * if not. Further, it is expected that the annotation type is available (that is,\n     * {@code annotationClass != null}); an exception is thrown if not. Callers that expect\n     * they always deal with runtime-retained annotations whose classes are available do not\n     * have to check (and will get decent errors for free), but callers that can possibly deal\n     * with class-retained annotations or missing annotation classes must check explicitly.\n     * <p>\n     * We call the generated implementation of the annotation type an <em>annotation literal class</em>\n     * and the instance produced by the generated bytecode an <em>annotation literal instance</em>,\n     * even though the generated code doesn't use CDI's {@code AnnotationLiteral}.\n     *\n     * @param bc will receive the bytecode sequence for instantiating the annotation literal class\n     *        as a sequence of {@link BlockCreator} method calls\n     * @param annotationClass the annotation type\n     * @param annotationInstance the annotation instance; must match the {@code annotationClass}\n     * @return an annotation literal instance result handle\n     */\n    public Expr create(BlockCreator bc, ClassInfo annotationClass, AnnotationInstance annotationInstance) {\n        if (!annotationInstance.runtimeVisible()) {\n            throw new IllegalArgumentException(\"Annotation does not have @Retention(RUNTIME): \" + annotationInstance);\n        }\n        if (annotationClass == null) {\n            throw new IllegalArgumentException(\"Annotation class not available: \" + annotationInstance);\n        }\n\n        AnnotationLiteralClassInfo literal = cache.getValue(new CacheKey(annotationClass));\n\n        ClassDesc generatedClass = ClassDesc.of(literal.generatedClassName);\n\n        if (literal.annotationMembers().isEmpty()) {\n            return bc.getStaticField(FieldDesc.of(generatedClass, \"INSTANCE\", generatedClass));\n        }\n\n        Expr[] ctorArgs = new Expr[literal.annotationMembers().size()];\n        int argIndex = 0;\n        for (MethodInfo annotationMember : literal.annotationMembers()) {\n            AnnotationValue value = annotationInstance.value(annotationMember.name());\n            if (value == null) {","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationLiteralProcessor.java#L70-L106","documentation":"Arc's AnnotationLiteralProcessor generates annotation literal subclasses at build time. Jandex annotations must be marked runtime-visible (i.e. @Retention(RUNTIME)) for literal generation; otherwise an IllegalArgumentException is thrown naming the offending annotation instance.","triggerScenarios":"Arc.create(...) processing an annotation instance whose runtimeVisible() flag is false — typically a source/class-retention annotation — passed to AnnotationLiteralProcessor.create.","commonSituations":"Using an annotation declared with @Retention(SOURCE) or @Retention(CLASS) in CDI injection points; indexing code where retention metadata differs from expectations; custom annotations missing @Retention(RUNTIME).","solutions":["Declare the annotation with @Retention(RetentionPolicy.RUNTIME)","Remove the non-runtime annotation from CDI-managed code","Check that the Jandex index reflects the compiled annotation retention"],"exampleFix":"// before\n@Target(TYPE) @Retention(RetentionPolicy.CLASS)\npublic @interface MyMarker {}\n// after\n@Target(TYPE) @Retention(RetentionPolicy.RUNTIME)\npublic @interface MyMarker {}","handlingStrategy":"validation","validationCode":"Retention r = MyAnno.class.getAnnotation(Retention.class); if (r == null || r.value() != RetentionPolicy.RUNTIME) throw new IllegalArgumentException(\"needs RUNTIME\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use @Retention(RUNTIME) on CDI annotations"],"tags":["arc","cdi","annotations","jandex"],"backgroundTag":"annotation-retention-runtime-required","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"}