'Running asm.js with GraalJS in stock JDK 8
I'm very interested on building an app that can run in a JDK8 and that uses a large codebase (tdlib) compiled into asm.js or wasm.
It has to run in systems where a JDK is already installed but it can't be changed. Also to run it on GraalVM is not an option. Also, I have tried it with Nashorn and confirmed that can't eval the js files generated with Emscripten.
I have created a hello world in C as an example and compiled it with:
emcc -c hello.c -o hello.o -s WASM=0
As a result, I obtain hello.js. If I run it with node, it prints "hello world".
If I try to run it with GraalJS,
String content = new String (Files.readAllBytes(Paths.get("hello.js")));
try (Context context = Context.create()) {
Value value = context.eval("js", content);
value.execute();
}
I get the following stack trace:
Aborted(Assertion failed: shell environment detected but not enabled at build time. Add 'shell' to `-s ENVIRONMENT` to enable.)
Exception in thread "main" TypeError: Cannot read property 'RuntimeError' of undefined
at <js> abort(Unnamed:5795:199855-199878)
at <js> assert(Unnamed:4961:167380-167432)
at <js> :program(Unnamed:420:16091-16224)
at org.graalvm.polyglot.Context.eval(Context.java:373)
at com.mycompany.app.App.benchGraalScriptEngine(App.java:86)
at com.mycompany.app.App.main(App.java:68)
How can GraalJS be configured to support the execution? Is there any other consideration to run node-compatible apps into a stock JDK?
Thank you very much for the help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
