Changes between Version 80 and Version 81 of j2p


Ignore:
Timestamp:
05/30/24 09:40:55 (6 months ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • j2p

    v80 v81  
    5454}}}
    5555
    56 ==== constructs
     56=== constructs
    5757The {{{private}}} keyword is reflected by the python convention of prefixing private fields function names and method names with {{{__}}}.
    5858
     
    6565
    6666
    67 ==== built-in "primitives"
     67=== built-in "primitives"
    6868||=java=||=python=||=remarks=||
    6969||String||str||
     
    7474||Set||set||
    7575
    76 ==== Classes
     76=== Classes
    7777Classes are by default translated using the "Stub" translator which assumes
    7878assumes the class names and modules are identical in Python and Java,
     
    106106There 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.
    107107
    108 ==== Auto Boxing
     108=== Auto Boxing
    109109Autoboxing 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.
    110110
     
    139139All 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.
    140140
    141 ==== @NonNull
     141=== @NonNull
    142142Java 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]}}}.
    143143You 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
     
    170170
    171171
    172 ==== More notes:
     172=== More notes:
    173173* some classes like {{{Arrays}}} or {{{Override}}} do not have a direct python equivalent. calls to static functions in these classes can still be translated.
    174174* 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.