org.springframework.objenesis

## Class SpringObjenesis

- java.lang.Object
- - org.springframework.objenesis.SpringObjenesis

- All Implemented Interfaces:
    org.springframework.objenesis.Objenesis

      public class SpringObjenesis
      extends Object
      implements org.springframework.objenesis.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.
  Since:
    4.2
  Author:
    Juergen Hoeller
  See Also:
    `isWorthTrying()`, `newInstance(Class, boolean)`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `IGNORE_OBJENESIS_PROPERTY_NAME` System property that instructs Spring to ignore Objenesis, not even attempting to use it.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SpringObjenesis()` Create a new `SpringObjenesis` instance with the standard instantiator strategy.
    `SpringObjenesis(org.springframework.objenesis.strategy.InstantiatorStrategy strategy)` Create a new `SpringObjenesis` instance with the given standard instantiator strategy.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> org.springframework.objenesis.instantiator.ObjectInstantiator<T>` | `getInstantiatorOf(Class<T> clazz)`
    `boolean` | `isWorthTrying()` Return whether this Objenesis instance is worth trying for instance creation, i.e.
    `<T> T` | `newInstance(Class<T> clazz)`
    `<T> T` | `newInstance(Class<T> clazz, boolean useCache)` Create a new instance of the given class via Objenesis.
    `protected <T> org.springframework.objenesis.instantiator.ObjectInstantiator<T>` | `newInstantiatorOf(Class<T> clazz)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### IGNORE_OBJENESIS_PROPERTY_NAME

          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.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SpringObjenesis

          public SpringObjenesis()

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

    - #### SpringObjenesis

          public SpringObjenesis(org.springframework.objenesis.strategy.InstantiatorStrategy strategy)

      Create a new `SpringObjenesis` instance with the given standard instantiator strategy.
      Parameters:
        `strategy` - the instantiator strategy to use

  - ### Method Detail

    - #### isWorthTrying

          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 `false`.

    - #### newInstance

          public <T> T newInstance(Class<T> clazz,
                                   boolean useCache)

      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)
      Returns:
        the new instance (never `null`)
      Throws:
        `ObjenesisException` - if instance creation failed

    - #### newInstance

          public <T> T newInstance(Class<T> clazz)

      Specified by:
        `newInstance` in interface `org.springframework.objenesis.Objenesis`

    - #### getInstantiatorOf

          public <T> org.springframework.objenesis.instantiator.ObjectInstantiator<T> getInstantiatorOf(Class<T> clazz)

      Specified by:
        `getInstantiatorOf` in interface `org.springframework.objenesis.Objenesis`

    - #### newInstantiatorOf

          protected <T> org.springframework.objenesis.instantiator.ObjectInstantiator<T> newInstantiatorOf(Class<T> clazz)