A JavaScript implementation that runs on GraalVM. See tags "javascript" and "graalvm". Use this tag for questions regarding running JavaScript code using GraalJS.
Questions tagged [graaljs]
67 questions
0
votes
1 answer
List of all possible error types in JavaScript?
Is there any test suite/list of all possible errors defined by the ECMAScript spec? I am currently writing a JavaScript Runtime and I wanted to have fancy errors so I need to parse them from the engine and handle accordingly.
The engine is Graal.jS,…

yushie
- 13
- 4
0
votes
1 answer
GraalVM JavaScript suffers from "host access" issues
This is done with JavaScrupt interpreter shell of GraalVM CE 21.3.0.
Attempting to access some Java class, such as java.io.File results in this error:
TypeError: Access to host class java.io.File is not allowed or does not exist.
When running the…

Melab
- 2,594
- 7
- 30
- 51
0
votes
1 answer
JavaScript equivalent of Java's String.getBytes(StandardCharsets.UTF_8)
I have the following Java code:
String str = "\u00A0";
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
System.out.println(Arrays.toString(bytes));
This outputs the following byte array:
[-62, -96]
I am trying to get the same result in…

rmf
- 625
- 2
- 9
- 39
0
votes
1 answer
GraalJS - Cannot build ScriptEngine from jar
I'm stuck with a problem involving GraalJS. I'm trying to use it as my JavaScript backend. It works flawlessly while I run in from IntelliJ, but as soon as I export a runnable .jar, it stops working. I've been debugging this issue for a few days…

Mihai Fumarel
- 160
- 1
- 14
0
votes
1 answer
Access complex Javascript object in Java GraalVM
I have a use case where I have a java Map which I convert into ProxyMap, use that map in javascript using context.eval and then create a new object in js (nested json). Now I want to use the object that was created in javascript back in java…

Swapnil Pandey
- 577
- 3
- 8
- 25
0
votes
2 answers
security considerations when using (end-user-defined) JavaScript code inside Java
I am working on a Java project. In it, we want to enable an end-user to define variables which are calculated based on a set of given variables of primitive types or strings. At some point, all given variables are set to specific values, and then…

Kjara
- 2,504
- 15
- 42
0
votes
1 answer
Add js external libs to embedded Camunda with Graalvm js-engine
I'm trying to implement some complex business validation logic via JS in DMN using java embedded camunda with spring boot. To avoid usage of deprecated Nashorn and add ES6 support, I've added to project graal js engine. It seems it works pretty…

Константин
- 11
- 3
0
votes
1 answer
Graalvm unknown identifier when passing java object to js
I am trying to run this Graalvm sample code:
package org.homi.scripting.experimental;
import org.graalvm.polyglot.*;
import java.nio.file.*;
import static java.nio.file.StandardWatchEventKinds.*;
import java.io.File;
import…

omri
- 352
- 2
- 18
0
votes
1 answer
graal js interpreter can't catch custom new Error
try {
if (typeof hostObj['propertyItDoesntHave'] === "undefined") {
throw new Error('first');
}
} catch (e) {
throw new Error('second');
}
For me, this is always crashing with:
org.graalvm.polyglot.PolyglotException: Error: first
at…

theonlygusti
- 11,032
- 11
- 64
- 119
0
votes
2 answers
Why doesn't GraalVM-node find my jar file?
I am trying to get my Node.js code to call my Java code, but when I run
% ls -la /Users/ekolotyluk/.m2/repository/com/fispan/crypto/common/0.1.0-SNAPSHOT/common-0.1.0-SNAPSHOT.jar
-rw-r--r--@ 1 ekolotyluk staff 15218 17 Mar 06:19…

Eric Kolotyluk
- 1,958
- 2
- 21
- 30
0
votes
2 answers
Add binding to static class Math in graal context
I use e.g.
context.getBindings("js").putMember("thing", new Thing(this));
to define a variable for my javascript.
How can I expose Java's Math """"object""""?
I can't do
context.getBindings("js").putMember("math",…

theonlygusti
- 11,032
- 11
- 64
- 119
0
votes
1 answer
Graaljs script engine evaluate on java script string condition
I am using jdk11, graal.js script engine .
We get two json string messages, one has rules/condition(jsRules) and the other one has message. If the value in message satisfies the condition in jsRules it should evaluate to 1 else 0 .
So for example…

Maazen
- 107
- 1
- 14
0
votes
2 answers
Using Symbol.iterator to access iterator of ProxyObject
I have created a Java class that implements the Graal ProxyObject interface. I can access all methods and properties of that class via hasMember(String key) and getMember(String key) methods. But if I use something like
myObject[Symbol.iterator]();…

Sebastian_K
- 19
- 3
0
votes
1 answer
Graal VM components required for a Node calling Java polyglot application
I planning to GraalVM to merge two (services one using Node and other based on Java) with Node as the main entry point language which calls classes/constructs in Java. I was reading about GraalVM but was not able to find below information in…

Vijeenrosh P.W
- 359
- 1
- 3
- 8
0
votes
1 answer
Can you remotely debug Graal.js script running inside Graal JVM?
I am running Java program on Graal JVM (graalvm-ce-java8-19.3.0), and inside that program I run JS scripts via Graal.js engine. I want to configure remote debugging connection for that JS script (not the Java program). I already found that Graal has…

tporeba
- 867
- 10
- 23