3 ms·
My point is that you can load GraalVM into an already running process using JNI and access objects that way. JNI isn't a great API by any means but it works and
by mike_hearn 9y ago
My point is that you can load GraalVM into an already running process using JNI and access objects that way. JNI isn't a great API by any means but it works and there are tools to bind to it. It isn't new and I don't think GraalVM without Substrate or Sulong innovates in this area.
So if you wanted to run JavaScript using GraalJS, from C, you would link against libjvm, use JNI to initialise the VM with Graal as the JIT compiler (there's a special flag for this), and then use the Polyglot API via JNI.
To bind from JavaScript to Polyglot without having Graal be the host would presumably require you to write a V8 extension that then loads the JVM using JNI and proxies back and forth. I think there are projects that do this already. But you wouldn't get the performance or convenience improvements than Graal/Truffle are pioneering.
In the end though, embedding the JVM this way - at least for node apps - would not be better or more efficient than using their node implementation, but ignoring things like performance and debuggability the results are presumably identical unless your code depends on an implementation detail of V8. So I don't get why you'd do that.