gnodet-bot commented on code in PR #13570:
URL: https://github.com/apache/maven/pull/13570#discussion_r4325658359


##########
impl/maven-impl/src/main/java/org/apache/maven/impl/ExtensibleEnumRegistries.java:
##########
@@ -46,6 +49,66 @@
 
 public class ExtensibleEnumRegistries {
 
+    private static final ClassValue<Optional<Method>> GET_IMPORT_REALMS = new 
ClassValue<>() {
+        @Override
+        protected Optional<Method> computeValue(Class<?> type) {
+            try {
+                return Optional.of(type.getMethod("getImportRealms"));
+            } catch (NoSuchMethodException | SecurityException e) {
+                return Optional.empty();
+            }
+        }
+    };
+
+    /**
+     * Checks whether a provider is visible from the given classloader.
+     * Providers from project extensions are loaded by extension-specific 
classloaders
+     * (realms) that are only imported into the project realm that declared 
the extension.
+     * This prevents extension-scoped providers from leaking across reactor 
modules
+     * during parallel builds.
+     *
+     * @param provider the SPI provider to check
+     * @param classLoader the classloader to check visibility from (typically 
the TCCL)
+     * @return {@code true} if the provider is visible, {@code false} otherwise
+     */
+    public static boolean isVisibleFrom(Object provider, ClassLoader 
classLoader) {

Review Comment:
   💡 **Unnecessary `public` visibility** — `isVisibleFrom()` is only called 
from `DefaultExtensibleEnumRegistry.lookup()` within the same package. The test 
class is also in `org.apache.maven.impl`, so package-private access is 
sufficient. Declaring this `public` widens the API surface of a non-API 
implementation class unnecessarily.
   
   ```suggestion
       static boolean isVisibleFrom(Object provider, ClassLoader classLoader) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to