gnodet-bot commented on code in PR #13470:
URL: https://github.com/apache/maven/pull/13470#discussion_r4258038504
##########
impl/maven-core/src/main/java/org/apache/maven/configuration/internal/EnhancedConfigurationConverter.java:
##########
@@ -111,6 +111,19 @@ public Object fromConfiguration(
}
}
+ private static Object instantiate(Class<?> type, PlexusConfiguration
configuration)
+ throws ComponentConfigurationException {
+ try {
+ var ctor = type.getDeclaredConstructor();
+ if (!ctor.canAccess(null)) {
+ ctor.setAccessible(true);
+ }
+ return ctor.newInstance();
+ } catch (ReflectiveOperationException e) {
Review Comment:
⚠️ **Missing test for the fixed scenario.**
This PR fixes a real bug (`Class.newInstance()` requiring a public
constructor) but adds no test. A future regression would be silent. Please add
a unit test in `maven-core` that:
1. Defines a class with a **package-private no-arg constructor** (e.g. a
static inner class in the test)
2. Runs it through `EnhancedConfigurationConverter.fromConfiguration()` (or
directly calls `instantiate()` via reflection)
3. Asserts the instance is created without `ComponentConfigurationException`
Without this, CI cannot catch a regression to the old `instantiateObject()`
call.
--
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]