{"record":{"id":"ec66cd3db5a3e772","repo":"quarkusio/quarkus","slug":"method-info-name-of-class-info-declaringc-ec66cd","errorCode":null,"errorMessage":"Method '${info.name()} of class '${info.declaringClass().name()}' cannot be static as it is annotated with '@${annotationDotName}'","messagePattern":"Method '(.+?) of class '(.+?)' cannot be static as it is annotated with '@(.+?)'","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/filters/CustomFilterGenerator.java","lineNumber":711,"sourceCode":"        ifNullBranch.falseBranch().assign(resourceInfo, ifNullBranch.falseBranch().invokeVirtualMethod(\n                MethodDescriptor.ofMethod(RuntimeResource.class, \"getSimplifiedResourceInfo\", SimpleResourceInfo.class),\n                runtimeResourceHandle));\n        return resourceInfo;\n    }\n\n    private String getGeneratedClassName(MethodInfo targetMethod, DotName annotationDotName) {\n        DotName declaringClassName = targetMethod.declaringClass().name();\n        return declaringClassName.toString() + \"$Generated\" + annotationDotName.withoutPackagePrefix() + \"$\"\n                + targetMethod.name();\n    }\n\n    private void checkModifiers(MethodInfo info, DotName annotationDotName) {\n        if ((info.flags() & Modifier.PRIVATE) != 0) {\n            throw new RuntimeException(\"Method '\" + info.name() + \" of class '\" + info.declaringClass().name()\n                    + \"' cannot be private as it is annotated with '@\" + annotationDotName + \"'\");\n        }\n        if ((info.flags() & Modifier.STATIC) != 0) {\n            throw new RuntimeException(\"Method '\" + info.name() + \" of class '\" + info.declaringClass().name()\n                    + \"' cannot be static as it is annotated with '@\" + annotationDotName + \"'\");\n        }\n    }\n\n    private ReturnType determineRequestFilterReturnType(MethodInfo targetMethod) {\n        if (targetMethod.returnType().kind() == Type.Kind.VOID) {\n            return ReturnType.VOID;\n        } else if (targetMethod.returnType().kind() == Type.Kind.PARAMETERIZED_TYPE) {\n            ParameterizedType parameterizedType = targetMethod.returnType().asParameterizedType();\n            if (parameterizedType.name().equals(UNI) && (parameterizedType.arguments().size() == 1)) {\n                if (parameterizedType.arguments().get(0).name().equals(VOID)) {\n                    return ReturnType.UNI_VOID;\n                } else if (parameterizedType.arguments().get(0).name().equals(RESPONSE)) {\n                    return ReturnType.UNI_RESPONSE;\n                } else if (parameterizedType.arguments().get(0).name().equals(REST_RESPONSE)) {\n                    return ReturnType.UNI_REST_RESPONSE;\n                }\n            } else if (parameterizedType.name().equals(OPTIONAL) && (parameterizedType.arguments().size() == 1)) {","sourceCodeStart":693,"sourceCodeEnd":729,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/server/processor/src/main/java/org/jboss/resteasy/reactive/server/processor/generation/filters/CustomFilterGenerator.java#L693-L729","documentation":"RESTEasy Reactive generates an instance-based filter class that invokes your annotated filter method; static methods cannot be dispatched that way. CustomFilterGenerator.checkModifiers inspects the MethodInfo flags and throws when a filter method is declared static.","triggerScenarios":"Annotating a `static` method with @ServerRequestFilter/@ServerResponseFilter (or a custom filter annotation) and building the application.","commonSituations":"Writing filters as static utility methods out of habit; moving a filter into a utility class and making it static while keeping the annotation.","solutions":["Remove the `static` modifier so the filter is an instance method.","If the logic must stay static, add a non-static method carrying the filter annotation that delegates to the static one.","Remove the filter annotation if the method is not meant to be a filter."],"exampleFix":"// before\npublic static void authFilter(ContainerRequestContext ctx) { ... }\n// after\npublic void authFilter(ContainerRequestContext ctx) { ... }","handlingStrategy":"validation","validationCode":"import java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\n\nvoid validateFilterNotStatic(Class<?> filterClass) {\n    for (Method m : filterClass.getDeclaredMethods()) {\n        if (java.util.Arrays.stream(m.getAnnotations()).anyMatch(\n                a -> a.annotationType().getName().endsWith(\"Filter\"))\n                && Modifier.isStatic(m.getModifiers())) {\n            throw new IllegalStateException(\"Filter method must not be static: \" + m);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filters must be instance methods — never static.","Do not move annotated filter methods into static utility classes.","Add an architecture test that flags static filter methods.","If delegation to a static utility is needed, keep the annotated wrapper non-static."],"tags":["quarkus","resteasy-reactive","build-time","filters","static"],"backgroundTag":"private-method-not-allowed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}