Repository navigation
fix: load JLine on module-path for targeted --enable-native-access (fixes #11028) - #13491
Conversation
- Add maven-api-classworlds to exportedArtifacts in extension.xml (prevents ClassCastException when plugins depend on the API) - Restore installEmbeddedTerminal() and dumb terminal color detection in MavenCli (inadvertently removed, regressing apache#13357) - Remove dead code applyExportOrOpen() from DefaultClassRealmManager (belongs in PR apache#13491 where it gets called) - Remove all unrelated changes that were baked into the squash commit: mvnval feature, MojoExecution noun-accessor refactor, DependencyNode cache fix, version bumps (mimir, japicmp), CI workflow changes, JvmConfigParser precompile, and various other master changes - Restore mimir 0.12.4 and japicmp 0.26.3 versions (fixes CI) Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
2adb07f to
7fb7656
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
The approach is correct — moving JLine to a named module to silence the ALL-UNNAMED warning is the right design. However, there are a few issues to address before merging.
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 — the four prior issues remain open. One additional finding:
This review was generated by an AI agent, Hermès on behalf of @gnodet.
7fb7656 to
8789e5c
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — none of the 6 prior issues have been fully addressed. One is partially addressed (probe ordering); the others remain open. Two additional findings below.
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.
6 prior findings addressed. One new issue found:
BootstrapCoreExtensionManager uses API classworlds types, inconsistent with MavenCli.java fixed in this same commit.
Both files live in compat/maven-embedder and this commit modified both. MavenCli.java was switched back to the plexus types (org.codehaus.plexus.classworlds.ClassWorld, org.codehaus.plexus.classworlds.realm.ClassRealm) for the compat layer — but BootstrapCoreExtensionManager was changed in the opposite direction, importing the API types (org.apache.maven.api.classworlds.ClassRealm/ClassWorld). This forces the ugly FQN downcast at lines 184–185 and the getClassLoader() workaround on line 179, simply because setParentRealm() is intentionally absent from the API interface.
Since this is compat code, the plexus types are the right choice here — as demonstrated by the fix applied to MavenCli.java in this same commit. Reverting BCEM to plexus imports eliminates the downcast and the workaround entirely.
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 9 prior findings are addressed. ✅ The probe ordering, fallback initialization, compat-layer type reversion, and m2.conf dual-load comment are all correct. One new finding in the new API module.
maven-api-classworlds is missing module-info.java.
Every other API module in api/ has one (maven-api-annotations, maven-api-cli, maven-api-core, maven-api-di, maven-api-metadata, maven-api-model, maven-api-plugin, maven-api-settings, maven-api-spi, maven-api-toolchain, maven-api-xml). Without a module-info.java, this module is an automatic module on the module-path: its module name is derived from the JAR filename (org.apache.maven.api.classworlds → depends on Maven artifact naming), has no requires declarations, and cannot be properly referenced by name in --enable-native-access or --add-opens. For a module whose entire purpose is enabling JPMS classloading, the irony of being an automatic module is notable.
Add api/maven-api-classworlds/src/main/java/module-info.java:
module org.apache.maven.api.classworlds {
requires transitive org.apache.maven.api.annotations;
exports org.apache.maven.api.classworlds;
}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.
All 9 prior findings are addressed. ✅ The module-info.java is now present and correct, ClassWorldListener methods are default for forward compatibility, and the impl-detail assertSame(realm, classLoader) assertion has been replaced with the API-correct assertNotNull.
LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Generalize the interface for use at all levels (session, project, plugin). The same Realm shape — classLoader(), moduleLayer(), lookup() — applies uniformly; the difference is what the Lookup sees, not the type. Module layers are not plugin-specific (extensions and core can also use them, e.g. JLine per apache#13491). See apache#13223 (Layer 0b) for the design rationale. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Add impl/maven-classworlds: fork of plexus-classworlds with org.codehaus.plexus.classworlds implementation, backward-compat adapters under org.codehaus.classworlds, and new JPMS capabilities (module directive in m2.conf, META-INF/maven/module-access descriptor) - Replace external plexus-classworlds dependency with maven-classworlds across all modules - Remove classWorldsVersion property from root pom.xml - Preserve org.codehaus.classworlds compat package until eclipse-sisu/sisu-project#280 is merged and released (tracked in #13693) - Public API surface for classworlds deferred per review feedback - Prerequisite for #13491 (JLine on module-path) and #13494 (per-plugin ModuleLayer support) - Supersedes #11029
1f8b57b to
c74dbfe
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — all previous findings remain addressed. One regression introduced by the rebase.
mvn.cmd debug echo uses stale %JVM_CONFIG_MAVEN_OPTS% — variable no longer exists.
The debug echo was updated to add %MAVEN_MODULE_OPTS%, but it regresses %JVM_CONFIG_ARGFILE_ARG% back to %JVM_CONFIG_MAVEN_OPTS%. That variable was renamed to JVM_CONFIG_ARGFILE_ARG by a prior PR; it does not exist in the current script. The actual JVM launch at the line below correctly uses %JVM_CONFIG_ARGFILE_ARG% — the bug is debug-only, but when MAVEN_DEBUG_SCRIPT is set on Windows the @argfile path silently vanishes from the output, making the debug log misleading.
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.
All prior findings addressed. ✅
The new commit (8cc0baa) correctly fixes the only remaining open issue: the stale %JVM_CONFIG_MAVEN_OPTS% reference in the mvn.cmd debug echo is now %JVM_CONFIG_ARGFILE_ARG%, matching the actual variable name and the actual JVM invocation below it.
The MAVEN_ARGS → MAVEN_EFFECTIVE_ARGS refactor is also clean: avoiding mutation of MAVEN_ARGS itself and using IS_MAIN_OVERRIDE (set during arg scanning) mirrors the Linux mvn behavior correctly.
One note for completeness: test-mvn-path-conversion.sh doesn't assert the MODULES_DIR path conversion in the debug output — adding a to_windows "$maven_home/lib/modules" assertion alongside the existing library.jline.path check would be a nice follow-up, but it's not a blocker.
LGTM.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
…13625) * Add scoped plugin service discovery API Expose a Maven 4 PluginManager service that resolves declared project plugins into public runtime metadata and performs component lookups with the plugin realm as the context classloader. This removes the need for build extensions to combine internal plugin manager and container APIs for plugin-contributed services. * Introduce scoped plugin realms Replace direct plugin classloader access with a PluginRealm that exposes the classloader, an optional module layer, and a realm-scoped Lookup. Keep TCCL management inside the Lookup implementation so callers cannot accidentally perform an unscoped component lookup. * Address plugin realm API review feedback Use Maven 4 noun-style realm accessors, document the new API, and preserve undeclared-plugin errors. Add the requested exception constructors and serialization metadata, nullable annotation, and regression coverage. * Document undeclared plugin error Declare the IllegalArgumentException thrown by PluginManager.loadPlugin when the requested plugin is not present in the project build. * Rename PluginRealm to Realm Generalize the interface for use at all levels (session, project, plugin). The same Realm shape — classLoader(), moduleLayer(), lookup() — applies uniformly; the difference is what the Lookup sees, not the type. Module layers are not plugin-specific (extensions and core can also use them, e.g. JLine per #13491). See #13223 (Layer 0b) for the design rationale. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * Clarify realm lookup visibility contract Document that realm lookup delegates with the realm classloader as the TCCL and that component visibility depends on container filtering. * Handle plugin descriptors without class realms Use the current context classloader, with the Maven implementation classloader as a final fallback, when legacy descriptors have no realm attached. Restore regression coverage for minimal mojo descriptors used by expression evaluation. * fix: keep getClassLoader() as default delegating to getRealm().classLoader() getClassLoader() was part of the Plugin API since 4.0.0-alpha-10 (MNG-7947). Keep it as a default method delegating to getRealm().classLoader() to preserve backward compatibility. --------- Co-authored-by: Guillaume Nodet <[email protected]> Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
…ixes apache#11028) - component.xml: move JLine JARs to lib/modules/, exclude from lib/ - m2.conf: add 'module' directives for JLine JARs + classpath fallback - mvn: replace --enable-native-access=ALL-UNNAMED with targeted module-path probe; fall back to ALL-UNNAMED when lib/modules/ is unavailable or JDK does not support the flag; use boot/*.jar wildcard (no longer tied to plexus-classworlds filename) - mvn.cmd: same targeted native-access; use IS_MAIN_OVERRIDE to suppress MAVEN_ARGS for sub-commands (--enc, --shell, --up, --val) - component.xml: drop outputFileNameMapping shim — boot/*.jar wildcard in the launcher scripts makes the filename opaque, so maven-classworlds can now be deployed under its natural name - LICENSE.vm: update JLine license block to lib/modules directory - MavenCli.java (compat): add explicit (ClassRealm) cast after API change
8cc0baa to
b3993da
Compare
gnodet-bot
left a comment
There was a problem hiding this comment.
Following up on my earlier review — all 18 prior threads are now resolved. The PR is well-structured: the fallback to ALL-UNNAMED when the module-path probe fails correctly restores the previous behavior, Cygwin/MinGW path conversion is properly sequenced (MODULES_DIR cygpath before the probe), and the IS_MAIN_OVERRIDE refactoring in mvn.cmd is semantically equivalent to the old MAVEN_MAIN_CLASS check. Two minor issues remain.
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.
✅ LGTM. The JLine JPMS module-path loading and targeted --enable-native-access are correctly implemented.
One minor note: the maven-api-classworlds condition in LICENSE.vm (line 275) is dead code — that module was created then removed in PR #13490. It's harmless but can be cleaned up in a follow-up.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
Summary
Load JLine JARs on the JPMS module-path (via
lib/modules/) so Maven can use a targeted--enable-native-access=org.jline.terminal.ffm,org.jline.nativinstead of the broad--enable-native-access=ALL-UNNAMED.Requires #13490 (internalize plexus-classworlds /
moduledirective inConfigurator).Changes
m2.conf— addmoduledirectives for JLine JARs; they're loaded in a childModuleLayerviaConfigurator.createModuleLayer()(PR A)component.xml— addlib/modules/output directory for JLine JARs in the assemblymvn— replace--enable-native-access=ALL-UNNAMEDwith targeted module names; add Java version guard (skip on JDKs < 11 that don't support the flag)mvn.cmd— same targeted native-access flags; guardMAVEN_ARGSfrom being forwarded to sub-commands (--enc,--shell,--up) matching LinuxmvnbehaviourLICENSE.vm— update JLine license blocktest-mvn-path-conversion.sh— test path conversion for the newlib/modules/directoryMotivation
--enable-native-access=ALL-UNNAMEDis overly broad and triggers a JDK warning (--enable-native-access=ALL-UNNAMEDis going away). JLine's FFM terminal and native libraries are the only consumers; targeting them precisely silences the warning while keeping native terminal support.Fixes #11028