gnodet opened a new pull request, #13470:
URL: https://github.com/apache/maven/pull/13470
## Problem
`AbstractConfigurationConverter.instantiateObject()` (from
`org.eclipse.sisu.plexus`) uses `Class.newInstance()` which requires a
**public** no-arg constructor. This prevents using package-private classes (or
static inner classes with non-public constructors) as `@Parameter`
configuration types in Maven 4 API plugins — an `IllegalAccessException` is
thrown at configuration time.
This was discovered while working on removing the `maven-archiver`
dependency from `maven-jar-plugin` (apache/maven-jar-plugin#618): the plugin's
`ArchiveConfiguration` type would benefit from being a package-private class
but currently cannot be used as a `@Parameter` type.
Fixes #13459.
## Solution
`EnhancedConfigurationConverter` already overrides `fromConfiguration()`,
which is the call site of `instantiateObject()`. Since `instantiateObject` is
`protected final` in `AbstractConfigurationConverter` (from sisu, not
overridable), we replace the call with a local `instantiate()` method that uses:
```java
var ctor = type.getDeclaredConstructor();
if (!ctor.canAccess(null)) {
ctor.setAccessible(true);
}
return ctor.newInstance();
```
This is **symmetric** with how `EnhancedCompositeBeanHelper.setFieldValue()`
already handles non-public fields (via `field.setAccessible(true)`). The fix
makes constructor instantiation consistent with field injection.
## Alternative
A one-line fix in `eclipse-sisu/sisu.plexus`'s
`AbstractConfigurationConverter.instantiateObject()` would be the cleanest
long-term solution, but that requires a sisu release cycle. This Maven-side fix
is immediately actionable.
--
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]