This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git

commit 482fc82107ec67014023e77fb59ce167773165a7
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Aug 16 16:20:24 2025 -0400

    Remove unused
    org.apache.commons.beanutils2.MethodUtils.invokeExactMethod(Object,
    String, Object[]) in favor of Apache Commons Lang's
    org.apache.commons.lang3.reflect.MethodUtils
---
 src/changes/changes.xml                            |  1 +
 .../org/apache/commons/beanutils2/MethodUtils.java | 29 ----------------------
 .../apache/commons/beanutils2/MethodUtilsTest.java | 17 ++++---------
 .../beanutils2/memoryleaktests/MemoryLeakTest.java |  2 +-
 4 files changed, 7 insertions(+), 42 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b2b2e91c..bd909581 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -39,6 +39,7 @@
       <!-- REMOVE -->
       <action dev="ggregory" type="remove" due-to="Gary Gregory">Remove unused 
ConstructorUtils in favor of Apache Commons Lang's 
org.apache.commons.lang3.ConstructorUtils. ConstructorUtils is unused in this 
component.</action>
       <action dev="ggregory" type="remove" due-to="Gary Gregory">Remove unused 
org.apache.commons.beanutils2.MethodUtils.invokeExactMethod(Object, String, 
Object) in favor of Apache Commons Lang's 
org.apache.commons.lang3.reflect.MethodUtils.</action>
+      <action dev="ggregory" type="remove" due-to="Gary Gregory">Remove unused 
org.apache.commons.beanutils2.MethodUtils.invokeExactMethod(Object, String, 
Object[]) in favor of Apache Commons Lang's 
org.apache.commons.lang3.reflect.MethodUtils.</action>
       <action dev="ggregory" type="remove" due-to="Gary Gregory">Remove unused 
org.apache.commons.beanutils2.MethodUtils.invokeStaticMethod(Class, String, 
Object) in favor of Apache Commons Lang's 
org.apache.commons.lang3.reflect.MethodUtils.</action>
       <action dev="ggregory" type="remove" due-to="Gary Gregory">Remove unused 
org.apache.commons.beanutils2.MethodUtils.invokeExactStaticMethod(Class, 
String, Object) in favor of Apache Commons Lang's 
org.apache.commons.lang3.reflect.MethodUtils.</action>
       <action dev="ggregory" type="remove" due-to="Gary Gregory">Remove unused 
org.apache.commons.beanutils2.MethodUtils.invokeExactStaticMethod(Class, 
String, Object) in favor of Apache Commons Lang's 
org.apache.commons.lang3.reflect.MethodUtils.</action>
diff --git a/src/main/java/org/apache/commons/beanutils2/MethodUtils.java 
b/src/main/java/org/apache/commons/beanutils2/MethodUtils.java
index d611663d..6f6202ca 100644
--- a/src/main/java/org/apache/commons/beanutils2/MethodUtils.java
+++ b/src/main/java/org/apache/commons/beanutils2/MethodUtils.java
@@ -517,35 +517,6 @@ public final class MethodUtils {
         return totalCost;
     }
 
