quarkusio/quarkus · error · IllegalStateException

Unsupported target: " + e.getValue()

Error message

Unsupported target: " + e.getValue()

What it means

@TemplateGlobal can only be applied to supported targets (fields and specific method kinds). When processing the annotated members, the generator switches on the annotation target kind and throws IllegalStateException for any kind it does not handle (e.g. an unexpected member type like CONSTRUCTOR or unsupported element).

Source

Thrown at independent-projects/qute/generator/src/main/java/io/quarkus/qute/generator/TemplateGlobalGenerator.java:143

                mc.body(bc -> {
                    Expr name = bc.invokeInterface(Descriptors.GET_NAME, evalContext);
                    bc.switch_(name, sc -> {
                        for (Entry<String, AnnotationTarget> e : targets.entrySet()) {
                            sc.caseOf(Const.of(e.getKey()), cbc -> {
                                switch (e.getValue().kind()) {
                                    case FIELD:
                                        FieldInfo field = e.getValue().asField();
                                        LocalVar val = cbc.localVar("val", cbc.getStaticField(fieldDescOf(field)));
                                        processReturnVal(cbc, field.type(), val, cc);
                                        break;
                                    case METHOD:
                                        MethodInfo method = e.getValue().asMethod();
                                        LocalVar val2 = cbc.localVar("val", cbc.invokeStatic(methodDescOf(method)));
                                        processReturnVal(cbc, method.returnType(), val2, cc);
                                        break;
                                    default:
                                        throw new IllegalStateException("Unsupported target: " + e.getValue());
                                }
                            });
                        }
                        sc.default_(dbc -> {
                        });
                    });
                    bc.return_(bc.invokeStatic(Descriptors.RESULTS_NOT_FOUND_EC, evalContext));
                });
            });
        });
        return generatedClassName;
    }

    public Set<String> getGeneratedTypes() {
        return generatedTypes;
    }

    public static void validate(MethodInfo method) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Ensure @TemplateGlobal is only on supported members: fields and no-arg methods with non-void returns
  2. Remove the annotation from the unsupported member
  3. Upgrade/patch Quarkus if a legitimate target kind is unsupported (file a Quarkus issue)

Example fix

// before
@TemplateGlobal
public MyGlobal() {}
// after
@TemplateGlobal
public static String globalName() { return "x"; }
Defensive patterns

Strategy: validation

Validate before calling

if (m.isAnnotationPresent(TemplateGlobal.class) && (m.getParameterCount() != 0 || m.getReturnType() == void.class))
    throw new IllegalStateException("@TemplateGlobal methods must be no-arg with non-void return");

Prevention

When it happens

Trigger: Placing @TemplateGlobal on a member type not supported by the generator, or an internal inconsistency in the Jandex annotation target map; raised in TemplateGlobalGenerator.generate during build.

Common situations: Annotating a constructor or static initializer by mistake; a library version where new target kinds exist but the generator hasn't been updated; custom annotation copying that mislabels targets.

Related errors


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