You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Get the value of the field with the given name from the provided targetObject/targetClass.
getField(Object targetObject, String name)
Get the value of the field with the given name from the provided targetObject.
Note that getField() works for both static fields and regular fields (support for static fields was added in v4.2.0.RC1 with this commit, associated with #11458).
Problem
In contrast, there is only one version of invokeMethod(), and it only works on an instantiated Object.
Invoke the method with the given name on the supplied target object with the supplied arguments.
There are no other versions of invokeMethod() that work for static methods.
Feature Request
To make the class more consistent with getField() and setField(), I would like to request a new version of invokeMethod() that works on static methods:
Background
Spring Test's ReflectionTestUtils includes methods for setting/getting fields, like so (bolded text is from me):
getField(Class<?> targetClass, String name)
targetClass
.getField(Object targetObject, Class<?> targetClass, String name)
targetObject
/targetClass
.getField(Object targetObject, String name)
targetObject
.Note that
getField()
works for both static fields and regular fields (support for static fields was added in v4.2.0.RC1 with this commit, associated with #11458).Problem
In contrast, there is only one version of
invokeMethod()
, and it only works on an instantiatedObject
.invokeMethod(Object target, String name, Object... args)
There are no other versions of
invokeMethod()
that work for static methods.Feature Request
To make the class more consistent with
getField()
andsetField()
, I would like to request a new version ofinvokeMethod()
that works on static methods:invokeMethod(Class<?> targetClass, String name, Object... args)
targetClass
with the supplied arguments.If it makes sense, we should also add:
invokeMethod(Object targetObject, Class<?> targetClass, String name, Object... args)
targetObject
/targetClass
with the supplied arguments.The text was updated successfully, but these errors were encountered: