3
3
Most Jython code that uses Java integration will be based on a
4
4
stable Jython release, and these only come in Python 2.x versions.
5
5
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.
7
8
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.
9
+ For Jython specific features, follow this document to learn about migration to GraalVM's Python runtime.
11
10
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 ` .
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 ` .
16
13
17
- ### Importing
18
- There are certain features of Jython's Java integration that we also offer. Here
19
- is an example:
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.
17
+ Here is an example:
20
18
21
19
>>> import java.awt as awt
22
20
>>> win = awt.Frame()
@@ -26,14 +24,13 @@ is an example:
26
24
'java.awt.Dimension[width=200,height=200]'
27
25
>>> win.show()
28
26
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.
27
+ This example works exactly the same on both Jython and Python on GraalVM.
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.
33
30
34
- Additionally, importing Java packages as Python modules is only supported under
35
- very specific circumstances. This will work:
36
- ```
31
+ Additionally, importing Java packages as Python modules is only supported under very specific circumstances.
32
+ For example, this will work:
33
+ ``` python
37
34
import java.lang as lang
38
35
```
39
36
0 commit comments