quarkusio/quarkus · error · DefinitionException

Type of injected Decorator<T> does not match the type of the

Error message

Type of injected Decorator<T> does not match the type of the bean declaring the injection point. Problematic injection point: ${injectionPointInfo.getTargetInfo()}

What it means

When Decorator<T> is injected with qualifier @Default, the CDI spec requires T to match the type of the bean declaring the injection point (the decorator itself). ArC compares the declaring class with T and throws this DefinitionException when they differ.

Source

Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/Injection.java:190

        if (beanType == BeanType.DECORATOR) {
            // the injection point is a field, an initializer method parameter or a bean constructor, with qualifier
            // @Default, then the type parameter of the injected Decorator must be the same as the type
            // declaring the injection point
            if (injectionPointInfo.getRequiredType().name().equals(DotNames.DECORATOR)
                    && injectionPointInfo.getRequiredType().kind() == Type.Kind.PARAMETERIZED_TYPE
                    && injectionPointInfo.getRequiredType().asParameterizedType().arguments().size() == 1) {
                Type actualType = injectionPointInfo.getRequiredType().asParameterizedType().arguments().get(0);
                AnnotationTarget ipTarget = injectionPointInfo.getAnnotationTarget();
                DotName expectedType = null;
                if (ipTarget.kind() == Kind.FIELD) {
                    expectedType = ipTarget.asField().declaringClass().name();
                } else if (ipTarget.kind() == Kind.METHOD_PARAMETER) {
                    expectedType = ipTarget.asMethodParameter().method().declaringClass().name();
                }
                if (expectedType != null
                        // This is very rudimentary check, might need to be expanded?
                        && !expectedType.equals(actualType.name())) {
                    throw new DefinitionException(
                            "Type of injected Decorator<T> does not match the type of the bean declaring the " +
                                    "injection point. Problematic injection point: " + injectionPointInfo.getTargetInfo());
                }
            }

            // the injection point is a field, an initializer method parameter or a bean constructor of a decorator,
            // with qualifier @Decorated, then the type parameter of the injected Bean must be the same as the delegate type
            //
            // a validation for the specification text above would naturally belong here, but we don't have
            // access to the delegate type yet, so this is postponed to `Beans.validateInterceptorDecorator()`
        }
    }

    private static void validateInjections(List<Injection> injections, BeanType beanType) {
        for (Injection injection : injections) {
            for (InjectionPointInfo ipi : injection.injectionPoints) {
                validateInjections(ipi, beanType);
            }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Change the type parameter to the exact type of the decorator declaring the injection point
  2. Use Decorator<?> with unbound wildcard if typed form is not required
  3. Remove the injection point if unused

Example fix

// before
@Decorator class MyDecorator { @Inject Decorator<Other> meta; }
// after
@Decorator class MyDecorator { @Inject Decorator<MyDecorator> meta; }
Defensive patterns

Strategy: validation

Validate before calling

Field f = MyDecorator.class.getDeclaredField("meta");
if (f.getGenericType().getTypeName().contains("Decorator<") && !f.getGenericType().getTypeName().endsWith("<MyDecorator>"))
    throw new IllegalStateException("Decorator<T> must match the declaring decorator type");

Prevention

When it happens

Trigger: Injecting Decorator<SomeOtherType> into a decorator whose own type differs, e.g. class MyDecorator { @Inject Decorator<Other> other; }.

Common situations: Copying interceptor metadata snippets into decorators; using a supertype instead of the decorator's own type.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/f90741c905d4a8d5. Report an issue: GitHub.