java.lang.Object | |
↳ | org.apache.commons.beanutils.ConstructorUtils |
Utility reflection methods focussed on constructors, modelled after MethodUtils
.
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.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a constructor with single argument.
| |||||||||||
Returns accessible version of the given constructor.
| |||||||||||
Returns a constructor given a class and signature.
| |||||||||||
Returns new instance of | |||||||||||
Returns new instance of | |||||||||||
Convenience method returning new instance of | |||||||||||
Convenience method returning new instance of | |||||||||||
Returns new instance of | |||||||||||
Returns new instance of |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Returns a constructor with single argument.
klass | the class to be constructed |
---|---|
parameterType | The constructor parameter type |
Returns accessible version of the given constructor.
ctor | prototype constructor object. |
---|
null
if accessible constructor can not be found.Returns a constructor given a class and signature.
klass | the class to be constructed |
---|---|
parameterTypes | the parameter array |
Returns new instance of klazz
created using the actual arguments args
.
The formal parameter types are inferred from the actual values of args
.
See invokeExactConstructor(Class, Object[], Class[])
for more details.
The signatures should be assignment compatible.
klass | the class to be constructed. |
---|---|
args | actual argument array |
klazz
NoSuchMethodException | If the constructor cannot be found |
---|---|
IllegalAccessException | If an error occurs accessing the constructor |
InvocationTargetException | If an error occurs invoking the constructor |
InstantiationException | If an error occurs instantiating the class |
Returns new instance of klazz
created using constructor
with signature parameterTypes
and actual arguments args
.
The signatures should be assignment compatible.
klass | the class to be constructed. |
---|---|
args | actual argument array |
parameterTypes | parameter types array |
klazz
NoSuchMethodException | if matching constructor cannot be found |
---|---|
IllegalAccessException | thrown on the constructor's invocation |
InvocationTargetException | thrown on the constructor's invocation |
InstantiationException | thrown on the constructor's invocation |
Convenience method returning new instance of klazz
using a single argument constructor.
The formal parameter type is inferred from the actual values of arg
.
See invokeExactConstructor(Class, Object[], Class[])
for more details.
The signatures should be assignment compatible.
klass | the class to be constructed. |
---|---|
arg | the actual argument |
klazz
NoSuchMethodException | If the constructor cannot be found |
---|---|
IllegalAccessException | If an error occurs accessing the constructor |
InvocationTargetException | If an error occurs invoking the constructor |
InstantiationException | If an error occurs instantiating the class |
Convenience method returning new instance of klazz
using a single argument constructor.
The formal parameter type is inferred from the actual values of arg
.
See invokeExactConstructor(Class, Object[], Class[])
for more details.
The signatures should match exactly.
klass | the class to be constructed. |
---|---|
arg | the actual argument |
klazz
NoSuchMethodException | If the constructor cannot be found |
---|---|
IllegalAccessException | If an error occurs accessing the constructor |
InvocationTargetException | If an error occurs invoking the constructor |
InstantiationException | If an error occurs instantiating the class |
Returns new instance of klazz
created using the actual arguments args
.
The formal parameter types are inferred from the actual values of args
.
See invokeExactConstructor(Class, Object[], Class[])
for more details.
The signatures should match exactly.
klass | the class to be constructed. |
---|---|
args | actual argument array |
klazz
NoSuchMethodException | If the constructor cannot be found |
---|---|
IllegalAccessException | If an error occurs accessing the constructor |
InvocationTargetException | If an error occurs invoking the constructor |
InstantiationException | If an error occurs instantiating the class |
Returns new instance of klazz
created using constructor
with signature parameterTypes
and actual arguments
args
.
The signatures should match exactly.
klass | the class to be constructed. |
---|---|
args | actual argument array |
parameterTypes | parameter types array |
klazz
NoSuchMethodException | if matching constructor cannot be found |
---|---|
IllegalAccessException | thrown on the constructor's invocation |
InvocationTargetException | thrown on the constructor's invocation |
InstantiationException | thrown on the constructor's invocation |