Class ConstructorUtils


  • public class ConstructorUtils
    extends Object

    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.

    Since:
    2.5
    Version:
    $Id: ConstructorUtils.java 1056863 2011-01-09 02:00:25Z niallp $