Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-15668

Jdep issue on org.springframework.objenesis.instantiator.sun.UnsafeFactoryInstantiator

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Works as Designed
    • Affects Version/s: 4.3.2
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      Hi Team,
      I ran the JDep on spring core 4.3.2 version and found that org.springframework.objenesis.instantiator.sun.UnsafeFactoryInstantiator uses sun.misc.Unsafe, and it says that it is JDK internal API (jdk.unsupported). so please let me know your plan for that class.

      Thanks
      Rajendra Rathore

        Issue Links

          Activity

          Hide
          juergen.hoeller Juergen Hoeller added a comment -

          This is a repackaged version of Objenesis (https://github.com/easymock/objenesis/releases) which includes a sun.misc.Unsafe based instantiator but only really uses it on Android and as a fallback on unknown JVMs. For well-known JVMs such as OpenJDK or the Oracle JDK, it uses a sun.reflect.ReflectionFactory based instantiator instead which is supported on JDK 9.

          FWIW, according to the most recent conversations, sun.misc.Unsafe instead is also still supported on JDK 9 for the time being. Which version of jdep are you running there?

          In Spring, we are using Objenesis to create side-effect free proxy instances with CGLIB (i.e. no constructor invocation side effects for proxy instances, just for target instances), and to not enforce default constructors on proxy classes to begin with. If this fails for any reason, we fall back to an invocation of the default constructor on the proxy class, so the use of Objenesis (and therefore the use of ReflectionFactory or Unsafe) is not actually mandatory.

          Show
          juergen.hoeller Juergen Hoeller added a comment - This is a repackaged version of Objenesis ( https://github.com/easymock/objenesis/releases ) which includes a sun.misc.Unsafe based instantiator but only really uses it on Android and as a fallback on unknown JVMs. For well-known JVMs such as OpenJDK or the Oracle JDK, it uses a sun.reflect.ReflectionFactory based instantiator instead which is supported on JDK 9. FWIW, according to the most recent conversations, sun.misc.Unsafe instead is also still supported on JDK 9 for the time being. Which version of jdep are you running there? In Spring, we are using Objenesis to create side-effect free proxy instances with CGLIB (i.e. no constructor invocation side effects for proxy instances, just for target instances), and to not enforce default constructors on proxy classes to begin with. If this fails for any reason, we fall back to an invocation of the default constructor on the proxy class, so the use of Objenesis (and therefore the use of ReflectionFactory or Unsafe ) is not actually mandatory.
          Hide
          rarathore rajendra rathore added a comment -

          I saw the latest version of objenesis and they remove that file, so just want to check which version of objenesis we are using it.

          Show
          rarathore rajendra rathore added a comment - I saw the latest version of objenesis and they remove that file, so just want to check which version of objenesis we are using it.
          Hide
          juergen.hoeller Juergen Hoeller added a comment -

          We're currently repackaging Objenesis 2.5.1 and will be upgrading to Objenesis 2.6 once released (SPR-15600), probably in time for our 5.0 GA and 4.3.10 releases.

          As far as I can see, UnsafeFactoryInstantiator is still around: https://github.com/easymock/objenesis/blob/master/main/src/main/java/org/objenesis/instantiator/sun/UnsafeFactoryInstantiator.java

          Note that the jdeps tool just gives indications. Conditional use of Unsafe as a fallback code path on older / third-party JDKs does not matter as long as it's not being used on OpenJDK 9 and Oracle JDK 9. In fact, even on the latter, Unsafe remains effectively supported for the time being.

          Show
          juergen.hoeller Juergen Hoeller added a comment - We're currently repackaging Objenesis 2.5.1 and will be upgrading to Objenesis 2.6 once released ( SPR-15600 ), probably in time for our 5.0 GA and 4.3.10 releases. As far as I can see, UnsafeFactoryInstantiator is still around: https://github.com/easymock/objenesis/blob/master/main/src/main/java/org/objenesis/instantiator/sun/UnsafeFactoryInstantiator.java Note that the jdeps tool just gives indications. Conditional use of Unsafe as a fallback code path on older / third-party JDKs does not matter as long as it's not being used on OpenJDK 9 and Oracle JDK 9. In fact, even on the latter, Unsafe remains effectively supported for the time being.

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              rarathore rajendra rathore
              Last updater:
              Juergen Hoeller
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                5 weeks, 6 days ago