Changes between Version 80 and Version 81 of j2p
- Timestamp:
- 05/30/24 09:40:55 (5 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
j2p
v80 v81 54 54 }}} 55 55 56 === =constructs56 === constructs 57 57 The {{{private}}} keyword is reflected by the python convention of prefixing private fields function names and method names with {{{__}}}. 58 58 … … 65 65 66 66 67 === =built-in "primitives"67 === built-in "primitives" 68 68 ||=java=||=python=||=remarks=|| 69 69 ||String||str|| … … 74 74 ||Set||set|| 75 75 76 === =Classes76 === Classes 77 77 Classes are by default translated using the "Stub" translator which assumes 78 78 assumes the class names and modules are identical in Python and Java, … … 106 106 There are a very few exceptions to the 'no inner classes' rule. If some particular inner classes, particularly constants, are used in very specific translators, these translators may opt to attempt to recognise these and process them separately. One example is the JsonDeserializer (jackson-t package) that recognises use of "com.fasterxml.jackson.databind.JsonDeserializer.None". Check the documentation of the translators for details. 107 107 108 === =Auto Boxing108 === Auto Boxing 109 109 Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes. For example, converting an int to an Integer, a double to a Double, and so on. If the conversion goes the other way, this is called unboxing. 110 110 … … 139 139 All these complications around varargs, including more eg [https://github.com/mrocklin/multipledispatch/issues/72 around dispatching vararg-typed methods] led us to currently not support varargs. 140 140 141 === =@NonNull141 === @NonNull 142 142 Java variables like {{{String val}}} can contain a null value, and functions like {{{String f() { ... } }}} can return null. Therefore they are translated to {{{val:Optional[str]}}} and {{{def f(self)->Optional[str]}}}. 143 143 You can annotate the java code with {{{@NonNull}}} (from {{{org.eclipse.jdt.annotation.NonNull}}}) to indicate the value/return value will not be null, like this … … 170 170 171 171 172 === =More notes:172 === More notes: 173 173 * some classes like {{{Arrays}}} or {{{Override}}} do not have a direct python equivalent. calls to static functions in these classes can still be translated. 174 174 * Different java classes, eg {{{Map}}} {{{AbstractMap}}} and {{{HashMap}}}, may translate to the same python class ({{{map}}}). This can be done because translation is only 1 way.