{"record":{"id":"0596b066a6fe152c","repo":"quarkusio/quarkus","slug":"method-info-name-of-class-info-declaringc-0596b0","errorCode":null,"errorMessage":"Method '${info.name()} of class '${info.declaringClass().name()}' cannot be private as it is annotated with '@${annotationDotName}'","messagePattern":"Method '(.+?) of class '(.+?)' cannot be private 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":707,"sourceCode":"        AssignableResultHandle resourceInfo = filterMethod.createVariable(SimpleResourceInfo.class);\n        BranchResult ifNullBranch = filterMethod.ifNull(runtimeResourceHandle);\n        ifNullBranch.trueBranch().assign(resourceInfo, ifNullBranch.trueBranch().readStaticField(\n                FieldDescriptor.of(SimpleResourceInfo.NullValues.class, \"INSTANCE\", SimpleResourceInfo.NullValues.class)));\n        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;","sourceCodeStart":689,"sourceCodeEnd":725,"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#L689-L725","documentation":"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.","triggerScenarios":"Declaring a method annotated with a filter annotation as `private` (e.g. `private void myFilter(ContainerRequestContext ctx) {}`) and building the Quarkus application.","commonSituations":"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.","solutions":["Change the filter method visibility to at least package-private (public preferred).","Remove the filter annotation if the method is only a helper.","Rebuild; the failure is at augmentation time so no runtime change is needed."],"exampleFix":"// before\nprivate void logFilter(ContainerRequestContext ctx) { ... }\n// after\npublic void logFilter(ContainerRequestContext ctx) { ... }","handlingStrategy":"validation","validationCode":"import java.lang.reflect.Method;\nimport java.lang.reflect.Modifier;\n\nvoid validateFilterVisibility(Class<?> filterClass) {\n    for (Method m : filterClass.getDeclaredMethods()) {\n        for (var a : m.getAnnotations()) {\n            String n = a.annotationType().getName();\n            if (n.endsWith(\"ServerRequestFilter\") || n.endsWith(\"ServerResponseFilter\")) {\n                if (Modifier.isPrivate(m.getModifiers()))\n                    throw new IllegalStateException(\"Filter method must not be private: \" + m);\n            }\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never declare filter methods private; use public or package-private.","Keep filter annotations only on handler methods, not helpers.","Add an ArchUnit/test rule scanning annotated filter methods for private/static modifiers.","Review visibility whenever refactoring classes containing filters."],"tags":["quarkus","resteasy-reactive","build-time","filters","visibility"],"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-14T00:17:10.932Z"}