-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
27 lines (21 loc) · 768 Bytes
/
Test.java
File metadata and controls
27 lines (21 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;
import java.util.function.IntSupplier;
public class Test {
public static void main(String[] args) {
Context polyglot = Context.newBuilder("js").allowAllAccess(true).build();
// when reflection configuration is provided
// ./testJVM.sh and ./testSubstrate.sh work as intended
polyglot.getBindings("js").putMember("func", new IntSupplier() {
@Override
public int getAsInt() {
return 3;
}
});
Value val = polyglot.eval("js", "func()");
if (val.asInt() == 3)
System.out.println("This works!");
else
System.out.println("Something is wrong!");
}
}