Class MethodUtils
- java.lang.Object
-
- com.aspectran.core.util.MethodUtils
-
public class MethodUtils extends java.lang.Object
Utility reflection methods.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Class<?>[]
EMPTY_CLASS_PARAMETERS
An empty class arraystatic java.lang.Object[]
EMPTY_OBJECT_ARRAY
An empty object arraystatic java.lang.reflect.Method[]
NO_METHODS
-
Constructor Summary
Constructors Constructor Description MethodUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
clearCache()
Clear the method cache.static java.lang.reflect.Method
getAccessibleMethod(java.lang.Class<?> clazz, java.lang.reflect.Method method)
Return an accessible method (that is, one that can be invoked via reflection) that implements the specified Method.static java.lang.reflect.Method
getAccessibleMethod(java.lang.Class<?> clazz, java.lang.String methodName)
Return an accessible method (that is, one that can be invoked via reflection) with given name and a single parameter.static java.lang.reflect.Method
getAccessibleMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?> paramType)
Return an accessible method (that is, one that can be invoked via reflection) with given name and a single parameter.static java.lang.reflect.Method
getAccessibleMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?>[] paramTypes)
Return an accessible method (that is, one that can be invoked via reflection) with given name and parameters.static java.lang.reflect.Method
getAccessibleMethod(java.lang.reflect.Method method)
Return an accessible method (that is, one that can be invoked via reflection) that implements the specified Method.static java.lang.reflect.Method
getMatchingAccessibleMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?>[] paramTypes)
Find an accessible method that matches the given name and has compatible parameters.static java.lang.reflect.Method
getMatchingAccessibleMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<?>[] paramTypes)
Find an accessible method that matches the given name and has compatible parameters.static java.lang.Object
invokeExactMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object arg)
Invoke a method whose parameter type matches exactly the object type.static java.lang.Object
invokeExactMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] args)
Invoke a method whose parameter types match exactly the object types.static java.lang.Object
invokeExactMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<?>[] paramTypes)
Invoke a method whose parameter types match exactly the parameter types given.static java.lang.Object
invokeExactStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName)
Invoke a static method that has no parameters.static java.lang.Object
invokeExactStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object arg)
Invoke a static method whose parameter type matches exactly the object type.static java.lang.Object
invokeExactStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object[] args)
Invoke a static method whose parameter types match exactly the object types.static java.lang.Object
invokeExactStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<?>[] paramTypes)
Invoke a static method whose parameter types match exactly the parameter types given.static java.lang.Object
invokeGetter(java.lang.Object object, java.lang.String getterName)
Gets an Object property from a bean.static java.lang.Object
invokeGetter(java.lang.Object object, java.lang.String getterName, java.lang.Object arg)
Gets an Object property from a bean.static java.lang.Object
invokeGetter(java.lang.Object object, java.lang.String getterName, java.lang.Object[] args)
Gets an Object property from a bean.static java.lang.Object
invokeMethod(java.lang.Object object, java.lang.String methodName)
Invoke a named method whose parameter type matches the object type.static java.lang.Object
invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object arg)
Invoke a named method whose parameter type matches the object type.static java.lang.Object
invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] args)
Invoke a named method whose parameter type matches the object type.static java.lang.Object
invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<?>[] paramTypes)
Invoke a named method whose parameter type matches the object type.static void
invokeSetter(java.lang.Object object, java.lang.String setterName, java.lang.Object arg)
Sets the value of a bean property to an Object.static void
invokeSetter(java.lang.Object object, java.lang.String setterName, java.lang.Object[] args)
Sets the value of a bean property to an Object.static java.lang.Object
invokeStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName)
Invoke a named static method that has no parameters.static java.lang.Object
invokeStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object arg)
Invoke a named static method whose parameter type matches the object type.static java.lang.Object
invokeStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object[] args)
Invoke a named static method whose parameter type matches the object type.static java.lang.Object
invokeStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<?>[] paramTypes)
Invoke a named static method whose parameter type matches the object type.
-
-
-
Method Detail
-
invokeSetter
public static void invokeSetter(java.lang.Object object, java.lang.String setterName, java.lang.Object arg) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Sets the value of a bean property to an Object.- Parameters:
object
- the bean to changesetterName
- the property name or setter method namearg
- use this argument- Throws:
java.lang.NoSuchMethodException
- the no such method exceptionjava.lang.IllegalAccessException
- the illegal access exceptionjava.lang.reflect.InvocationTargetException
- the invocation target exception
-
invokeSetter
public static void invokeSetter(java.lang.Object object, java.lang.String setterName, java.lang.Object[] args) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Sets the value of a bean property to an Object.- Parameters:
object
- the bean to changesetterName
- the property name or setter method nameargs
- use this arguments- Throws:
java.lang.NoSuchMethodException
- the no such method exceptionjava.lang.IllegalAccessException
- the illegal access exceptionjava.lang.reflect.InvocationTargetException
- the invocation target exception
-
invokeGetter
public static java.lang.Object invokeGetter(java.lang.Object object, java.lang.String getterName) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Gets an Object property from a bean.- Parameters:
object
- the beangetterName
- the property name or getter method name- Returns:
- the property value (as an Object)
- Throws:
java.lang.NoSuchMethodException
- the no such method exceptionjava.lang.IllegalAccessException
- the illegal access exceptionjava.lang.reflect.InvocationTargetException
- the invocation target exception
-
invokeGetter
public static java.lang.Object invokeGetter(java.lang.Object object, java.lang.String getterName, java.lang.Object arg) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Gets an Object property from a bean.- Parameters:
object
- the beangetterName
- the property name or getter method namearg
- use this argument- Returns:
- the property value (as an Object)
- Throws:
java.lang.NoSuchMethodException
- the no such method exceptionjava.lang.IllegalAccessException
- the illegal access exceptionjava.lang.reflect.InvocationTargetException
- the invocation target exception
-
invokeGetter
public static java.lang.Object invokeGetter(java.lang.Object object, java.lang.String getterName, java.lang.Object[] args) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Gets an Object property from a bean.- Parameters:
object
- the beangetterName
- the property name or getter method nameargs
- use this arguments- Returns:
- the property value (as an Object)
- Throws:
java.lang.NoSuchMethodException
- the no such method exceptionjava.lang.IllegalAccessException
- the illegal access exceptionjava.lang.reflect.InvocationTargetException
- the invocation target exception
-
invokeMethod
public static java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a named method whose parameter type matches the object type.
- Parameters:
object
- invoke method on this objectmethodName
- get method with this name- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible
-
invokeMethod
public static java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object arg) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a named method whose parameter type matches the object type.
The behaviour of this method is less deterministic than
invokeExactMethod()
. It loops through all methods with names that match and then executes the first it finds with compatible parameters.This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a
Boolean
class would match aboolean
primitive.This is a convenient wrapper for
invokeMethod(Object object,String methodName,Object[] args)
.- Parameters:
object
- invoke method on this objectmethodName
- get method with this namearg
- use this argument- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeMethod
public static java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] args) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a named method whose parameter type matches the object type.
The behaviour of this method is less deterministic than
invokeExactMethod(Object object,String methodName,Object[] args)
. It loops through all methods with names that match and then executes the first it finds with compatible parameters.This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a
Boolean
class would match aboolean
primitive.This is a convenient wrapper for
invokeMethod(Object object,String methodName,Object[] args,Class[] paramTypes)
.- Parameters:
object
- invoke method on this objectmethodName
- get method with this nameargs
- use these arguments - treat null as empty array- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeMethod
public static java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<?>[] paramTypes) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a named method whose parameter type matches the object type.
The behaviour of this method is less deterministic than
invokeExactMethod(Object object,String methodName,Object[] args,Class[] paramTypes)
. It loops through all methods with names that match and then executes the first it finds with compatible parameters.This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a
Boolean
class would match aboolean
primitive.- Parameters:
object
- invoke method on this objectmethodName
- get method with this nameargs
- use these arguments - treat null as empty arrayparamTypes
- match these parameters - treat null as empty array- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeExactMethod
public static java.lang.Object invokeExactMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object arg) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a method whose parameter type matches exactly the object type.
This is a convenient wrapper for
invokeExactMethod(Object object,String methodName,Object[] args)
.- Parameters:
object
- invoke method on this objectmethodName
- get method with this namearg
- use this argument- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeExactMethod
public static java.lang.Object invokeExactMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] args) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a method whose parameter types match exactly the object types.
This uses reflection to invoke the method obtained from a call to
getAccessibleMethod()
.- Parameters:
object
- invoke method on this objectmethodName
- get method with this nameargs
- use these arguments - treat null as empty array- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeExactMethod
public static java.lang.Object invokeExactMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<?>[] paramTypes) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a method whose parameter types match exactly the parameter types given.
This uses reflection to invoke the method obtained from a call to
getAccessibleMethod()
.- Parameters:
object
- invoke method on this objectmethodName
- get method with this nameargs
- use these arguments - treat null as empty arrayparamTypes
- match these parameters - treat null as empty array- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeExactStaticMethod
public static java.lang.Object invokeExactStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<?>[] paramTypes) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a static method whose parameter types match exactly the parameter types given.
This uses reflection to invoke the method obtained from a call to
getAccessibleMethod(Class, String, Class[])
.- Parameters:
objectClass
- invoke static method on this classmethodName
- get method with this nameargs
- use these arguments - treat null as empty arrayparamTypes
- match these parameters - treat null as empty array- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeStaticMethod
public static java.lang.Object invokeStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a named static method that has no parameters.- Parameters:
objectClass
- invoke static method on this classmethodName
- get method with this name- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeStaticMethod
public static java.lang.Object invokeStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object arg) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a named static method whose parameter type matches the object type.
The behaviour of this method is less deterministic than
invokeExactMethod(Object, String, Object[], Class[])
. It loops through all methods with names that match and then executes the first it finds with compatible parameters.This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a
Boolean
class would match aboolean
primitive.This is a convenient wrapper for
invokeStaticMethod(Class objectClass,String methodName,Object[] args)
.- Parameters:
objectClass
- invoke static method on this classmethodName
- get method with this namearg
- use this argument- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeStaticMethod
public static java.lang.Object invokeStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object[] args) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a named static method whose parameter type matches the object type.
The behaviour of this method is less deterministic than
invokeExactMethod(Object object,String methodName,Object[] args)
. It loops through all methods with names that match and then executes the first it finds with compatible parameters.This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a
Boolean
class would match aboolean
primitive.This is a convenient wrapper for
invokeStaticMethod(Class objectClass,String methodName,Object[] args,Class[] paramTypes)
.- Parameters:
objectClass
- invoke static method on this classmethodName
- get method with this nameargs
- use these arguments - treat null as empty array- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeStaticMethod
public static java.lang.Object invokeStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<?>[] paramTypes) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a named static method whose parameter type matches the object type.
The behaviour of this method is less deterministic than
invokeExactStaticMethod(Class objectClass,String methodName,Object[] args,Class[] paramTypes)
. It loops through all methods with names that match and then executes the first it finds with compatible parameters.This method supports calls to methods taking primitive parameters via passing in wrapping classes. So, for example, a
Boolean
class would match aboolean
primitive.- Parameters:
objectClass
- invoke static method on this classmethodName
- get method with this nameargs
- use these arguments - treat null as empty arrayparamTypes
- match these parameters - treat null as empty array- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeExactStaticMethod
public static java.lang.Object invokeExactStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a static method that has no parameters.- Parameters:
objectClass
- invoke static method on this classmethodName
- get method with this name- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeExactStaticMethod
public static java.lang.Object invokeExactStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object arg) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a static method whose parameter type matches exactly the object type.This is a convenient wrapper for
invokeExactStaticMethod(Class objectClass,String methodName,Object[] args)
.- Parameters:
objectClass
- invoke static method on this classmethodName
- get method with this namearg
- use this argument- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
invokeExactStaticMethod
public static java.lang.Object invokeExactStaticMethod(java.lang.Class<?> objectClass, java.lang.String methodName, java.lang.Object[] args) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Invoke a static method whose parameter types match exactly the object types.
This uses reflection to invoke the method obtained from a call to
getAccessibleMethod(Class, String, Class[])
.- Parameters:
objectClass
- invoke static method on this classmethodName
- get method with this nameargs
- use these arguments - treat null as empty array- Returns:
- the value returned by the invoked method
- Throws:
java.lang.NoSuchMethodException
- if there is no such accessible methodjava.lang.reflect.InvocationTargetException
- wraps an exception thrown by the method invokedjava.lang.IllegalAccessException
- if the requested method is not accessible via reflection
-
getAccessibleMethod
public static java.lang.reflect.Method getAccessibleMethod(java.lang.Class<?> clazz, java.lang.String methodName)
Return an accessible method (that is, one that can be invoked via reflection) with given name and a single parameter. If no such method can be found, return
null
. Basically, a convenience wrapper that constructs aClass
array for you.- Parameters:
clazz
- get method from this classmethodName
- get method with this name- Returns:
- the accessible method
-
getAccessibleMethod
public static java.lang.reflect.Method getAccessibleMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?> paramType)
Return an accessible method (that is, one that can be invoked via reflection) with given name and a single parameter. If no such method can be found, return
null
. Basically, a convenience wrapper that constructs aClass
array for you.- Parameters:
clazz
- get method from this classmethodName
- get method with this nameparamType
- taking this type of parameter- Returns:
- the accessible method
-
getAccessibleMethod
public static java.lang.reflect.Method getAccessibleMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?>[] paramTypes)
Return an accessible method (that is, one that can be invoked via reflection) with given name and parameters. If no such method can be found, return
null
. This is just a convenient wrapper forgetAccessibleMethod(Method method)
.- Parameters:
clazz
- get method from this classmethodName
- get method with this nameparamTypes
- with these parameters types- Returns:
- the accessible method
-
getAccessibleMethod
public static java.lang.reflect.Method getAccessibleMethod(java.lang.reflect.Method method)
Return an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. If no such method can be found, return
null
.- Parameters:
method
- the method that we wish to call- Returns:
- the accessible method
-
getAccessibleMethod
public static java.lang.reflect.Method getAccessibleMethod(java.lang.Class<?> clazz, java.lang.reflect.Method method)
Return an accessible method (that is, one that can be invoked via reflection) that implements the specified Method. If no such method can be found, return
null
.- Parameters:
clazz
- The class of the objectmethod
- The method that we wish to call- Returns:
- the accessible method
-
getMatchingAccessibleMethod
public static java.lang.reflect.Method getMatchingAccessibleMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Object[] args, java.lang.Class<?>[] paramTypes)
Find an accessible method that matches the given name and has compatible parameters. Compatible parameters mean that every method parameter is assignable from the given parameters. In other words, it finds a method with the given name that will take the parameters given.
This method is slightly undeterminstic since it loops through methods names and return the first matching method.
This method is used by
invokeMethod(Object object,String methodName,Object[] args,Class[] paramTypes)
.This method can match primitive parameter by passing in wrapper classes. For example, a
Boolean
will match a primitiveboolean
parameter.- Parameters:
clazz
- find method in this classmethodName
- find method with this nameargs
- find method with given argumentsparamTypes
- find method with compatible parameters- Returns:
- the accessible method
-
getMatchingAccessibleMethod
public static java.lang.reflect.Method getMatchingAccessibleMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?>[] paramTypes)
Find an accessible method that matches the given name and has compatible parameters. Compatible parameters mean that every method parameter is assignable from the given parameters. In other words, it finds a method with the given name that will take the parameters given.
This method is slightly undeterminstic since it loops through methods names and return the first matching method.
This method can match primitive parameter by passing in wrapper classes. For example, a
Boolean
will match a primitiveboolean
parameter.- Parameters:
clazz
- find method in this classmethodName
- find method with this nameparamTypes
- find method with compatible parameters- Returns:
- the accessible method
-
clearCache
public static int clearCache()
Clear the method cache.- Returns:
- the number of cached methods cleared
-
-