Skip to content

Commit bbb5db7

Browse files
committed
Remove unused
org.apache.commons.beanutils2.MethodUtils.invokeStaticMethod(Class, String, Object) in favor of Apache Commons Lang's MethodUtils
1 parent 0af69af commit bbb5db7

File tree

3 files changed

+1
-41
lines changed

3 files changed

+1
-41
lines changed

src/changes/changes.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<!-- REMOVE -->
4040
<action dev="ggregory" type="remove" due-to="Gary Gregory">Remove unused ConstructorUtils in favor of Apache Commons Lang's ConstructorUtils. ConstructorUtils is unused in this component.</action>
4141
<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 MethodUtils.</action>
42+
<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 MethodUtils.</action>
4243
</release>
4344
<release version="2.0.0-M2" date="2025-05-25" description="This is a major release and requires Java 8.">
4445
<!-- FIX -->

src/main/java/org/apache/commons/beanutils2/MethodUtils.java

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -891,40 +891,6 @@ public static Object invokeMethod(final Object object, final String methodName,
891891
return method.invoke(object, args);
892892
}
893893

894-
/**
895-
* <p>
896-
* Invoke a named static method whose parameter type matches the object type.
897-
* </p>
898-
*
899-
* <p>
900-
* The behavior of this method is less deterministic than {@link #invokeExactMethod(Object, String, Object[], Class[])}. It loops through all methods with
901-
* names that match and then executes the first it finds with compatible parameters.
902-
* </p>
903-
*
904-
* <p>
905-
* This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a {@code Boolean} class would match a
906-
* {@code boolean} primitive.
907-
* </p>
908-
*
909-
* <p>
910-
* This is a convenient wrapper for {@link #invokeStaticMethod(Class objectClass,String methodName,Object [] args)}.
911-
* </p>
912-
*
913-
* @param objectClass invoke static method on this class
914-
* @param methodName get method with this name
915-
* @param arg use this argument. May be null (this will result in calling the parameterless method with name {@code methodName}).
916-
* @return The value returned by the invoked method
917-
* @throws NoSuchMethodException if there is no such accessible method
918-
* @throws InvocationTargetException wraps an exception thrown by the method invoked
919-
* @throws IllegalAccessException if the requested method is not accessible via reflection
920-
* @since 1.8.0
921-
*/
922-
public static Object invokeStaticMethod(final Class<?> objectClass, final String methodName, final Object arg)
923-
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
924-
final Object[] args = toArray(arg);
925-
return invokeStaticMethod(objectClass, methodName, args);
926-
}
927-
928894
/**
929895
* <p>
930896
* Invoke a named static method whose parameter type matches the object type.

src/test/java/org/apache/commons/beanutils2/MethodUtilsTest.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,6 @@ void testInvokeMethodUnknown() throws Exception {
216216
assertThrows(NoSuchMethodException.class, () -> MethodUtils.invokeMethod(parent, "bogus", childOne));
217217
}
218218

219-
@Test
220-
void testInvokeStaticMethodNull() throws Exception {
221-
final int current = TestBean.currentCounter();
222-
final Object value = MethodUtils.invokeStaticMethod(TestBean.class, "currentCounter", (Object) null);
223-
assertEquals(current, ((Integer) value).intValue(), "currentCounter value");
224-
}
225-
226219
@Test
227220
void testNoCaching() throws Exception {
228221
// no caching

0 commit comments

Comments
 (0)