This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-plugin-testing.git
commit 702e08483bc05554d070cab8a5d3c6afb7e4d08e Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Tue Nov 10 14:26:30 2026 +0000 Keep plexus ReflectionUtils on the Maven 3 harness The Maven 3 line cannot drop plexus-utils (mojo configuration is wired through the Plexus configurator), so replacing ReflectionUtils.getFieldByNameIncludingSuperclasses with a private JDK helper was churn without benefit. Restore the plexus utility and note the private-helper variant as Maven-4-only (#13928), while keeping the orthogonal improvements: UTF-8 readers and field-not-found messages that include the class name. --- .../maven/api/plugin/testing/MojoExtension.java | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java index bbbc6be..0e3eae9 100644 --- a/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java +++ b/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing/MojoExtension.java @@ -88,6 +88,7 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; import org.codehaus.plexus.testing.PlexusExtension; import org.codehaus.plexus.util.InterpolationFilterReader; +import org.codehaus.plexus.util.ReflectionUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomBuilder; import org.eclipse.aether.RepositorySystemSession; @@ -686,7 +687,7 @@ public class MojoExtension extends PlexusExtension implements ParameterResolver */ @SuppressWarnings("unchecked") public static <T> T getVariableValueFromObject(Object object, String variable) throws IllegalAccessException { - Field field = getFieldByNameIncludingSuperclasses(variable, object.getClass()); + Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses(variable, object.getClass()); Objects.requireNonNull( field, "Field " + variable + " not found in " + object.getClass().getName()); @@ -752,7 +753,7 @@ public class MojoExtension extends PlexusExtension implements ParameterResolver */ public static void setVariableValueToObject(Object object, String variable, Object value) throws IllegalAccessException { - Field field = getFieldByNameIncludingSuperclasses(variable, object.getClass()); + Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses(variable, object.getClass()); Objects.requireNonNull( field, "Field " + variable + " not found in " + object.getClass().getName()); @@ -760,21 +761,6 @@ public class MojoExtension extends PlexusExtension implements ParameterResolver field.set(object, value); } - /** - * Traverses the class hierarchy from {@code clazz} upward and returns the first - * declared field matching {@code name}, or {@code null} if none is found. - */ - private static Field getFieldByNameIncludingSuperclasses(String name, Class<?> clazz) { - for (Class<?> type = clazz; type != null && type != Object.class; type = type.getSuperclass()) { - try { - return type.getDeclaredField(name); - } catch (NoSuchFieldException ignored) { - // continue - } - } - return null; - } - private static class WrapEvaluator implements TypeAwareExpressionEvaluator { private final PlexusContainer container;
