Skip to content

Commit

Permalink
Only look for a provider() method if service provider class is in an …
Browse files Browse the repository at this point in the history
…explicit module.
  • Loading branch information
woess committed Apr 25, 2024
1 parent 5922877 commit 23f22dc
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,18 @@ void handleServiceClassIsReachable(DuringAnalysisAccess access, Class<?> service
Constructor<?> nullaryConstructor = null;
Method nullaryProviderMethod = null;
try {
for (Method method : providerClass.getDeclaredMethods()) {
if (Modifier.isPublic(method.getModifiers()) && Modifier.isStatic(method.getModifiers()) &&
method.getParameterCount() == 0 && method.getName().equals("provider")) {
if (nullaryProviderMethod == null) {
nullaryProviderMethod = method;
} else {
/* There must be at most one public static provider() method. */
nullaryProviderMethod = null;
break;
/* Only look for a provider() method if provider class is in an explicit module. */
if (providerClass.getModule().isNamed() && !providerClass.getModule().getDescriptor().isAutomatic()) {
for (Method method : providerClass.getDeclaredMethods()) {
if (Modifier.isPublic(method.getModifiers()) && Modifier.isStatic(method.getModifiers()) &&
method.getParameterCount() == 0 && method.getName().equals("provider")) {
if (nullaryProviderMethod == null) {
nullaryProviderMethod = method;
} else {
/* There must be at most one public static provider() method. */
nullaryProviderMethod = null;
break;
}
}
}
}
Expand Down

0 comments on commit 23f22dc

Please sign in to comment.