gnodet commented on code in PR #13570:
URL: https://github.com/apache/maven/pull/13570#discussion_r4335577452
##########
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:
`public` is intentional now that commit 377932b extends the classloader
filter to `DefaultTypeRegistry` and `DefaultLifecycleRegistry` (both in
`org.apache.maven.internal.impl`, a different package). Package-private access
would break the cross-package call. The method is internal-only but visible
across modules in the same JDK module, so the `public` modifier does not widen
the effective API surface beyond what already exists.
--
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]