Questions tagged [graaljs]

A JavaScript implementation that runs on GraalVM. See tags "javascript" and "graalvm". Use this tag for questions regarding running JavaScript code using GraalJS.

67 questions
1
vote
1 answer

StackOverflowError when executing javascript function from java with graalvm

I know its a lot to ask to read such a big post but i hope you do as i really dont have any idea where to start looking for a solution of a problem that I dont even understand. I have a java service on a windows server. This service loads/evaluates…
Michael
  • 1,931
  • 2
  • 8
  • 22
1
vote
0 answers

Graal js Binding access Java api to get value for JS variables

import com.oracle.truffle.js.scriptengine.GraalJSScriptEngine; import org.graalvm.polyglot.Context; import javax.script.Compilable; public class Main { Context.Builder context = Context.newBuilder("js") .allowAllAccess(true) …
1
vote
0 answers

Spring Native fails to start native app after add language:js - Error creating bean with name 'requestMappingHandlerMapping'

i've configured a spring native app which should use graalvm js interpreter to run js code. The app works fine if i build/run it with nashorn interpreter (no native, standard build). If i build it using native profile and GraalVM js interpreter it…
1
vote
0 answers

"Class not found" when runing feature with karate.jar

I have a feature that execute a function from a Java class. So for this reason I use this command to get the class and create a new instance: When I run this feature with maven (mvn test -Dtest...) everything is okay. The problem is when I run this…
1
vote
1 answer

Unsigned right shift >>> in Javascript (GraalJS) vs Java

I have the following Java code: long num = 3482085570325547757; // Discard all but the highest priority 31 bits int result = (int) (num >>> 33); // Returns 405368112 I am trying to do the equivalent in Javascript (using the…
rmf
  • 625
  • 2
  • 9
  • 39
1
vote
1 answer

Use import in javascript being called from Java program through graalvm

I am trying out Graalvm for a use case and I was wondering if I can use import statements in the javascript being called from java. I have tried both: context.eval("js", "import v4 from 'uuid';var o = v4();"); which gives the error Expected an…
Swapnil Pandey
  • 577
  • 3
  • 8
  • 25
1
vote
1 answer

Can't access property of Java Object passed to ScriptEngine

I am passing an object "transformContext" from Java into a Graal.js scriptEngine. The object contains a Hashmap called "dataRecordsByName" which in Java I can usually access with the following line: transformContext.get("dataRecordsByName") I am…
Sam Meehan
  • 53
  • 5
1
vote
1 answer

How can I access properties of Java Objects passed to scriptEngine?

I am passing an object to a scriptEngine using the engine.put() method, and am attempting to retrieve a property of said object using the engine.eval() method. However I can't seem to access them as the object seems to lose its methods when put in…
Sam Meehan
  • 53
  • 5
1
vote
1 answer

How to load js files with multiple functions (of the same name per file) in java/graalvm and invoke functions by file name

I have a server application that loads several script files (for processing specific dataset-fields) at startup. the scripts should be parsed and the "expression"-data of the script should be stored in a map (by column name) so that they can be…
Michael
  • 1,931
  • 2
  • 8
  • 22
1
vote
1 answer

org.graalvm.polyglot.PolyglotException: ReferenceError: document is not defined

I am using Spring boot 2.4.4, JDK 1.8, and created ScriptEngine as shown. Page loaded perfectly for the first time but the second time it throws the exception mentioned below. @Bean public ScriptEngine scriptEngine() { ScriptEngine engine =…
Nitin Jha
  • 1,485
  • 2
  • 10
  • 14
1
vote
1 answer

Not in GraalVM JS runtime?

I'm using the latest (21.0.0) version of GraalVM for JavaScript via Maven in Nashorn compatibility mode. Upon noticing functions like Java.addToClassPath and objects like Polyglot don't exist, I ran the sample code shown here: if (typeof Graal !=…
iamgio
  • 83
  • 9
1
vote
1 answer

Extending Java Classes and Overriding Methods with Overloaded Parameters in ES4X/Graal

I'm trying to extend a Java class in a JavaScript project using ES4X/Graal. The class that I want to extend, has methods with overloeaded parameters that I need to override. I know that you can call a specific Java method by using the square…
1
vote
2 answers

GraalJSEngineFactory could not be instantiated

I am new to Graal. I am referring this document. I am using JDK 11. Below is the code I am trying to run: ScriptEngine graaljsEngine = new ScriptEngineManager().getEngineByName("graal.js"); if (graaljsEngine == null) { …
Maazen
  • 107
  • 1
  • 14
1
vote
2 answers

GraalJs - call constructor of java object

I want to use graal js to provide some scripting extension to my application How can i initialize a new java object on the javascript side? Context ctx = Context ctx =…
user2749903
  • 1,275
  • 1
  • 10
  • 20
1
vote
1 answer

How should I do to get the script output from the GraalJS script engine encoded correctly?

We're processing JSON in our Scala program by executing dynamically generated JavaScript code. This worked fine in Java 8 when using the included Nashorn script engine. We have now switch to Java 13. Nashorn is no longer included, so we included…
Per Norman
  • 13
  • 3