Class UnsafeFactoryInstantiator<T>

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

@Instantiator(STANDARD) public class UnsafeFactoryInstantiator<T> extends Object implements ObjectInstantiator<T>
Instantiates an object, WITHOUT calling it's constructor, using sun.misc.Unsafe.allocateInstance(). Unsafe and its methods are implemented by most modern JVMs.
See Also:
  • Field Details

    • unsafe

      private final sun.misc.Unsafe unsafe
    • type

      private final Class<T> type
  • Constructor Details

    • UnsafeFactoryInstantiator

      public UnsafeFactoryInstantiator(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.