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.
  • Constructor Details

    • UnsafeAllocator

      public UnsafeAllocator()
  • Method Details

    • newInstance

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

      public static UnsafeAllocator create()
    • assertInstantiable

      static void assertInstantiable(Class<?> c)
      Check if the class can be instantiated by unsafe allocator. If the instance has interface or abstract modifiers throw an UnsupportedOperationException
      Parameters:
      c - instance of the class to be checked