spring-framework / org.springframework.objenesis / SpringObjenesis / newInstance

newInstance

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

Create a new instance of the given class via Objenesis.

Parameters

clazz - the class to create an instance of

useCache - whether to use the instantiator cache (typically true but can be set to false e.g. for reloadable classes)

Exceptions

ObjenesisException - if instance creation failed

Return
the new instance (never null)

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