Jayesh45-master opened a new pull request, #11604:
URL: https://github.com/apache/maven/pull/11604
Pull Request
Fixes #11581
Title
Remove reflective mutation of InputSource.modelId to comply with JDK 26 (JEP
500)
Description
What this PR does
This pull request removes reflective mutation of the modelId field on
org.apache.maven.api.model.InputSource from DefaultModelBuilder.
The removed code used reflection (setAccessible(true)) to mutate a final
field on a public Maven API model object.
Why this change is needed
Running Maven 4.0.0-rc5 on JDK 26 triggers the following warning even for
simple
invocations such as mvn clean:
Final field modelId in class org.apache.maven.api.model.InputSource
has been mutated reflectively
This warning is produced due to JEP 500, which tightens restrictions around
reflective mutation of final fields and will block such behavior in a future
Java release.
Key points:
org.apache.maven.api.model.InputSource is part of Maven’s public API
API model objects are immutable by design
maven-impl must not mutate API objects
Legacy model classes (org.apache.maven.model.*) are intentionally not
accessible from maven-impl
Reflective mutation violates both Maven 4 architecture and upcoming JVM rules
How the issue is resolved
The reflective mutation block in DefaultModelBuilder is removed entirely.
The modelId value is diagnostic metadata and is not required for build
correctness. Removing the mutation:
Preserves API immutability
Removes illegal reflective access
Eliminates JDK 26 warnings
Keeps runtime behavior unchanged for users
There is no valid alternative implementation at this layer that respects both
Maven’s module boundaries and Java’s strong encapsulation.
Scope of the change
Addresses one issue only: illegal reflective mutation of InputSource
No refactoring beyond the affected code block
No API changes
No behavior changes
Checklist Compliance
This pull request addresses a single issue only
Description explains what, how, and why clearly
Commit has a meaningful subject and body
Unit tests
Not added: this change removes illegal reflective access and does not alter
externally observable behavior. There is no reliable unit-test hook to assert
JVM-level reflective warnings.
mvn verify executed locally (with -DskipTests)
Core ITs
Not executed locally due to environment constraints; CI will validate
Change is under ~20 LOC
Verification
Executed locally:
mvn -DskipTests verify
mvn clean
Results:
Build succeeds
JDK 26 reflective mutation warning is no longer emitted
License Declaration
I hereby declare this contribution to be licensed under the
[Apache License Version 2.0, January
2004](http://www.apache.org/licenses/LICENSE-2.0)
--
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]