ObjenesisStd / ObjenesisBase,
providing a cache based on Class keys instead of class names,
and allowing for selective use of the cache.
isWorthTrying(), newInstance(Class, boolean)
| Modifier and Type | Field and Description |
|---|---|
| private final ConcurrentReferenceHashMap | |
| public static final String | IGNORE_OBJENESIS_PROPERTY_NAME
System property that instructs Spring to ignore Objenesis, not even attempting to use it. |
| private final InstantiatorStrategy | |
| private volatile Boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SpringObjenesis(InstantiatorStrategy
the instantiator strategy to use strategy)Create a new |
| Modifier and Type | Method and Description |
|---|---|
| public <T> ObjectInstantiator | getInstantiatorOf(Class<T>
Class to instantiate clazz)Implements org. Will pick the best instantiator for the provided class. |
| public boolean | isWorthTrying()
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. |
| public <T> T | Returns: the new instance (nevernull)the class to create an instance of clazz, boolean whether to use the instantiator cache
(typically useCache)true but can be set to false
e.g. for reloadable classes)Create a new instance of the given class via Objenesis. |
| public <T> T | newInstance(Class<T>
Class to instantiate clazz)Implements org. Will create a new object without any constructor being called |
| protected <T> ObjectInstantiator |
| cache | back to summary |
|---|---|
| private final ConcurrentReferenceHashMap<Class<?>, ObjectInstantiator<?>> cache | |
| IGNORE_OBJENESIS_PROPERTY_NAME | back to summary |
|---|---|
| public static final String IGNORE_OBJENESIS_PROPERTY_NAME 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. | |
| strategy | back to summary |
|---|---|
| private final InstantiatorStrategy strategy | |
| worthTrying | back to summary |
|---|---|
| private volatile Boolean worthTrying | |
| SpringObjenesis | back to summary |
|---|---|
| public SpringObjenesis() Create a new | |
| SpringObjenesis | back to summary |
|---|---|
| public SpringObjenesis(InstantiatorStrategy strategy) Create a new
| |
| getInstantiatorOf | back to summary |
|---|---|
| public <T> ObjectInstantiator Implements org. Doc from org. Will pick the best instantiator for the provided class. If you need to create a lot of
instances from the same class, it is way more efficient to create them from the same
ObjectInstantiator than calling
| |
| isWorthTrying | back to summary |
|---|---|
| public boolean isWorthTrying() 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 | |
| newInstance | back to summary |
|---|---|
| public <T> T newInstance(Class<T> clazz, boolean useCache) Create a new instance of the given class via Objenesis.
| |
| newInstance | back to summary |
|---|---|
| public <T> T newInstance(Class<T> clazz) Implements org. Doc from org. Will create a new object without any constructor being called | |
| newInstantiatorOf | back to summary |
|---|---|
| protected <T> ObjectInstantiator | |