Tuesday, September 28, 2021

Porting From Nashorn: How To Handle JS Multi-Threading on Graalvm

Porting existing JavaScript code from Nashorn to GraalVM can be a challenge. This article focus on a multi-threading issue we got into when we ported SwiftMQ Stream scripts generated from Flow Director.Porting from Nashhorn

Javascript Is Single-Threaded

If you register an asynchronous callback on a Java class and this callback is invoked while you are still within the execution of the same JS script, you have multi-threaded access, even if you immediately schedule the processing of the callback in an event queue. Nashorn doesn’t check this, but GraalVM does and throws an exception. So any script with such callbacks will not work on GraalVM.



from DZone.com Feed https://ift.tt/2ZF6kpf

No comments:

Post a Comment