gnodet commented on PR #13625:
URL: https://github.com/apache/maven/pull/13625#issuecomment-6264417046

   We've updated the classloader improvements tracking issue (#13223) to 
include a **Layer 0b — Public Realm API** that aligns with the direction of 
this PR but proposes a slightly different shape.
   
   The idea: instead of exposing `Plugin.getClassLoader()` and having 
`PluginManager.lookupList()` do manual TCCL swapping, introduce a `PluginRealm` 
concept that bundles a classloader with a scoped `Lookup`:
   
   ```java
   public interface PluginRealm {
       ClassLoader getClassLoader();
       Optional<ModuleLayer> getModuleLayer(); // for future JPMS ModuleLayer 
support
       Lookup getLookup(); // scoped to this realm's import chain
   }
   ```
   
   `Plugin.getRealm()` replaces `Plugin.getClassLoader()`, and callers do 
`plugin.getRealm().getLookup().lookupList(type)` — no manual 
`Thread.setContextClassLoader()` needed.
   
   Benefits:
   - **Encapsulates TCCL handling** inside the `Lookup` implementation
   - **Abstracts classpath vs JPMS** — same API for classpath-based and 
`ModuleLayer`-based realms
   - **Enforces visibility** — the `Lookup` is pre-scoped, so component 
visibility follows the realm's import chain by construction
   - **Removes `PluginManager.lookupList()`** — the realm owns its scoped 
lookup directly
   
   See #13223 for the full plan, specifically the "Layer 0b" and "Design 
Principle — Component Visibility Follows Classloading Rules" sections.
   
   _Claude Code on behalf of Guillaume Nodet_


-- 
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