| java.lang.Object org.apache.commons.beanutils.ConstructorUtils
ConstructorUtils | public class ConstructorUtils (Code) | | Utility reflection methods focussed on constructors, modelled after
MethodUtils .
Known Limitations
Accessing Public Constructors In A Default Access Superclass
There is an issue when invoking public constructors contained in a default access superclass.
Reflection locates these constructors fine and correctly assigns them as public.
However, an IllegalAccessException is thrown if the constructors is invoked.
ConstructorUtils contains a workaround for this situation.
It will attempt to call setAccessible on this constructor.
If this call succeeds, then the method can be invoked as normal.
This call will only succeed when the application has sufficient security privilages.
If this call fails then a warning will be logged and the method may fail.
author: Craig R. McClanahan author: Ralph Schaer author: Chris Audley author: Rey Francois author: Gregor Rayman author: Jan Sorensen author: Robert Burrell Donkin author: Rodney Waldhoff version: $Revision: 555824 $ $Date: 2007-07-13 01:27:15 +0100 (Fri, 13 Jul 2007) $ |
Method Summary | |
public static Constructor | getAccessibleConstructor(Class klass, Class parameterType) Returns a constructor with single argument. | public static Constructor | getAccessibleConstructor(Class klass, Class[] parameterTypes) Returns a constructor given a class and signature. | public static Constructor | getAccessibleConstructor(Constructor ctor) Returns accessible version of the given constructor.
Parameters: ctor - prototype constructor object. | public static Object | invokeConstructor(Class klass, Object arg) Convenience method returning new instance of klazz using a single argument constructor. | public static Object | invokeConstructor(Class klass, Object[] args) Returns new instance of klazz created using the actual arguments args . | public static Object | invokeConstructor(Class klass, Object[] args, Class[] parameterTypes) | public static Object | invokeExactConstructor(Class klass, Object arg) Convenience method returning new instance of klazz using a single argument constructor. | public static Object | invokeExactConstructor(Class klass, Object[] args) Returns new instance of klazz created using the actual arguments args . | public static Object | invokeExactConstructor(Class klass, Object[] args, Class[] parameterTypes) |
getAccessibleConstructor | public static Constructor getAccessibleConstructor(Constructor ctor)(Code) | | Returns accessible version of the given constructor.
Parameters: ctor - prototype constructor object. null if accessible constructor can not be found. See Also: java.lang.SecurityManager |
|
|