Skip to content

Commit 6cff59f

Browse files
committed
[GR-27032] Rename the Jython guide to migration guide
PullRequest: graalpython/1365
2 parents 2a998e6 + 091afa6 commit 6cff59f

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
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: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
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.
6-
Thus, GraalVM does not provide full compatibility with these earlier 2.x versions of Jython.
6+
GraalVM does not provide a full compatibility with these earlier 2.x versions of Jython.
7+
Thus, a significant migration step will have to be taken to migrate all your code to Python 3.
78

8-
Nonetheless, there are certain features of Jython's Java integration that we can offer similarly.
9+
For Jython specific features, follow this document to learn about migration to GraalVM's Python runtime.
10+
11+
Note that some features of Jython have a negative impact on runtime performance, and are disabled by default.
12+
To make migration easier, you can enable some features with a command line flag on GraalVM: `--python.EmulateJython`.
13+
14+
## Importing Java Packages
15+
16+
There are certain features of Jython's Java integration that are enabled by default on GraalVM's Python runtime.
917
Here is an example:
1018

1119
>>> import java.awt as awt
@@ -17,23 +25,21 @@ Here is an example:
1725
>>> win.show()
1826

1927
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.
28+
However, on GraalVM only packages in the `java` namespace can be directly imported.
29+
Importing classes from packages outside the `java` namespace also requires the `--python.EmulateJython` option to be active.
2730

31+
Additionally, importing Java packages as Python modules is only supported under very specific circumstances.
2832
For example, this will work:
2933
```python
3034
import java.lang as lang
3135
```
36+
3237
But this will not:
3338
```python
3439
import javax.swing as swing
3540
from javax.swing import *
3641
```
42+
3743
Instead, you will have to import one of the classes you are interested in directly:
3844
```python
3945
import javax.swing.Window as Window

0 commit comments

Comments
 (0)