quarkusio/quarkus · error · IllegalStateException

Global variable method declared on " + method.declaringClass

Error message

Global variable method declared on " + method.declaringClass().name() + " must not be private: " + method

What it means

IllegalStateException from TemplateGlobalGenerator.validate(MethodInfo): the @TemplateGlobal method is private. The generated bytecode must be able to invoke it, so private accessors are rejected at build time; the declaring class and method are named in the message.

Source

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

        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())) {
            throw new IllegalStateException("Global variable field declared on " + field.declaringClass().name()
                    + " must not be private: " + field);
        }
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Make the @TemplateGlobal method at least package-private (public is typical)
  2. Move it to the globals class where it can be non-private
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at independent-projects/qute/generator/src/main/java/io/quarkus/qute/generator/TemplateGlobalGenerator.java:176 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/023f6be0cd254353. Report an issue: GitHub.