Class ConstructorUtils

  • public class ConstructorUtils
    extends Object

    Utility reflection methods focused on constructors, modeled 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 correctly locates these constructors and assigns them as public. However, an IllegalAccessException is thrown if the constructor is invoked.

    ConstructorUtils contains a workaround for this situation: it will attempt to call AccessibleObject.setAccessible(boolean) 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 privileges. If this call fails then a warning will be logged and the method may fail.

    • Constructor Detail

      • ConstructorUtils

        public ConstructorUtils()

        ConstructorUtils instances should NOT be constructed in standard programming. Instead, the class should be used as ConstructorUtils.invokeConstructor(cls, args).

        This constructor is public to permit tools that require a JavaBean instance to operate.