Repository navigation
Conversation
Document Maven's classloader hierarchy and realm structure for Maven 4.x, covering the bootstrap classloader, core realm, core extensions, API realms, build extensions, project realms, plugin realms, exported artifacts/packages, and Sisu component visibility scoping. Based on the Takari Maven Classloading reference, updated for the current Maven 4.x architecture. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gnodet-bot
left a comment
There was a problem hiding this comment.
Two technical inaccuracies in the classloading strategy section and realm diagram.
1. Wrong default for classLoadingStrategy
The table in the "Core Extension Realms" section claims parent-first is the default. The source of truth is api/maven-api-cli/src/main/mdo/core-extensions.mdo:
<defaultValue>self-first</defaultValue>The description in that file also reads: "The class loading strategy: 'self-first' (the default), 'parent-first'…". The table and its default annotation need to be swapped.
2. maven.api.v4 is not a child of maven.api
The diagram shows maven.api.v4 nested under maven.api, suggesting it is a child realm. It isn't. Both are created with null parent in DefaultClassRealmManager:
// maven.api — foreign imports from CoreExports
this.mavenApiRealm = createRealm(API_REALMID, RealmType.Core, null, null, foreignImports, null);
// maven.api.v4 — foreign imports directly from containerRealm, not from maven.api
Map<String, ClassLoader> apiV4Imports = new HashMap<>();
apiV4Imports.put("org.apache.maven.api", containerRealm);
apiV4Imports.put("org.slf4j", containerRealm);
this.maven4ApiRealm = createRealm(API_V4_REALMID, RealmType.Core, null, null, apiV4Imports, null);maven.api.v4 is a sibling of maven.api, not a child. Both import directly from containerRealm (or from CoreExports which are sourced from it). The diagram's indentation implies a parent/child relationship that does not exist in the classworld graph.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Replace ASCII art with an SVG diagram showing the full realm hierarchy with distinct arrow types for parent relationships, package imports, and export feeds. Fix maven.api.v4: it has no parent and imports directly from the container realm — it is not a child of maven.api. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — 1 of the 2 issues has been addressed, but the table default is still wrong.
✅ Addressed: maven.api.v4 diagram hierarchy — the SVG now places both maven.api and maven.api.v4 at translate(_, 360) (same Y level), correctly showing them as siblings. The footer note also explicitly states they both have no parent and import directly from the container realm.
<classLoadingStrategy> table still marks parent-first as the default. The source of truth (core-extensions.mdo line 89: <defaultValue>self-first</defaultValue>) is unchanged — self-first is and remains the default. The table rows need to be swapped.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Document how Maven 4 plugins (using maven-di) have a stricter component visibility model than Maven 3 plugins (using Sisu): Maven 4 mojos are instantiated by a plain maven-di injector with only their own classpath and manually bound core services, without access to build extension components or Sisu beans. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — 1 of the 2 issues has been addressed, but the classLoading default is still wrong.
✅ Addressed: Diagram hierarchy — maven.api and maven.api.v4 are now correctly placed at the same Y level in the SVG (both at translate(_, 360)), and the footer note explicitly states they both have no parent and import directly from the container realm.
self-first is the default per core-extensions.mdo (<defaultValue>self-first</defaultValue>), yet:
- The XML comment on line 83 still reads
parent-first (default), self-first, plugin - The table still marks
`parent-first`as(default)
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
We already have https://maven.apache.org/guides/mini/guide-maven-classloading.html. Please rather extend that. |
|
Unsure from where the false statement "SISU visibility filtering can only happen when an explicit lookup is performed" comes from. For start, Sisu never filtered before 1.1.0, it was flat. Only Plexus was filtering. And the "plexus lookup filtering" was left in core when Maven Core was moved from Plexus to JSR330, but these two key spots were left Plexus (to have it realm filtering applied), see MavenITmng4385LifecycleMappingFromExtensionInReactorTest IT. Sisu was always dynamic, lazy, and it applied to anything Sisu injected. And since Sisu 1.1.0 JSR330 beans can be filtered as well. |
|
Proof for my claim is in last commit in PR #13582 |
- Replace plexus-classworlds with maven-classworlds (internalized since 4.2) - Update boot JAR path: plexus-classworlds-*.jar → maven-classworlds-*.jar - MNG-8112: -Dmaven.ext.class.path extension.xml descriptors are now honored - Document PluginManager API and Realm interface added in Maven 4 API - Update [classworlds] link to the new impl/maven-classworlds module Merge upstream/master into docs/maven-classloading
The mvn launcher script loads all JARs under boot/ with a wildcard, not a specific maven-classworlds-*.jar filename.
The m2.conf 'module' directive loads ${maven.home}/lib/modules/*.jar
as a child JPMS ModuleLayer (currently JLine JARs). The same JARs are
also listed as a 'load' entry in [plexus.core] as a classpath fallback
for embedders or older JDKs where createModuleLayer() is not invoked.
…ation)
Core extensions are not only read from .mvn/extensions.xml (project).
Maven 4 reads from three locations in precedence order:
- Project: ${session.rootDirectory}/.mvn/extensions.xml (maven.project.extensions)
- User: ${user.home}/.m2/extensions.xml (maven.user.extensions)
- Installation: ${maven.home}/conf/extensions.xml (maven.installation.extensions)
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier reviews — the diagram hierarchy is now correctly fixed (both maven.api and maven.api.v4 at the same Y level), but the classLoadingStrategy default is still wrong in two places (see inline comments).
self-first is the default per api/maven-api-cli/src/main/mdo/core-extensions.mdo (<defaultValue>self-first</defaultValue>), yet both the XML comment and the strategy table still say parent-first (default).
On @kwin's feedback (existing classloading guide): Worth considering whether this content should extend https://maven.apache.org/guides/mini/guide-maven-classloading.html instead of creating a new page — but that's a maintainer call beyond the scope of this review.
On @cstamas's feedback (Sisu filtering): The current text in the Limitations section attributes the quote to DefaultPackagingRegistry and scopes it specifically to injected collections, which is accurate for that context. The broader historical claim about Sisu filtering has been removed — the surviving text is defensible.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
The doc targets Maven 4 — no need for 'As of Maven 4.2' notes. Fold the MNG-8112 clarification directly into the bullet point.
gnodet-bot
left a comment
There was a problem hiding this comment.
The documentation has three factual errors — two of them are contradictory within the same PR diff.
1 & 2 — Wrong default classloading strategy (lines 107 & 123)
The XML snippet says:
<!-- optional: parent-first (default), self-first, plugin -->And the strategy table annotates `parent-first` (default).
But the authoritative source (core-extensions.mdo) declares self-first as the default:
- Description:
'self-first' (the default) <defaultValue>self-first</defaultValue>
The same diff even defines self-first correctly at line 131: "Uses the core realm as parent but checks its own classes first" — that is the behaviour you get by default. Both annotations pointing to parent-first are wrong.
3 — Sisu "limitation" is overgeneralised (lines 390–395)
The diff states as a general Sisu limitation:
Filtering only works on explicit lookups, not on injected collections.
This copies a code comment that is scoped to the DefaultPackagingRegistry legacy LifecycleMapping fallback — not a blanket Sisu limitation. Sisu 1.1.0+ filters injected collections too (confirmed by cstamas, the Sisu maintainer). The Limitations section should either be removed or scoped precisely to that specific legacy use-case.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
- Fix default classLoadingStrategy: self-first is the default per core-extensions.mdo, not parent-first (both XML comment and table) - Rewrite realm wiring section: maven.ext imports from extension realms (primary direction), extension realms import from maven.ext (for Sisu FilteredBeans visibility) - Remove false claim that Sisu filtering only works on explicit lookups — Sisu 1.1.0+ filters injected collections too - Remove false claim that project scope is imprecise in Sisu terms — project scope is defined with realms - Rewrite Limitations section around Sisu's forgiving/strict modes Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — all three findings have been addressed.
- Wrong default in XML comment ✅ —
<!-- optional: self-first (default), parent-first, plugin -->is now correct. - Wrong default in strategy table ✅ —
self-first (default)is now correctly annotated in the table. - Overgeneralised Sisu limitation ✅ — the false claim removed; the Limitations section now accurately describes Sisu's forgiving/strict mode behaviour.
The three-location extensions.xml table (project / user / installation) is a nice addition. Content is technically accurate for Maven 4.x.
LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — all three findings have been addressed.
- Wrong default in XML comment ✅ —
<!-- optional: self-first (default), parent-first, plugin -->is now correct. - Wrong default in strategy table ✅ —
self-first (default)is now correctly annotated in the table. - Overgeneralised Sisu limitation ✅ — the false claim removed; the Limitations section now accurately describes Sisu's forgiving/strict mode behaviour.
The three-location extensions.xml table (project / user / installation) is a nice addition. Content is technically accurate for Maven 4.x.
LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Summary
src/site/markdown/classloading.mddocumenting Maven's classloader hierarchy and realm structure for Maven 4.xCovers: bootstrap classloader, core realm, core extensions, maven.ext realm, API realms (maven.api + maven.api.v4), build extensions, project realms, plugin realms, exported artifacts/packages descriptor, and Sisu component visibility scoping (including known limitations).
Based on the Takari Maven Classloading reference, updated for the current Maven 4.x architecture.
Related to #13223 (overall classloader improvements plan).
Test plan
mvn sitegenerates the classloading page correctly🤖 Generated with Claude Code