spring-framework / org.springframework.objenesis / SpringObjenesis

SpringObjenesis

open class SpringObjenesis : Objenesis

Spring-specific variant of ObjenesisStd / ObjenesisBase, providing a cache based on Class keys instead of class names, and allowing for selective use of the cache.

Author
Juergen Hoeller

Since
4.2

See Also
#isWorthTrying()#newInstance(Class, boolean)

Constructors

<init>

SpringObjenesis()

Create a new SpringObjenesis instance with the standard instantiator strategy.

SpringObjenesis(strategy: InstantiatorStrategy)

Create a new SpringObjenesis instance with the given standard instantiator strategy.

Properties

IGNORE_OBJENESIS_PROPERTY_NAME

static val IGNORE_OBJENESIS_PROPERTY_NAME: String

System property that instructs Spring to ignore Objenesis, not even attempting to use it. Setting this flag to "true" is equivalent to letting Spring find out that Objenesis isn't working at runtime, triggering the fallback code path immediately: Most importantly, this means that all CGLIB AOP proxies will be created through regular instantiation via a default constructor.

Functions

getInstantiatorOf

open fun <T : Any> getInstantiatorOf(clazz: Class<T>): ObjectInstantiator<T>

isWorthTrying

open fun isWorthTrying(): Boolean

Return whether this Objenesis instance is worth trying for instance creation, i.e. whether it hasn't been used yet or is known to work.

If the configured Objenesis instantiator strategy has been identified to not work on the current JVM at all or if the "spring.objenesis.ignore" property has been set to "true", this method returns false.

newInstance

open fun <T : Any> newInstance(clazz: Class<T>, useCache: Boolean): T

Create a new instance of the given class via Objenesis.

open fun <T : Any> newInstance(clazz: Class<T>): T