Skip to content

Commit 062bcd0

Browse files
committed
rename the Jython guide to migration guide
1 parent 1640549 commit 062bcd0

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

docs/user/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The GraalVM team continues to improve the number of passing CPython unittests, a
99
### Can the GraalVM Python runtime replace my Jython use case?
1010

1111
It can, but there are some caveats, like Python code subclassing Java classes or use through the `javax.script.ScriptEngine` not being supported.
12-
See the [Jython Compatibility](Jython.md) guide for details.
12+
See the [Jython Migration](Jython.md) guide for details.
1313

1414
### Do I need to compile and run native modules as LLVM bitcode to use on GraalVM's Python runtime?
1515

docs/user/Jython.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
# Jython Compatibility
1+
# Jython Migration Guide
22

33
Most Jython code that uses Java integration will be based on a
44
stable Jython release, and these only come in Python 2.x versions.
55
GraalVM's Python runtime, in contrast, is only targeting Python 3.x.
66
Thus, GraalVM does not provide full compatibility with these earlier 2.x versions of Jython.
77

8-
Nonetheless, there are certain features of Jython's Java integration that we can offer similarly.
9-
Here is an example:
8+
Thus, a significant migration step will have to be to migrate all your code to
9+
Python 3. For Jython specific features, follow this document to learn about
10+
migration to GraalVM's Python runtime.
11+
12+
Be adviced: some features of Jython have a negative impact on runtime
13+
performance, and thus are disabled by default. To make migration easier, we
14+
enable some features with a command line flag on GraalVM:
15+
`--python.EmulateJython`.
16+
17+
### Importing
18+
There are certain features of Jython's Java integration that we also offer. Here
19+
is an example:
1020

1121
>>> import java.awt as awt
1222
>>> win = awt.Frame()
@@ -16,24 +26,23 @@ Here is an example:
1626
'java.awt.Dimension[width=200,height=200]'
1727
>>> win.show()
1828

19-
This example works exactly the same on both Jython and Python on GraalVM.
20-
Some features of Jython are more expensive at runtime, and thus are hidden behind a
21-
command line flag on GraalVM: `--python.EmulateJython`.
22-
23-
## Import Java Classes
24-
25-
Import statements allow you to import Java classes, but (unlike Jython), only
26-
packages in the `java` namespace can be directly imported.
29+
This example works exactly the same on both Jython and Python on
30+
GraalVM. However, on GraalVM only packages in the `java` namespace can be
31+
directly imported. Importing classes from packages outside `java` namespace also
32+
requires the `--python.EmulateJython` option to be active.
2733

28-
For example, this will work:
29-
```python
34+
Additionally, importing Java packages as Python modules is only supported under
35+
very specific circumstances. This will work:
36+
```
3037
import java.lang as lang
3138
```
39+
3240
But this will not:
3341
```python
3442
import javax.swing as swing
3543
from javax.swing import *
3644
```
45+
3746
Instead, you will have to import one of the classes you are interested in directly:
3847
```python
3948
import javax.swing.Window as Window

0 commit comments

Comments
 (0)