Package org.apache.bsf.util
Class MethodUtils
java.lang.Object
org.apache.bsf.util.MethodUtils
This file is a collection of reflection utilities for dealing with
methods and constructors.
- Author:
- Sanjiva Weerawarana, Joseph Kesselman
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Constructor
getConstructor
(Class targetClass, Class[] argTypes) Class.getConstructor() finds only the entry point (if any) _exactly_ matching the specified argument types.static Method
static Method
Class.getMethod() finds only the entry point (if any) _exactly_ matching the specified argument types.
-
Constructor Details
-
MethodUtils
public MethodUtils()
-
-
Method Details
-
getConstructor
public static Constructor getConstructor(Class targetClass, Class[] argTypes) throws SecurityException, NoSuchMethodException Class.getConstructor() finds only the entry point (if any) _exactly_ matching the specified argument types. Our implmentation can decide between several imperfect matches, using the same search algorithm as the Java compiler. Note that all constructors are static by definition, so isStaticReference is true.- Throws:
NoSuchMethodException
- if constructor not found.SecurityException
-
getMethod
public static Method getMethod(Class target, String methodName, Class[] argTypes, boolean isStaticReference) throws SecurityException, NoSuchMethodException -
getMethod
public static Method getMethod(Object target, String methodName, Class[] argTypes) throws SecurityException, NoSuchMethodException Class.getMethod() finds only the entry point (if any) _exactly_ matching the specified argument types. Our implmentation can decide between several imperfect matches, using the same search algorithm as the Java compiler. This version emulates the compiler behavior by allowing lookup to be performed against either a class or an instance -- classname.foo() must be a static method call, instance.foo() can invoke either static or instance methods.- Parameters:
target
- object on which call is to be mademethodName
- name of method I'm lookin' forargTypes
- array of argument types of method- Returns:
- the desired method
- Throws:
SecurityException
- if security violationNoSuchMethodException
- if no such method
-