Class UnsafeAllocator

java.lang.Object
com.google.gson.internal.UnsafeAllocator

public abstract class UnsafeAllocator extends Object
Do sneaky things to allocate objects without invoking their constructors.
  • Field Details

  • Constructor Details

    • UnsafeAllocator

      public UnsafeAllocator()
  • Method Details

    • newInstance

      public abstract <T> T newInstance(Class<T> c) throws Exception
      Throws:
      Exception
    • assertInstantiable

      private static void assertInstantiable(Class<?> c)
      Asserts that the class is instantiable. This check should have already occurred in ConstructorConstructor; this check here acts as safeguard since trying to use Unsafe for non-instantiable classes might crash the JVM on some devices.
    • create

      private static UnsafeAllocator create()