Skip to content

Commit 927e1dc

Browse files
committed
[GR-2243] Update documentation about Java/host interoperability with native images
* Fixes #1853.
1 parent d5e6cc9 commit 927e1dc

File tree

5 files changed

+19
-13
lines changed

5 files changed

+19
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ executable. This means that you don't need a JVM installed on your system to
6060
use it. The advantage of the native configuration is that it starts about as
6161
fast as MRI, it may use less memory, and it becomes fast in less time. The
6262
disadvantage of the native configuration is that you can't use Java tools like
63-
VisualVM, you can't use Java interoperability, and *peak performance may be
63+
VisualVM, it is less convenient for Java interoperability, and *peak performance may be
6464
lower than on the JVM*. The native configuration is used by default, but you
6565
can also request it using `--native`. To use polyglot programming with the
6666
*native* configuration, you need to use the `--polyglot` flag. To check you
@@ -69,7 +69,7 @@ are using the *native* configuration, `ruby --version` should mention
6969

7070
TruffleRuby can also be used in the *JVM* configuration, where it runs as a
7171
normal Java application on the JVM, as any other Java application would. The
72-
advantage of the JVM configuration is that you can use Java interoperability,
72+
advantage of the JVM configuration is that you can use Java interoperability easily,
7373
and *peak performance may be higher than the native configuration*. The
7474
disadvantage of the JVM configuration is that it takes much longer to start and
7575
to get fast, and may use more memory. The JVM configuration is requested using

doc/contributor/native-image.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ The disadvantages of the Native Image version of TruffleRuby are:
100100

101101
* It has lower peak performance, as the GC is simpler and some optimisations
102102
such as compressed ordinary object pointers (OOPS) are not yet available.
103-
* You can't use Java interoperability.
104103
* You can't use standard Java tools like VisualVM.
104+
* Java interoperability works in the native configuration but requires more setup.
105+
First, only for classes loaded in the image can be accessed.
106+
You can add more classes by compiling a native image including TruffleRuby.
107+
See https://www.graalvm.org/docs/reference-manual/embed/#build-native-images-from-polyglot-applications for details.
105108

106109
So the native version may not be appropriate for all uses.
107110

doc/user/compatibility.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,15 @@ extensions to Ruby.
291291

292292
## Features not yet supported in native configuration
293293

294-
* Java interop
295-
296294
Running TruffleRuby in the native configuration is mostly the same as running
297295
on the JVM. There are differences in resource management, as both VMs use
298296
different garbage collectors. But, functionality-wise, they are essentially on
299-
par with one another. The big difference is support for Java interop, which
300-
currently relies on reflection. TruffleRuby's implementation of Java interop
301-
does not work with the GraalVM Native Image Generator's limited support for
302-
runtime reflection.
297+
par with one another.
298+
299+
Java interoperability works in the native configuration but requires more setup.
300+
First, only for classes loaded in the image can be accessed.
301+
You can add more classes by compiling a native image including TruffleRuby.
302+
See https://www.graalvm.org/docs/reference-manual/embed/#build-native-images-from-polyglot-applications for details.
303303

304304
## Spec Completeness
305305

doc/user/deploying.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ JVM installed on your system to use it. The advantage of the native
1818
configuration is that it starts about as fast as MRI, it may use less memory,
1919
and it becomes fast in less time than the *JVM* configuration. The
2020
disadvantage of the native configuration is that you can't use Java tools like
21-
VisualVM, you can't use Java interoperability, and *peak performance may be
21+
VisualVM, it is less convenient for Java interoperability, and *peak performance may be
2222
lower than on the JVM*. The native configuration is used by default, but you
2323
can also request it using `--native`. To use polyglot programming with the
2424
*native* configuration, you need to use the `--polyglot` flag.
2525

2626
TruffleRuby can also be used in the *JVM* configuration, where it runs as a
2727
normal Java application on the JVM, as any other Java application would. The
28-
advantage of the JVM configuration is that you can use Java interoperability, and
28+
advantage of the JVM configuration is that you can use Java interoperability easily, and
2929
*peak performance may be higher than the native configuration*. The disadvantage
3030
of the JVM configuration is that it takes much longer to start and to get fast,
3131
and may use more memory. The JVM configuration is requested using `--jvm`.

doc/user/polyglot.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,11 @@ converted to boolean if possible or considered to be true.
147147
## Accessing Java objects
148148

149149
TruffleRuby's Java interop interface is similar to the interface from the
150-
Nashorn JavaScript implementation, as also implemented by Graal.js. It's only
151-
available in JVM mode (`--jvm`).
150+
Nashorn JavaScript implementation, as also implemented by Graal.js.
151+
152+
It is easier to use Java interop in JVM mode (`--jvm`).
153+
Java interop is also supported in native mode but requires more setup.
154+
See https://www.graalvm.org/docs/reference-manual/embed/#build-native-images-from-polyglot-applications for details.
152155

153156
`Java.type('name')` returns a Java class object, given a name such as
154157
`java.lang.Integer` or `int[]`. With the class object, `.new` will create an

0 commit comments

Comments
 (0)