quarkusio/quarkus · error · RuntimeException

Method '${info.name()} of class '${info.declaringClass().nam

Error message

Method '${info.name()} of class '${info.declaringClass().name()}' cannot be private as it is annotated with '@${annotationDotName}'

What it means

During application augmentation RESTEasy Reactive generates a filter class for each method annotated with @ServerRequestFilter/@ServerResponseFilter (or a custom filter annotation). The generated dispatch code needs to invoke the method from a generated subclass, which is impossible for a private method, so CustomFilterGenerator.checkModifiers rejects private filter methods at build time.

Source

Thrown at independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/filters/CustomFilterGenerator.java:707

        AssignableResultHandle resourceInfo = filterMethod.createVariable(SimpleResourceInfo.class);
        BranchResult ifNullBranch = filterMethod.ifNull(runtimeResourceHandle);
        ifNullBranch.trueBranch().assign(resourceInfo, ifNullBranch.trueBranch().readStaticField(
                FieldDescriptor.of(SimpleResourceInfo.NullValues.class, "INSTANCE", SimpleResourceInfo.NullValues.class)));
        ifNullBranch.falseBranch().assign(resourceInfo, ifNullBranch.falseBranch().invokeVirtualMethod(
                MethodDescriptor.ofMethod(RuntimeResource.class, "getSimplifiedResourceInfo", SimpleResourceInfo.class),
                runtimeResourceHandle));
        return resourceInfo;
    }

    private String getGeneratedClassName(MethodInfo targetMethod, DotName annotationDotName) {
        DotName declaringClassName = targetMethod.declaringClass().name();
        return declaringClassName.toString() + "$Generated" + annotationDotName.withoutPackagePrefix() + "$"
                + targetMethod.name();
    }

    private void checkModifiers(MethodInfo info, DotName annotationDotName) {
        if ((info.flags() & Modifier.PRIVATE) != 0) {
            throw new RuntimeException("Method '" + info.name() + " of class '" + info.declaringClass().name()
                    + "' cannot be private as it is annotated with '@" + annotationDotName + "'");
        }
        if ((info.flags() & Modifier.STATIC) != 0) {
            throw new RuntimeException("Method '" + info.name() + " of class '" + info.declaringClass().name()
                    + "' cannot be static as it is annotated with '@" + annotationDotName + "'");
        }
    }

    private ReturnType determineRequestFilterReturnType(MethodInfo targetMethod) {
        if (targetMethod.returnType().kind() == Type.Kind.VOID) {
            return ReturnType.VOID;
        } else if (targetMethod.returnType().kind() == Type.Kind.PARAMETERIZED_TYPE) {
            ParameterizedType parameterizedType = targetMethod.returnType().asParameterizedType();
            if (parameterizedType.name().equals(UNI) && (parameterizedType.arguments().size() == 1)) {
                if (parameterizedType.arguments().get(0).name().equals(VOID)) {
                    return ReturnType.UNI_VOID;
                } else if (parameterizedType.arguments().get(0).name().equals(RESPONSE)) {
                    return ReturnType.UNI_RESPONSE;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Change the filter method visibility to at least package-private (public preferred).
  2. Remove the filter annotation if the method is only a helper.
  3. Rebuild; the failure is at augmentation time so no runtime change is needed.

Example fix

// before
private void logFilter(ContainerRequestContext ctx) { ... }
// after
public void logFilter(ContainerRequestContext ctx) { ... }
Defensive patterns

Strategy: validation

Validate before calling

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

void validateFilterVisibility(Class<?> filterClass) {
    for (Method m : filterClass.getDeclaredMethods()) {
        for (var a : m.getAnnotations()) {
            String n = a.annotationType().getName();
            if (n.endsWith("ServerRequestFilter") || n.endsWith("ServerResponseFilter")) {
                if (Modifier.isPrivate(m.getModifiers()))
                    throw new IllegalStateException("Filter method must not be private: " + m);
            }
        }
    }
}

Prevention

When it happens

Trigger: Declaring a method annotated with a filter annotation as `private` (e.g. `private void myFilter(ContainerRequestContext ctx) {}`) and building the Quarkus application.

Common situations: Refactoring a filter method to private during cleanup; IDE auto-generated helper methods that kept an annotation; copying a filter into a utility class and tightening visibility.

Related errors


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