gradle/gradle · error · IllegalArgumentException
Method %s is not public.
Error message
Method %s is not public.
What it means
Gradle throws this error when the following condition is violated: Method <value> is not public.
Source
Thrown at platforms/core-configuration/model-core/src/main/java/org/gradle/internal/instantiation/managed/DefaultManagedObjectRegistry.java:269
private static final MethodHandles.Lookup LOOKUP = MethodHandles.publicLookup();
private final ConcurrentMap<Method, MethodHandle> unreflectionCache = new ConcurrentHashMap<>();
private final ConcurrentMap<GetMethodKey, Method> findMethodCache = new ConcurrentHashMap<>();
/**
* Unreflect the given method, caching the result.
*
* @throws IllegalArgumentException if the method is not public or its declaring class is not public.
*/
public MethodHandle unreflect(Method method) {
MethodHandle cached = unreflectionCache.get(method);
if (cached != null) {
return cached;
}
if (!Modifier.isPublic(method.getModifiers())) {
throw new IllegalArgumentException("Method " + method + " is not public.");
} else if (!Modifier.isPublic(method.getDeclaringClass().getModifiers())) {
throw new IllegalArgumentException("Declaring class '" + method.getDeclaringClass().getName() + "' of method " + method + " is not public.");
}
return unreflectionCache.computeIfAbsent(method, m -> {
try {
MethodHandle handle = LOOKUP.unreflect(m);
return handle.asType(MethodType.methodType(Object.class, handle.type().parameterArray())); // Allows invokeExact
} catch (IllegalAccessException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
});
}
/**
* Get the method in the given class with the given signature.
*
* @throws RuntimeException if the method cannot be found.View on GitHub (pinned to 534f27719b)
Solutions
- Review the values passed to this API and correct the invalid input described in the error message.
When it happens
Trigger: 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.
Common situations: See trigger scenarios.
AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22).
Data as JSON: /api/errors/c430691f1a0085c5.
Report an issue: GitHub.