Skip to content

Commit 946e0b7

Browse files
committed
fix the interop code example
1 parent 545d323 commit 946e0b7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/user/JavaInterop.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ The method `Java.addToClasspath()` can be used to programmatically add to the cl
3030

3131
### Polyglot Context
3232
The preferred method of launching GraalVM JavaScript with Java interop support instance is via polyglot `Context`.
33-
For that, a new `org.graalvm.polyglot.Context` is built with the `hostAccess` option set:
33+
For that, a new `org.graalvm.polyglot.Context` is built with the `hostAccess` option allowing access and a `hostClassLookup` predicate defining the Java classes you allow access to:
3434

3535
```java
36-
Context context = Context.newBuilder("js").allowHostAccess(true).build();
36+
Context context = Context.newBuilder("js").
37+
allowHostAccess(HostAccess.ALL).
38+
allowHostClassLookup(className -> true). //allows access to all Java classes
39+
build();
3740
context.eval("js", jsSourceCode);
3841
```
3942

0 commit comments

Comments
 (0)