{"record":{"id":"9cf5ae155e88088a","repo":"quarkusio/quarkus","slug":"type-of-injected-interceptor-t-does-not-match-the","errorCode":null,"errorMessage":"Type of injected Interceptor<T> does not match the type of the bean declaring the injection point. Problematic injection point: ${injectionPointInfo.getTargetInfo()}","messagePattern":"Type of injected Interceptor<T> does not match the type of the bean declaring the injection point\\. Problematic injection point: (.+?)","errorType":"exception","errorClass":"DefinitionException","httpStatus":null,"severity":"error","filePath":"independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Injection.java","lineNumber":166,"sourceCode":"            }\n            // the injection point is a field, an initializer method parameter or a bean constructor, with qualifier\n            // @Default, then the type parameter of the injected Bean, or Interceptor must be the same as the type\n            // declaring the injection point\n            if (injectionPointInfo.getRequiredType().name().equals(DotNames.INTERCEPTOR_BEAN)\n                    && injectionPointInfo.getRequiredType().kind() == Type.Kind.PARAMETERIZED_TYPE\n                    && injectionPointInfo.getRequiredType().asParameterizedType().arguments().size() == 1) {\n                Type actualType = injectionPointInfo.getRequiredType().asParameterizedType().arguments().get(0);\n                AnnotationTarget ipTarget = injectionPointInfo.getAnnotationTarget();\n                DotName expectedType = null;\n                if (ipTarget.kind() == Kind.FIELD) {\n                    expectedType = ipTarget.asField().declaringClass().name();\n                } else if (ipTarget.kind() == Kind.METHOD_PARAMETER) {\n                    expectedType = ipTarget.asMethodParameter().method().declaringClass().name();\n                }\n                if (expectedType != null\n                        // This is very rudimentary check, might need to be expanded?\n                        && !expectedType.equals(actualType.name())) {\n                    throw new DefinitionException(\n                            \"Type of injected Interceptor<T> does not match the type of the bean declaring the \" +\n                                    \"injection point. Problematic injection point: \" + injectionPointInfo.getTargetInfo());\n                }\n            }\n        }\n        if (beanType == BeanType.DECORATOR) {\n            // the injection point is a field, an initializer method parameter or a bean constructor, with qualifier\n            // @Default, then the type parameter of the injected Decorator must be the same as the type\n            // declaring the injection point\n            if (injectionPointInfo.getRequiredType().name().equals(DotNames.DECORATOR)\n                    && injectionPointInfo.getRequiredType().kind() == Type.Kind.PARAMETERIZED_TYPE\n                    && injectionPointInfo.getRequiredType().asParameterizedType().arguments().size() == 1) {\n                Type actualType = injectionPointInfo.getRequiredType().asParameterizedType().arguments().get(0);\n                AnnotationTarget ipTarget = injectionPointInfo.getAnnotationTarget();\n                DotName expectedType = null;\n                if (ipTarget.kind() == Kind.FIELD) {\n                    expectedType = ipTarget.asField().declaringClass().name();\n                } else if (ipTarget.kind() == Kind.METHOD_PARAMETER) {","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Injection.java#L148-L184","documentation":"When Interceptor<T> is injected with qualifier @Default, the CDI spec requires T to match the type of the bean declaring the injection point (i.e., the interceptor itself). ArC compares the injection point's declaring class to T and throws this DefinitionException when they differ.","triggerScenarios":"Injecting Interceptor<SomeOtherType> into an interceptor (or decorator) whose own type differs, e.g. class MyInterceptor { @Inject Interceptor<Other> other; }.","commonSituations":"Copying Bean<T> metadata examples into interceptor classes with the wrong type parameter; using a base/interface type instead of the interceptor's own type.","solutions":["Set the type parameter to the exact type of the interceptor class declaring the injection point","Use Interceptor<?> with unbound wildcard if you don't need the typed form (verify the qualifier rules)","Remove the injection if the metadata is unused"],"exampleFix":"// before\nclass MyInterceptor { @Inject Interceptor<OtherBean> meta; }\n// after\nclass MyInterceptor { @Inject Interceptor<MyInterceptor> meta; }","handlingStrategy":"validation","validationCode":"Field f = MyInterceptor.class.getDeclaredField(\"meta\");\nif (f.getGenericType().getTypeName().contains(\"Interceptor<\") && !f.getGenericType().getTypeName().endsWith(\"<MyInterceptor>\"))\n    throw new IllegalStateException(\"Interceptor<T> must match the declaring interceptor type\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Type parameter of Interceptor<T> must equal the interceptor's own class","Keep a canonical self-metadata pattern per interceptor","Run builds frequently; ArC validates at build time"],"tags":["cdi","arc","interceptor","bean-metadata","generics","build-time"],"backgroundTag":"cdi-bean-metadata-type-mismatch","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"}