quarkusio/quarkus · error

Multiple extension methods match 0 params and the names %s:

Error message

Multiple extension methods match 0 params and the names %s: %s. Specify priorities to avoid this problem.

What it means

Same ambiguity as the single-name variant, but for a method matching multiple names (@TemplateExtension(matchNames = {...}) or ANY). When resolved with zero arguments, the generated resolver requires exactly one candidate method; multiple matches with equal priority trigger this IllegalStateException.

Source

Thrown at independent-projects/qute/generator/src/main/java/io/quarkus/qute/generator/ExtensionMethodGenerator.java:392

                            bc.block(nested -> {
                                // Test that any of the names matches
                                nested.block(nested2 -> {
                                    for (String matchName : matchNames.stream().sorted().toList()) {
                                        nested2.if_(nested2.exprEquals(name, Const.of(matchName)),
                                                namesMatch -> namesMatch.break_(nested2));
                                    }
                                    nested2.break_(nested);
                                });
                                // Test number of evaluated params
                                nested.if_(nested.ne(paramsCount, Const.of(numberOfParams)),
                                        notEqual -> notEqual.break_(nested));

                                List<NamespaceExtensionMethodInfo> methods = mne.getValue();
                                if (numberOfParams == 0) {
                                    // No params -> there must be exactly one extension method
                                    if (methods.size() > 1) {
                                        throw new IllegalStateException(
                                                "Multiple extension methods match 0 params and the names %s: %s. Specify priorities to avoid this problem."
                                                        .formatted(matchNames, methods));
                                    }
                                    nested.return_(doInvokeNoParams(nested, name, evalContext, methods.get(0)));
                                } else {
                                    evaluateAndInvoke(nested, evalContext, name, methods);
                                }
                            });
                        }

                        // Next handle all matchRegex methods
                        for (NamespaceExtensionMethodInfo em : extensionMethodForParams) {
                            if (em.matchesRegex()) {
                                bc.block(nested -> {
                                    // Test regexp
                                    FieldDesc patternField = FieldDesc.of(cc.type(),
                                            PATTERN + "_" + sha1(em.method().toString()), Pattern.class);
                                    Expr pattern = cc.this_().field(patternField);

View on GitHub (pinned to e1c734241f)

Solutions

  1. Give one method a higher priority via @TemplateExtension(priority = N)
  2. Narrow the matchNames/matchRegex of one method so they no longer overlap
  3. Remove the duplicate or catch-all method

Example fix

// before
@TemplateExtension(namespace = "cfg", matchNames = {"a", "b"})
static String get(String name) { ... }
@TemplateExtension(namespace = "cfg", matchNames = {"b", "c"})
static String get2(String name) { ... }
// after
@TemplateExtension(namespace = "cfg", matchNames = {"a", "b"}, priority = 5)
static String get(String name) { ... }
Defensive patterns

Strategy: validation

Validate before calling

// Ensure multi-name extensions don't overlap and have distinct priorities:
assert distinctPriorities(multiNameExtensions) : "Multiple 0-param matches for the same names";

Prevention

When it happens

Trigger: Two extension methods in the same namespace both declaring matchNames/ANY matching the same name, both invocable with zero params and equal priority; raised in generateNamespaceResolver.

Common situations: A catch-all ANY method colliding with a specific matchNames method in the same namespace; registering the same extension class twice; two libraries each contributing a multi-name namespace extension.

Related errors


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