{"record":{"id":"5855bf8849accd7f","repo":"permissions-dispatcher/PermissionsDispatcher","slug":"method-e-simplestring-annotated-with","errorCode":null,"errorMessage":"Method '${e.simpleString()}()' annotated with '@${annotationType.simpleName}' must not be private","messagePattern":"Method '(.+?)\\(\\)' annotated with '@(.+?)' must not be private","errorType":"validation","errorClass":"PrivateMethodException","httpStatus":null,"severity":"error","filePath":"processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt","lineNumber":68,"sourceCode":" * <p>\n * Raises an exception if it doesn't contain any elements.\n */\nfun <A : Annotation> checkNotEmpty(items: List<ExecutableElement>, rpe: RuntimePermissionsElement, annotationClass: Class<A>) {\n    if (items.isEmpty()) {\n        throw NoAnnotatedMethodsException(rpe, annotationClass)\n    }\n}\n\n/**\n * Checks the elements in the provided list annotated with an annotation\n * against private modifiers.\n * <p>\n * Raises an exception if any element contains the \"private\" modifier.\n */\nfun <A : Annotation> checkPrivateMethods(items: List<ExecutableElement>, annotationClass: Class<A>) {\n    items.forEach {\n        if (it.modifiers.contains(Modifier.PRIVATE)) {\n            throw PrivateMethodException(it, annotationClass)\n        }\n    }\n}\n\n/**\n * Checks the return type of the elements in the provided list.\n * <p>\n * Raises an exception if any element specifies a return type other than 'void'.\n */\nfun checkMethodSignature(items: List<ExecutableElement>) {\n    items.forEach {\n        // Allow 'void' return type only\n        if (it.returnType.kind != TypeKind.VOID) {\n            throw WrongReturnTypeException(it)\n        }\n        // Allow methods without 'throws' declaration only\n        if (it.thrownTypes.isNotEmpty()) {\n            throw NoThrowsAllowedException(it)","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/permissions-dispatcher/PermissionsDispatcher/blob/74b532bf1fe430fb12ad8414b80399f2d7cfc954/processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt#L50-L86","documentation":"Thrown by checkPrivateMethods in Validators.kt:68. Methods annotated with permission annotations (@NeedsPermission, @OnPermissionDenied, etc.) must not be private, because the generated PermissionsDispatcher class needs to invoke them via generated delegate methods; a private method would be uncallable from the generated code.","triggerScenarios":"Declaring an annotated method with the private modifier in Kotlin or Java, e.g. private fun showCamera() with @NeedsPermission.","commonSituations":"Kotlin defaulting visibility habits; making a permission callback private after a refactor; IDE auto-completion suggesting a private helper annotated by mistake.","solutions":["Remove the private modifier so the method has at least internal/public visibility.","Use internal instead of private in Kotlin if you want module-level visibility."],"exampleFix":"// before\n@NeedsPermission(Manifest.permission.CAMERA)\nprivate fun showCamera() { }\n\n// after\n@NeedsPermission(Manifest.permission.CAMERA)\nfun showCamera() { }","handlingStrategy":"validation","validationCode":"@NeedsPermission(Manifest.permission.CAMERA)\nfun showCamera() { } // ensure no 'private' modifier","typeGuard":null,"tryCatchPattern":"try {\n    build()\n} catch (e: CompilationError) {\n    logger.error(\"Permission-annotated methods must not be private\", e)\n}","preventionTips":["Never mark annotated permission callbacks private.","Use internal/public visibility in Kotlin.","Code-review visibility changes on annotated methods."],"tags":["kotlin","annotation-processor","visibility"],"backgroundTag":"insufficient-permissions","analyzedSha":"74b532bf1fe430fb12ad8414b80399f2d7cfc954","analyzedAt":"2026-09-08T21:44:58.380Z","contentChangedAt":"2026-09-08T21:44:58.380Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}