New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jdep issue on org.springframework.objenesis.instantiator.sun.UnsafeFactoryInstantiator [SPR-15668] #20227

Closed
spring-issuemaster opened this Issue Jun 15, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

spring-issuemaster commented Jun 15, 2017

rajendra rathore opened SPR-15668 and commented

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


Affects: 4.3.2

Issue Links:

  • #19712 Upgrade to Objenesis 2.5
  • #20159 Upgrade to Objenesis 2.6 for Google App Engine Standard on Java 8 and for better JDK 9 support
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Jun 15, 2017

Juergen Hoeller commented

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.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Jun 16, 2017

rajendra rathore commented

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.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Jun 16, 2017

Juergen Hoeller commented

We're currently repackaging Objenesis 2.5.1 and will be upgrading to Objenesis 2.6 once released (#20159), 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment