Skip to content

fix: JSR330 filtering fix - #13582

Merged
cstamas merged 9 commits into
apache:maven-3.10.xfrom
cstamas:maven-3.10.x-jsr330-filtering
Oct 20, 2026
Merged

cstamas merged 9 commits into
apache:maven-3.10.xfrom
cstamas:maven-3.10.x-jsr330-filtering

Conversation

@cstamas

@cstamas cstamas commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Maven Core Extensions are having JSR330 filtering applied as well, but alas, when they are present, class realm layout changes a bit and visibility becomes invisibility. Using Sisu latest API to basically turn off filtering for JSR330 beans (so making it happen the very same as it was in Maven 3.9) when it comes to Maven Core Extensions.

Also, remove a forgotten "plexus dance", as today, with JSR330 filtering, it is not needed anymore.

Depends on eclipse-sisu/sisu-project#275
Fixes: #13583

Maven Core Extensions are having JSR330 filtering applied as well,
but alas, when they are present, class realm layout changes a bit
and visibility becomes invisibility. Using Sisu latest API to
basically turn off filtering for JSR330 beans (so making it
happen the very same as it was in Maven 3.9) when it comes to
Maven Core Extensions.
@cstamas
cstamas force-pushed the maven-3.10.x-jsr330-filtering branch from c6dcb84 to c1ae5ea Compare October 18, 2026 15:50
@cstamas
cstamas marked this pull request as ready for review October 18, 2026 16:02
@cstamas cstamas self-assigned this Oct 18, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ SNAPSHOT dependency blocks merge

This PR adds Sisu Maven Plugin 1.1.1-SNAPSHOT (pom.xml line 129) and two snapshot repositories (central-portal-snapshots) to fetch it. It cannot be merged until Sisu 1.1.1 is released and the SNAPSHOT reference + repository blocks are removed.

Next step: Wait for eu.maveniverse.sisu:sisu-maven-plugin:1.1.1 to be available on Central, then update the version and drop the snapshot repository blocks.


⚠️ No regression test

The fix changes filtering logic in BootstrapCoreExtensionManager (JSR330 visibility filtering is bypassed when the TCCL is a core extension realm), restoring Maven 3.9 behavior — but there is no test that reproduces the original failure. Without a regression test, a future refactor could silently reintroduce the bug.

Suggestion: Add an IT that loads a core extension with a JSR330 component and verifies it can be injected without NoSuchBeanDefinitionException.


💡 Javadoc inaccuracy in contextRealm() (MavenCli.java)

The Javadoc says:

"Helper method to return current TCCL set ClassRealm or null, if TCCL is not a class realm."

But the implementation walks the parent chain:

for (ClassLoader tccl = Thread.currentThread().getContextClassLoader(); tccl != null; tccl = tccl.getParent()) {
    if (tccl instanceof ClassRealm) {
        return (ClassRealm) tccl;
    }
}

This returns a ClassRealm if any ancestor of the TCCL is one — not just the direct TCCL itself. The Javadoc should reflect that: e.g. "Returns the first ClassRealm found in the TCCL parent chain, or null if none is found."


This review was generated by an AI agent, Hermès on behalf of @gnodet.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — 1 of 3 issues has been addressed.

✅ Javadoc inaccuracy in contextRealm() — fixed. The new Javadoc accurately states "Returns the first ClassRealm found in the TCCL parent chain, or null if none is found." The refactoring of realm-detection logic into BootstrapCoreExtensionManager (with the CORE_EXTENSION_REALM_NAME_PREFIX constant) is a clean improvement. The CORE_EXTENSION_REALM_NAME_PREFIX = "coreExtension>" constant is used consistently — no remaining hardcoded occurrences in the class.

✅ Core design verified. I cross-checked the Sisu FilteredBeans semantics: when the transformed supplier's .get() returns null, FilteredBeans.iterator() falls through to the unfiltered beans.iterator(). This is the documented mechanism to disable JSR330 filtering per-realm and precisely matches the intent of restoring Maven 3.9 behavior for core extensions. The TCCL-based check is thread-safe — Thread.currentThread().getContextClassLoader() is per-thread, and the parent-chain walk reads the immutable classloader hierarchy.

⚠️ SNAPSHOT dependency still blocks merge — sisu-maven-plugin 1.1.1-SNAPSHOT and the central-portal-snapshots repository blocks remain in pom.xml. Even though sisu-project#275 is now merged, sisu 1.1.1 has not been released yet. This PR cannot be merged until sisu 1.1.1 is out on Central and the snapshot reference + repository blocks are removed.

