{"record":{"id":"c430691f1a0085c5","repo":"gradle/gradle","slug":"method-s-is-not-public","errorCode":null,"errorMessage":"Method %s is not public.","messagePattern":"Method (.+?) is not public\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"platforms/core-configuration/model-core/src/main/java/org/gradle/internal/instantiation/managed/DefaultManagedObjectRegistry.java","lineNumber":269,"sourceCode":"\n        private static final MethodHandles.Lookup LOOKUP = MethodHandles.publicLookup();\n\n        private final ConcurrentMap<Method, MethodHandle> unreflectionCache = new ConcurrentHashMap<>();\n        private final ConcurrentMap<GetMethodKey, Method> findMethodCache = new ConcurrentHashMap<>();\n\n        /**\n         * Unreflect the given method, caching the result.\n         *\n         * @throws IllegalArgumentException if the method is not public or its declaring class is not public.\n         */\n        public MethodHandle unreflect(Method method) {\n            MethodHandle cached = unreflectionCache.get(method);\n            if (cached != null) {\n                return cached;\n            }\n\n            if (!Modifier.isPublic(method.getModifiers())) {\n                throw new IllegalArgumentException(\"Method \" + method + \" is not public.\");\n            } else if (!Modifier.isPublic(method.getDeclaringClass().getModifiers())) {\n                throw new IllegalArgumentException(\"Declaring class '\" + method.getDeclaringClass().getName() + \"' of method \" + method + \" is not public.\");\n            }\n\n            return unreflectionCache.computeIfAbsent(method, m -> {\n                try {\n                    MethodHandle handle = LOOKUP.unreflect(m);\n                    return handle.asType(MethodType.methodType(Object.class, handle.type().parameterArray())); // Allows invokeExact\n                } catch (IllegalAccessException e) {\n                    throw UncheckedException.throwAsUncheckedException(e);\n                }\n            });\n        }\n\n        /**\n         * Get the method in the given class with the given signature.\n         *\n         * @throws RuntimeException if the method cannot be found.","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/core-configuration/model-core/src/main/java/org/gradle/internal/instantiation/managed/DefaultManagedObjectRegistry.java#L251-L287","documentation":"Gradle throws this error when the following condition is violated: Method <value> is not public.","triggerScenarios":"Thrown at platforms/core-configuration/model-core/src/main/java/org/gradle/internal/instantiation/managed/DefaultManagedObjectRegistry.java:269 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Review the values passed to this API and correct the invalid input described in the error message."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}