Class JSickoFallbackInstantiatorStrategy

  • All Implemented Interfaces:
    org.objenesis.strategy.InstantiatorStrategy

    public class JSickoFallbackInstantiatorStrategy
    extends org.objenesis.strategy.BaseInstantiatorStrategy
    JSicko composed fallback strategy for classes without default empty constructor.

    The composed fallback strategy supports the following cases:

    If the class is Serializable, it will use Kryo's SerializingInstantiatorStrategy, which (quoting Kryo's documentation) uses Java's built-in serialization mechanism to create an instance. Using this, the class must implement java.io.Serializable and the first zero argument constructor in a super class is invoked.

    If the class is not Serializable, it will default to StdInstantiatorStrategy, which uses JVM specific APIs to create an instance of a class without calling any constructor at all. This is in general dangerous if there is some logic in the constructors that is expected to be called, but there is no alternative in this case.

    • Constructor Detail

      • JSickoFallbackInstantiatorStrategy

        public JSickoFallbackInstantiatorStrategy()
    • Method Detail

      • newInstantiatorOf

        public <T> org.objenesis.instantiator.ObjectInstantiator<T> newInstantiatorOf​(Class<T> type)