quarkusio/quarkus · error · DefinitionException

More than 1 parameter of type ClassInfo, MethodInfo, FieldIn

Error message

More than 1 parameter of type ClassInfo, MethodInfo, FieldInfo, ClassConfig, MethodConfig, or FieldConfig for method " + method

What it means

A build-time @Enhancement extension method must target exactly one thing, identified by a single query parameter (ClassInfo, MethodInfo, FieldInfo, ClassConfig, MethodConfig, or FieldConfig). ExtensionPhaseEnhancement.runExtensionMethod() throws DefinitionException when it finds more than one such parameter, since the processor cannot decide which one selects the enhancement target.

Source

Thrown at independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/ExtensionPhaseEnhancement.java:46

        List<ExtensionMethodParameter> parameters = new ArrayList<>(method.parametersCount());
        for (org.jboss.jandex.Type parameterType : method.parameterTypes()) {
            ExtensionMethodParameter parameter = ExtensionMethodParameter.of(parameterType);
            parameters.add(parameter);

            if (parameter.isQuery()) {
                numQueryParameters++;
            }

            parameter.verifyAvailable(ExtensionPhase.ENHANCEMENT, method);
        }

        if (numQueryParameters == 0) {
            throw new DefinitionException("No parameter of type ClassInfo, MethodInfo, FieldInfo, "
                    + "ClassConfig, MethodConfig, or FieldConfig for method " + method);
        }

        if (numQueryParameters > 1) {
            throw new DefinitionException("More than 1 parameter of type ClassInfo, MethodInfo, FieldInfo, "
                    + "ClassConfig, MethodConfig, or FieldConfig for method " + method);
        }

        ExtensionMethodParameter query = parameters.stream()
                .filter(ExtensionMethodParameter::isQuery)
                .findAny()
                .get(); // guaranteed to be there

        List<org.jboss.jandex.ClassInfo> matchingClasses = matchingClasses(method.jandex);
        List<?> allValuesForQueryParameter;
        if (query == ExtensionMethodParameter.CLASS_INFO) {
            allValuesForQueryParameter = matchingClasses.stream()
                    .map(it -> new ClassInfoImpl(index, annotationOverlay, it))
                    .toList();
        } else if (query == ExtensionMethodParameter.METHOD_INFO) {
            allValuesForQueryParameter = matchingClasses.stream()
                    .map(it -> new ClassInfoImpl(index, annotationOverlay, it))
                    .flatMap(it -> Stream.concat(it.constructors().stream(), it.methods().stream()))

View on GitHub (pinned to e1c734241f)

Solutions

  1. Keep exactly one query parameter; drop the extra one.
  2. If you need both the class and a member, use a single MethodInfo/FieldInfo parameter and navigate to its declaring ClassInfo from the metadata.
  3. Split into two separate @Enhancement methods, one per target.

Example fix

// before
@Enhancement
void enhance(ClassConfig clazz, MethodConfig method) { ... }

// after
@Enhancement
void enhance(MethodConfig method) {
    ClassConfig clazz = method.declaringClass();
}
Defensive patterns

Strategy: validation

Validate before calling

long queries = Arrays.stream(method.getParameters())
    .map(p -> p.type().name().withoutPackagePrefix())
    .filter(n -> Set.of("ClassInfo","MethodInfo","FieldInfo","ClassConfig","MethodConfig","FieldConfig").contains(n))
    .count();
if (queries > 1) throw new IllegalStateException("@Enhancement method must have exactly one query parameter");

Type guard

static boolean isSingleQueryMethod(MethodInfo m) {
    return Arrays.stream(m.parameters()).filter(ExtensionPhaseEnhancement::isQueryType).count() == 1;
}

Try / catch

try {
    processor.run(extensionClass);
} catch (DefinitionException e) {
    fail("Too many query parameters: " + e.getMessage());
}

Prevention

When it happens

Trigger: Declaring an @Enhancement method with two or more parameters of the six query types (e.g. both ClassInfo and MethodInfo, or ClassConfig and MethodConfig), making numQueryParameters > 1 during processing.

Common situations: Combining a class-level and member-level enhancement in one method expecting them to be filled together; adding an extra info parameter 'for convenience' to also see the declaring class; copy-pasting signatures from different extension methods.

Related errors


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