{"record":{"id":"1caf6effdffc4643","repo":"quarkusio/quarkus","slug":"unsupported-target","errorCode":null,"errorMessage":"Unsupported target:","messagePattern":"Unsupported target:","errorType":"error_code","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/CachedResultsProcessor.java","lineNumber":344,"sourceCode":"\n        AnnotationValue lockTimeoutValue = annotation.value(\"lockTimeout\");\n        if (lockTimeoutValue != null)\n            lockTimeout = lockTimeoutValue.asLong();\n\n        AnnotationValue keyGeneratorValue = annotation.value(\"keyGenerator\");\n        if (keyGeneratorValue != null)\n            keyGenerator = keyGeneratorValue.asClass().name();\n\n        AnnotationValue excludeValue = annotation.value(\"exclude\");\n        if (excludeValue != null)\n            exclude = excludeValue.asString();\n\n        if (annotation.target().kind() == Kind.FIELD) {\n            type = annotation.target().asField().type();\n        } else if (annotation.target().kind() == Kind.METHOD_PARAMETER) {\n            type = annotation.target().asMethodParameter().type();\n        } else {\n            throw new IllegalStateException(\"Unsupported target:\" + annotation.target());\n        }\n\n        if (type.kind() != Type.Kind.CLASS) {\n            throw new IllegalStateException(\"Invalid type: \" + type);\n        }\n        ClassInfo injectedClazz = index.getClassByName(type.name());\n        if (injectedClazz == null) {\n            throw new IllegalStateException(\"Injected class not found in index: \" + type.name());\n        }\n        if (!injectedClazz.isInterface()\n                && !injectedClazz.hasNoArgsConstructor()) {\n            throw new IllegalStateException(\n                    \"@CachedResults class must be an interface or declare a no-args constructor: \" + injectedClazz);\n        }\n        return new CachedResultsInjectConfig(cacheName, lockTimeout, keyGenerator, injectedClazz,\n                // consider all but @CachedResults and @Inject\n                annotation.target().declaredAnnotations().stream().filter(\n                        a -> !a.name().equals(CACHED_RESULTS)","sourceCodeStart":326,"sourceCodeEnd":362,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/CachedResultsProcessor.java#L326-L362","documentation":"During Quarkus build, the cache extension processes every @CachedResults annotation. @CachedResults is only allowed on an injection field or an injection method parameter; any other annotation target (e.g. a class, method, or type-use) is rejected. This is a build-time deployment error, not a runtime failure.","triggerScenarios":"Placing @CachedResults on a target other than a FIELD or METHOD_PARAMETER — e.g. annotating the class itself, a business method, or a local variable while the deployment step walks injection points and calls createConfig.","commonSituations":"Developers copying @Inject-style annotation placement assumptions, annotating a constructor or setter instead of a field, or IDE quick-fixes moving the annotation to the wrong element.","solutions":["Move @CachedResults onto the injected field: `@Inject @CachedResults MyInterface result;`","If injected via constructor/setter, put it on the parameter: `public MyClass(@CachedResults MyInterface r) {...}`","Never place @CachedResults on a class, plain (non-injection) method, or local variable."],"exampleFix":"// before\n@CachedResults\npublic class MyService { ... }\n\n// after\npublic class MyService {\n    @Inject\n    @CachedResults(cacheName = \"my-cache\")\n    MyResultInterface result;\n}","handlingStrategy":"validation","validationCode":"// Build-time check: only fields or method parameters of an injected point may carry @CachedResults\n// In application code, simply never place @CachedResults elsewhere; verify usage:\n// grep -rn --include='*.java' -B2 '@CachedResults' src/main/java | grep -E 'class |void |static '","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only apply @CachedResults next to @Inject (field or injection parameter)","Let the IDE show the annotation's @Target and respect it","Review annotation placement during code review for cache annotations"],"tags":["quarkus","cache","build-time","annotation-target"],"backgroundTag":"invalid-annotation-target","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"}