quarkusio/quarkus · error · IllegalStateException
Global variable method declared on " + method.declaringClass
Error message
Global variable method declared on " + method.declaringClass().name() + " must not return void: " + method
What it means
IllegalStateException from TemplateGlobalGenerator.validate(MethodInfo): the @TemplateGlobal method is declared void. A global variable must yield a value, so the generator rejects void return types; the declaring class and method are included in the message.
Source
Thrown at independent-projects/qute/generator/src/main/java/io/quarkus/qute/generator/TemplateGlobalGenerator.java:168
bc.return_(bc.invokeStatic(Descriptors.RESULTS_NOT_FOUND_EC, evalContext));
});
});
});
return generatedClassName;
}
public Set<String> getGeneratedTypes() {
return generatedTypes;
}
public static void validate(MethodInfo method) {
if (!Modifier.isStatic(method.flags())) {
throw new IllegalStateException(
"Global variable method declared on " + method.declaringClass().name() + " must be static: "
+ method);
}
if (method.returnType().kind() == Kind.VOID) {
throw new IllegalStateException("Global variable method declared on " + method.declaringClass().name()
+ " must not return void: " + method);
}
if (!method.parameterTypes().isEmpty()) {
throw new IllegalStateException("Global variable method declared on " + method.declaringClass().name()
+ " must not accept any parameter: " + method);
}
if (Modifier.isPrivate(method.flags())) {
throw new IllegalStateException("Global variable method declared on " + method.declaringClass().name()
+ " must not be private: " + method);
}
}
public static void validate(FieldInfo field) {
if (!Modifier.isStatic(field.flags())) {
throw new IllegalStateException(
"Global variable field declared on " + field.declaringClass().name() + " must be static: " + field);
}
if (Modifier.isPrivate(field.flags())) {View on GitHub (pinned to e1c734241f)
Solutions
- Change the method's return type to the type of the global value
- Or remove @TemplateGlobal from the void method
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at independent-projects/qute/generator/src/main/java/io/quarkus/qute/generator/TemplateGlobalGenerator.java:168 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/2758f522521be94c.
Report an issue: GitHub.