{"record":{"id":"c457314273bb9ae3","repo":"quarkusio/quarkus","slug":"attempted-to-use-the-getallannotations-method-bu","errorCode":null,"errorMessage":"Attempted to use the getAllAnnotations() method but AnnotationStore wasn't initialized.","messagePattern":"Attempted to use the getAllAnnotations\\(\\) method but AnnotationStore wasn't initialized\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationsTransformationContext.java","lineNumber":79,"sourceCode":"    }\n\n    void setAnnotations(C annotations) {\n        LOG.tracef(\"Annotations of %s transformed: %s\", target, annotations);\n        this.annotations = annotations;\n    }\n\n    public Collection<AnnotationInstance> getAllAnnotations() {\n        return getAllAnnotationForTarget(getTarget());\n    }\n\n    public Collection<AnnotationInstance> getAllTargetAnnotations() {\n        return getAllAnnotationForTarget(getAnnotationTarget());\n    }\n\n    private Collection<AnnotationInstance> getAllAnnotationForTarget(AnnotationTarget target) {\n        AnnotationStore annotationStore = get(BuildExtension.Key.ANNOTATION_STORE);\n        if (annotationStore == null) {\n            throw new IllegalStateException(\n                    \"Attempted to use the getAllAnnotations() method but AnnotationStore wasn't initialized.\");\n        }\n        // Jandex overlay in compatible mode won't allow us to query for METHOD_PARAMETER\n        // hence if the \"target\" is method param, we query whole method and filter it\n        if (AnnotationTarget.Kind.METHOD_PARAMETER.equals(target.kind())) {\n            return Annotations.getParameterAnnotations(annotationStore::getAnnotations,\n                    target.asMethodParameter().method(), target.asMethodParameter().position());\n        } else {\n            return annotationStore.getAnnotations(target);\n        }\n    }\n\n}\n","sourceCodeStart":61,"sourceCodeEnd":93,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationsTransformationContext.java#L61-L93","documentation":"AnnotationsTransformationContext.getAllAnnotations()/getAllTargetAnnotations() require the AnnotationStore build extension key to be initialized in the build context. If no AnnotationStore was registered (i.e. no BuildExtension providing ANNOTATION_STORE is active), the context throws IllegalStateException. This is an internal invariant: annotation transformation extensions can only read annotations through the store.","triggerScenarios":"A custom BuildExtension/AnnotationTransformer calls ctx.getAllAnnotations() or getAllTargetAnnotations() while the AnnotationStore isn't part of the build (e.g. extension not properly registered/initialized, or transformation context used outside a deployment where the store is set up).","commonSituations":"Writing a custom Arc annotation transformer extension; using the transformation context in a test harness without the full BeanDeployment initialization; BuildExtension priority/registration mistakes.","solutions":["Ensure your BuildExtension is registered and initialized (initialize(ctx) receives the context that wires the AnnotationStore)","Use getAnnotationStore()/store-backed access only after initialization completes","In custom harnesses, initialize BeanDeployment/AnnotationStore before invoking transformations","Prefer AnnotationStore.getAnnotations(target) via a properly provided key rather than bypassing registration"],"exampleFix":"// before\npublic void transform(TransformationContext ctx) { ctx.getAllAnnotations(); } // store missing\n// after\npublic boolean initialize(BuildContext ctx) { this.ctx = ctx; return true; }\npublic void transform(TransformationContext tc) { this.ctx.get(BuildExtension.Key.ANNOTATION_STORE); ... }","handlingStrategy":"validation","validationCode":"AnnotationStore store = ctx.get(BuildExtension.Key.ANNOTATION_STORE);\nif (store == null) throw new IllegalStateException(\"Initialize your BuildExtension before using getAllAnnotations()\");","typeGuard":"static boolean storeReady(BuildContext ctx) { return ctx.get(BuildExtension.Key.ANNOTATION_STORE) != null; }","tryCatchPattern":"try { annotations = ctx.getAllAnnotations(); }\ncatch (IllegalStateException e) { log.warn(\"AnnotationStore unavailable; falling back to target.raw annotations\"); }","preventionTips":["Only call getAllAnnotations() from within extension callbacks after initialize(ctx)","Return true from BuildExtension.initialize() when you intend to use store-backed APIs","In custom harnesses, initialize BeanDeployment before transformations"],"tags":["cdi","arc","annotation-store","build-extension","initialization-order"],"backgroundTag":"build-extension-not-initialized","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"}