Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
GraalVM JS: How I do pass Truffle options via Bindings (Nashorn compat mode) and Context in a Java application?

I'm trying to understand performance of my JavaScript running within a Java application but I can't find a way to pass Truffle options through the Java interfaces like Bindings (when in Nashorn compat mode) and Context.

Specifically, I'm trying to turn on compilation info --engine.TraceCompilation mentioned in: https://www.graalvm.org/22.1/graalvm-as-a-platform/language-implementation-framework/Options/

but all I find are examples like this:

ScriptEngine js = scriptEngineManager.getEngineByName("graal.js");

Bindings bindings = js.getBindings(ScriptContext.ENGINE_SCOPE);

bindings.put("polyglot.js.allowHostAccess", true);
bindings.put("polyglot.js.nashorn-compat", true);

// -------   I want to do something like this: -----------
bindings.put("polyglot.js.engine.TraceCompilation", true); // <-- does not work
//--------------------------------------------------------

This guide mentions the list of options that can be passed this way and none of the Truffle options are listed: https://www.graalvm.org/22.1/reference-manual/js/ScriptEngine/

Note that for legacy reasons I need to use Nashorn compatibility mode to run the JavaScript code.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

as the documentation states, those are language launcher options. You would typically provide them to a launcher like js, node or similar.

$ js --engine.TraceCompilation yourJSFile.js

As you seem to start from Java, you can also provide them to the Java process with system properties (by preprending polyglot and explicitly providing true for boolean options):

$ java -Dpolyglot.engine.TraceCompilation=true yourJavaClass

I don't believe you can provide those options as late as in the bindings of the language, because they should not affect the language but the overall GraalVM system. (this is also why your polyglot.js.engine.TraceCompilation is off; the option has nothing to do with js)

HTH, Christian

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!