{"record":{"id":"19248a0320fd81f5","repo":"quarkusio/quarkus","slug":"invalid-type","errorCode":null,"errorMessage":"Invalid type: ","messagePattern":"Invalid type: ","errorType":"error_code","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/CachedResultsProcessor.java","lineNumber":348,"sourceCode":"\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)\n                                && !a.name().equals(INJECT))\n                        .toList(),\n                exclude);\n    }","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/cache/deployment/src/main/java/io/quarkus/cache/deployment/CachedResultsProcessor.java#L330-L366","documentation":"The @CachedResults annotation target resolved to a Jandex Type whose kind is not CLASS (e.g. parameterized type, array, primitive, type variable). The generated cache-result producer needs a concrete class/interface name to index, so non-class types are rejected at build time.","triggerScenarios":"Annotating an injection point whose declared type is generic (e.g. `List<String>`), an array, a primitive wrapper resolved oddly, or a type variable rather than a plain class/interface type.","commonSituations":"Injecting `@CachedResults SomeGeneric<T>`, injecting an array type, or Kotlin/other-language generated signatures producing PARAMETERIZED_TYPE instead of CLASS.","solutions":["Declare the injected field/parameter with a raw class or interface type (no generics, no arrays).","If you need a parameterized type, introduce a dedicated non-generic interface/class and inject that.","Check for compiler/Lombok/annotation-processor artifacts altering the declared type signature."],"exampleFix":"// before\n@Inject @CachedResults\nList<CachedResult> results;\n\n// after\n@Inject @CachedResults\nCachedResultList results; // plain interface/class type","handlingStrategy":"validation","validationCode":"// Ensure the annotated injection point declares a raw class/interface type\nField f = MyClass.class.getDeclaredField(\"result\");\nif (f.getGenericType() instanceof ParameterizedType || f.getType().isArray()) {\n    throw new IllegalStateException(\"@CachedResults target must be a plain class/interface type\");\n}","typeGuard":"static boolean isPlainClassType(java.lang.reflect.Field f) {\n    return !f.getGenericType().toString().contains(\"<\") && !f.getType().isArray();\n}","tryCatchPattern":null,"preventionTips":["Avoid generic or array types on @CachedResults injection points","Create a dedicated non-generic interface for cached results","Compile early — this fails at build time, before deployment"],"tags":["quarkus","cache","build-time","generics","jandex"],"backgroundTag":"invalid-injection-type","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"}