-    /**
-     * Invoke a method whose parameter types match exactly the object types.
-     *
-     * <p>
-     * This uses reflection to invoke the method obtained from a call to 
{@code getAccessibleMethod()}.
-     * </p>
-     *
-     * @param object     invoke method on this object.
-     * @param methodName get method with this name.
-     * @param args       use these arguments - treat null as empty array 
(passing null will result in calling the parameterless method with name
-     *                   {@code methodName}).
-     * @return The value returned by the invoked method.
-     * @throws NoSuchMethodException     if there is no such accessible method.
-     * @throws InvocationTargetException wraps an exception thrown by the 
method invoked.
-     * @throws IllegalAccessException    if the requested method is not 
accessible via reflection.
-     */
-    public static Object invokeExactMethod(final Object object, final String 
methodName, Object... args)
-            throws NoSuchMethodException, IllegalAccessException, 
InvocationTargetException {
-        if (args == null) {
-            args = BeanUtils.EMPTY_OBJECT_ARRAY;
-        }
-        final int arguments = args.length;
-        final Class<?>[] parameterTypes = new Class[arguments];
-        for (int i = 0; i < arguments; i++) {
-            parameterTypes[i] = args[i].getClass();
-        }
-        return invokeExactMethod(object, methodName, args, parameterTypes);
-    }
-
     /**
      * Invoke a method whose parameter types match exactly the parameter types 
given.
      *
diff --git a/src/test/java/org/apache/commons/beanutils2/MethodUtilsTest.java 
b/src/test/java/org/apache/commons/beanutils2/MethodUtilsTest.java
index 430905f1..9e572564 100644
--- a/src/test/java/org/apache/commons/beanutils2/MethodUtilsTest.java
+++ b/src/test/java/org/apache/commons/beanutils2/MethodUtilsTest.java
@@ -64,7 +64,7 @@ class MethodUtilsTest {
     void testClearCache() throws Exception {
         MethodUtils.clearCache(); // make sure it starts empty
         final PublicSubBean bean = new PublicSubBean();
-        MethodUtils.invokeExactMethod(bean, "setFoo", "alpha");
+        MethodUtils.invokeExactMethod(bean, "setFoo", new String[] { "alpha" 
}, new Class[] { String.class });
         assertEquals(1, MethodUtils.clearCache());
         assertEquals(0, MethodUtils.clearCache());
     }
@@ -99,12 +99,6 @@ class MethodUtilsTest {
         assertMethod(method, "methodBaz");
     }
 
-    @Test
-    void testInvokeExactMethodNullArray() throws Exception {
-        final Object result = MethodUtils.invokeExactMethod(new 
AlphaBean("parent"), "getName", null);
-        assertEquals("parent", result);
-    }
-
     @Test
     void testInvokeExactMethodNullArrayNullArray() throws Exception {
         final Object result = MethodUtils.invokeExactMethod(new 
AlphaBean("parent"), "getName", null, null);
@@ -125,7 +119,7 @@ class MethodUtilsTest {
         MethodUtils.setCacheMethods(false);
 
         final PublicSubBean bean = new PublicSubBean();
-        MethodUtils.invokeExactMethod(bean, "setFoo", "alpha");
+        MethodUtils.invokeExactMethod(bean, "setFoo", new String[] { "alpha" 
}, new Class[] { String.class });
         assertEquals(0, MethodUtils.clearCache());
 
         // reset default
@@ -145,9 +139,9 @@ class MethodUtilsTest {
 
         // see if we can access public methods in a default access superclass
         // from a public access subclass instance
-        MethodUtils.invokeExactMethod(bean, "setFoo", "alpha");
+        MethodUtils.invokeExactMethod(bean, "setFoo", new String[] { "alpha" 
}, new Class[] { String.class });
         assertEquals(bean.getFoo(), "alpha", "Set value (foo:2)");
-        MethodUtils.invokeExactMethod(bean, "setBar", "beta");
+        MethodUtils.invokeExactMethod(bean, "setBar", new String[] { "beta" }, 
new Class[] { String.class });
         assertEquals(bean.getBar(), "beta", "Set value (bar:2)");
 
         Method method = MethodUtils.getAccessibleMethod(PublicSubBean.class, 
"setFoo", String.class);
@@ -169,9 +163,8 @@ class MethodUtilsTest {
     void testSetCacheMethods() throws Exception {
         MethodUtils.setCacheMethods(true);
         MethodUtils.clearCache(); // make sure it starts empty
-
         final PublicSubBean bean = new PublicSubBean();
-        MethodUtils.invokeExactMethod(bean, "setFoo", "alpha");
+        MethodUtils.invokeExactMethod(bean, "setFoo", new String[] { "alpha" 
}, new Class[] { String.class });
         assertEquals(1, MethodUtils.clearCache());
         assertEquals(0, MethodUtils.clearCache());
     }
diff --git 
a/src/test/java/org/apache/commons/beanutils2/memoryleaktests/MemoryLeakTest.java
 
b/src/test/java/org/apache/commons/beanutils2/memoryleaktests/MemoryLeakTest.java
index 1891ec1f..26cf1f88 100644
--- 
a/src/test/java/org/apache/commons/beanutils2/memoryleaktests/MemoryLeakTest.java
+++ 
b/src/test/java/org/apache/commons/beanutils2/memoryleaktests/MemoryLeakTest.java
@@ -382,7 +382,7 @@ public class MemoryLeakTest {
 
         // if you comment the following line, the test will work, and the 
ClassLoader will be released.
         // That proves that nothing is wrong with the test, and MethodUtils is 
holding a reference
-        assertEquals("initialValue", MethodUtils.invokeExactMethod(bean, 
"getName", new Object[0]));
+        assertEquals("initialValue", MethodUtils.invokeExactMethod(bean, 
"getName", new Object[0], new Class[0]));
 
         // this should make the reference go away.
         loader = null;

Reply via email to