⚠️ No regression test — still unaddressed. The fix changes JSR330 visibility filtering for core extension realms, restoring Maven 3.9 behavior, but there is no test that exercises the failure scenario (i.e. a core extension providing a JSR330 component that the container cannot find without this fix). At minimum, an IT verifying that a core extension's JSR330 beans are injectable would prevent future regressions.


This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sisu is filtering for us, even injected collections. Magic.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewing after the latest commits. Two issues remain.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Comment thread pom.xml Resolved

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on my earlier review — 1 of 2 open issues has been addressed.

✅ isEnabled() filtering in DefaultLifecycles.java — addressed. The removeIf(e -> !isEnabled(e.getKey())) call correctly preserves the maven.site.lifecycle.disabled behavior, and the new testSiteLifecycleDisabled unit test validates it end-to-end (sets the system property, verifies only clean and default remain). I cross-checked: DefaultLifecyclePluginAnalyzer is unrelated to this check — the isEnabled() gate only applies to lifecycle phases, not packaging-to-lifecycle mappings, so no symmetrical fix is needed there.

⚠️ SNAPSHOT dependency still blocks merge — sisu-maven-plugin 1.1.1-SNAPSHOT and the central-portal-snapshots repository blocks remain in pom.xml. Sisu 1.1.1 has not been released yet (current latest on Central is 1.1.0, released July 2026). This PR cannot be merged until 1.1.1 is out on Central and the SNAPSHOT reference + repository blocks are removed.


This review was generated by an AI agent, Hermès on behalf of @gnodet.

Comment thread pom.xml Resolved
@cstamas
cstamas requested a review from gnodet-bot October 20, 2026 11:12

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review after latest commits. The SNAPSHOT dependency is resolved and missing tests are now added — both prior blocking issues addressed. Two minor suggestions below.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@cstamas
cstamas requested a review from gnodet-bot October 20, 2026 12:22

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All previously-raised review threads are now addressed. ✅

What's new in this push:

  • Defensive lifecycle == null check added in DefaultLifecycles.java with explanatory comment
  • BootstrapCoreExtensionManagerTest.java expanded to 6 test scenarios covering ClassRealm hierarchy cases

One remaining blocker: Spotless formatting

The new test file has a Palantir Java format violation that fails CI. Fix with:

mvn spotless:apply -pl maven-embedder

Also: Duplicate PR #13584 covers the same fix and should be closed.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@cstamas cstamas added the bug Something isn't working label Oct 20, 2026

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All previously-raised review findings are now resolved. ✅

What's new in this push:

  • "Reformat" commit (f98ac41) runs spotless:apply on BootstrapCoreExtensionManagerTest.java — one line unwrapped to satisfy Palantir Java Format. No semantic change.

Summary of prior findings (all addressed):

  • ✅ SNAPSHOT dependency (sisu-maven-plugin 1.1.1-SNAPSHOT) → resolved (1.1.1 released, now on Central)
  • ✅ Missing regression test → BootstrapCoreExtensionManagerTest.java added (6 test scenarios)
  • ✅ isEnabled() filtering lost in DefaultLifecycles → fixed with removeIf
  • ✅ Javadoc inaccuracy in contextRealm() → fixed
  • ✅ Spotless formatting violation in test file → fixed by this Reformat commit

Housekeeping note: PR #13584 by @charangowdamd-cmd ("[3.10.x] Fix #13583: Allow core extensions to see container components with Sisu 1.1.0") is still open and duplicates this fix. A maintainer should close it as superseded.

LGTM.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@cstamas
cstamas merged commit 248482b into apache:maven-3.10.x Oct 20, 2026
5 checks passed
@cstamas
cstamas deleted the maven-3.10.x-jsr330-filtering branch October 20, 2026 15:12
@pzygielo

Copy link
Copy Markdown
Contributor

I think this caused https://lists.apache.org/thread.html/g47zd1kvtj4wmmr8l3q22o896p55s7x8 - where groovy-eclipse-compiler registered as extension (https://github.com/groovy/groovy-eclipse/wiki/groovy-eclipse-maven-plugin#use-the-groovy-eclipse-compiler-mojo-for-configuring-source-folders) has no :add-groovy-build-paths executed.

That worked fine in 3.10.0 and previously in 3.9.16 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants