|
2 | 2 |
|
3 | 3 | The java2python package can translate any syntactically valid Java source |
4 | 4 | code file. The generated Python code is not guaranteed to run, nor is |
5 | | -guaranteed to be syntatically valid Python. However, java2python works |
| 5 | +guaranteed to be syntactically valid Python. However, java2python works |
6 | 6 | well many cases, and in some of those, it creates perfectly usable and |
7 | 7 | workable Python code. |
8 | 8 |
|
9 | | -The remainder of this page describes how Java language features are |
10 | | -translated into Python constructs. |
11 | | - |
12 | 9 |
|
13 | 10 | ### General Approach |
14 | 11 |
|
@@ -75,22 +72,29 @@ Refer to the note above regarding bit shift right. |
75 | 72 |
|
76 | 73 | #### Basic Types |
77 | 74 |
|
78 | | - byte |
79 | | - short |
80 | | - char |
81 | | - int |
82 | | - long |
83 | | - float |
84 | | - double |
85 | | - boolean |
| 75 | +The basic Java types are mapped to Python types as follows: |
| 76 | + |
| 77 | + byte => int |
| 78 | + short => int |
| 79 | + char => str |
| 80 | + int => int |
| 81 | + long => long |
| 82 | + float => float |
| 83 | + double => float |
| 84 | + boolean => bool |
86 | 85 |
|
87 | 86 | #### Types, Interfaces, Enums |
88 | 87 |
|
89 | 88 | Java classes, interfaces, and enums are translated into Python classes. |
90 | 89 |
|
91 | | -In the case of interfaces, the strategy is configurable. By default, interfaces are translated to classes utilizing the ABCMeta class. The package includes config handlers that can translate to simple classes (inheriting from `object`), or from Zope Interfaces. |
| 90 | +In the case of interfaces, the strategy is configurable. By default, |
| 91 | +interfaces are translated to classes utilizing the ABCMeta class. The package |
| 92 | +includes config handlers that can translate to simple classes (inheriting from |
| 93 | +`object`), or from Zope Interfaces. |
92 | 94 |
|
93 | | -Enums are also translated via a configurable strategy. By default, enumerated values are created as class attributes with string values. The package includes a config handler to create class attributes with integer values. |
| 95 | +Enums are also translated via a configurable strategy. By default, enumerated |
| 96 | +values are created as class attributes with string values. The package |
| 97 | +includes a config handler to create class attributes with integer values. |
94 | 98 |
|
95 | 99 | #### Statements |
96 | 100 |
|
@@ -166,18 +170,18 @@ continue [Identifier] |
166 | 170 |
|
167 | 171 | ##### Annotations |
168 | 172 |
|
169 | | - Annotation |
170 | | - public |
171 | | - protected |
172 | | - private |
173 | | - static |
174 | | - abstract |
175 | | - final |
176 | | - native |
177 | | - synchronized |
178 | | - transient |
179 | | - volatile |
180 | | - strictfp |
| 173 | + Annotation |
| 174 | + public |
| 175 | + protected |
| 176 | + private |
| 177 | + static |
| 178 | + abstract |
| 179 | + final |
| 180 | + native |
| 181 | + synchronized |
| 182 | + transient |
| 183 | + volatile |
| 184 | + strictfp |
181 | 185 |
|
182 | 186 | #### The Rest |
183 | 187 |
|
|
0 commit comments