Unsafe.defineAnonymousClass no longer exists in Java17!

Attila Szegedi szegedia at gmail.com
Wed Jan 24 17:20:45 UTC 2024


Hi!

Are you experiencing this with Nashorn 15.4 from https://github.com/openjdk/nashorn? This issue is supposed to have been fixed since Nashorn 15.3 in this change https://github.com/openjdk/nashorn/pull/16 according to the changelog: https://github.com/openjdk/nashorn/blob/main/CHANGELOG.md

You say it fails, but it’s encased in a try-catch specifically for this reason. Can you give me a stack trace of how it fails?

Attila.


> On 2024. Jan 24., at 13:02, Luc Chapon <sxilderik at gmail.com> wrote:
> 
> Hello all
> 
> First message here
> 
> We are facing a problem re Nashorn (latest) and java17
> 
> In Context.java, line 330, you try to get a handle to a no longer existent method, Unsafe.defineAnonymousClass
> 
> And fail of course.
> 
> I’m trying to rewrite this part for our own temporary urgent need according to this.
> 
> https://www.oracle.com/java/technologies/javase/17-relnote-issues.html
> core-libs
> ➜ <https://www.oracle.com/java/technologies/javase/17-relnote-issues.html#JDK-8243287> Removal of sun.misc.Unsafe::defineAnonymousClass
> sun.misc.Unsafe::defineAnonymousClass API has been removed in JDK 17. The API replacement is java.lang.invoke.MethodHandles.Lookup::defineHiddenClass and java.lang.invoke.MethodHandles.Lookup::defineHiddenClassWithClassData.
> 
> 
> Are you aware of the problem? Is there a fix already available?
> 
> Thank you!
> 
> Luc Chapon
> ChapsVision
> Suresnes, France
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/nashorn-dev/attachments/20240124/87c85ee6/attachment.htm>


More information about the nashorn-dev mailing list