quarkusio/quarkus · error · IllegalStateException

Unknown type '${type}' used as an annotation in constructor

Error message

Unknown type '${type}' used as an annotation in constructor of class '${resourceDotName}'

What it means

During bytecode generation of the custom producer's constructor, each parameter kind (QUERY, PATH, MATRIX, COOKIE) is mapped to the corresponding request-reading virtual method. If a CtorParamData carries a CustomProducerParameterType outside that set, generation fails with this IllegalStateException. It is a defensive branch that normal user code cannot reach: it only fires if the annotation-to-type mapping and the bytecode switch drift apart.

Source

Thrown at extensions/resteasy-reactive/rest/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/CustomResourceProducersGenerator.java:315

                            resultHandle = m.getMethodParam(otherParamIndex);
                            otherParamIndex++;
                        } else if (type == CtorParamData.CustomProducerParameterType.HEADER) {
                            resultHandle = m.invokeVirtualMethod(getHeaderParamMethodCreator.getMethodDescriptor(), m.getThis(),
                                    m.load(ctorParamDatum.getAnnotationValue()));
                        } else if (type == CtorParamData.CustomProducerParameterType.QUERY) {
                            resultHandle = m.invokeVirtualMethod(getQueryParamMethodCreator.getMethodDescriptor(), m.getThis(),
                                    m.load(ctorParamDatum.getAnnotationValue()));
                        } else if (type == CtorParamData.CustomProducerParameterType.PATH) {
                            resultHandle = m.invokeVirtualMethod(getPathParamMethodCreator.getMethodDescriptor(), m.getThis(),
                                    m.load(0)); // TODO: this is not correct, we really need to look up the index
                        } else if (type == CtorParamData.CustomProducerParameterType.MATRIX) {
                            resultHandle = m.invokeVirtualMethod(getMatrixParamMethodCreator.getMethodDescriptor(), m.getThis(),
                                    m.load(ctorParamDatum.getAnnotationValue()));
                        } else if (type == CtorParamData.CustomProducerParameterType.COOKIE) {
                            resultHandle = m.invokeVirtualMethod(getCookieParamMethodCreator.getMethodDescriptor(), m.getThis(),
                                    m.load(ctorParamDatum.getAnnotationValue()));
                        } else {
                            throw new IllegalStateException("Unknown type '" + type
                                    + "' used as an annotation in constructor of class '" + resourceDotName + "'");
                        }
                        ctorParamHandles.add(resultHandle);
                    }

                    // FIXME: this doesn't actually support injection in the resource instance
                    m.returnValue(m.newInstance(ctor, ctorParamHandles.toArray(new ResultHandle[0])));
                }
            }
            // FIXME: support constructors for bean params too
            additionalBeanBuildItemBuildProducer
                    .produce(AdditionalBeanBuildItem.builder()
                            .addBeanClasses(parameterContainersThatNeedCustomProducer.stream().map(DotName::toString).toList())
                            // FIXME: we should add this, but for that we also need to make the resource class request-scoped
                            //                                                         .setDefaultScope(DOTNAME_REQUEST_SCOPED)
                            //                                                         .setUnremovable()
                            .build());
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Verify the exact Quarkus version and file an upstream Quarkus issue with the resource class signature and full stack trace
  2. If patching the extension, add the missing branch in the type switch of the generated-constructor bytecode section
  3. As a workaround, switch the resource to field/method parameter injection instead of constructor injection
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Only reachable if a new CustomProducerParameterType is introduced in the annotation-mapping phase (e.g. support for a new JAX-RS parameter annotation) without extending the bytecode-generation switch, or via internal misuse of CtorParamData. Not reachable from user REST code under normal circumstances.

Common situations: Custom/patched Quarkus builds, adding framework-level support for a new parameter annotation, or other code constructing CtorParamData with a hand-rolled type.

Related errors


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