Class SunReflectionFactoryInstantiator<T>

java.lang.Object
org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator<T>
All Implemented Interfaces:
ObjectInstantiator<T>

@Instantiator(STANDARD) public class SunReflectionFactoryInstantiator<T> extends Object implements ObjectInstantiator<T>
Instantiates an object, WITHOUT calling it's constructor, using internal sun.reflect.ReflectionFactory - a class only available on JDK's that use Sun's 1.4 (or later) Java implementation. This is the best way to instantiate an object without any side effects caused by the constructor - however it is not available on every platform.
See Also:
  • Field Details

    • mungedConstructor

      private final Constructor<T> mungedConstructor
  • Constructor Details

    • SunReflectionFactoryInstantiator

      public SunReflectionFactoryInstantiator(Class<T> type)
  • Method Details

    • newInstance

      public T newInstance()
      Description copied from interface: ObjectInstantiator
      Returns a new instance of an object. The returned object's class is defined by the implementation.
      Specified by:
      newInstance in interface ObjectInstantiator<T>
      Returns:
      A new instance of an object.
    • getJavaLangObjectConstructor

      private static Constructor<Object> getJavaLangObjectConstructor()