Changes between Version 32 and Version 33 of j2p


Ignore:
Timestamp:
06/21/23 11:18:56 (17 months ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • j2p

    v32 v33  
    3030The mechanism assumes a fixed mapping from java to python objects, as in the table below. This fixed mapping is needed to ensure the translator can be sure which objects will appear on the python side of the translation, so that proper actions can be taken to further the translation.
    3131
    32 built-in "primitives"
     32==== constructs
     33The {{{private}}} keyword is reflected by the python convention of adding "__" to private fields function names and method names
     34
     35The {{{static}}} keyword results in fields being set in the class definition object.
     36
     37Fields in Java have to be initialized in the __init__ function in the python translation.
     38
     39Overloaded methods can not be handled by default python and need to be handled using an external library {{{multidispatch==0.6.0}}} and result in additional annotations {{{@dispatch(...)}}} in the translated code.
     40
     41==== built-in "primitives"
    3342||=java=||=python=||=remarks=||
    3443||String||str||
     
    3948||Set||set||
    4049
    41 built-in classes
     50==== built-in classes
    4251||=java=||=python=||=remarks=||
    4352||Class||type||
     
    4655If function calls in python deliver a wrong object (not matching the above mapping), the translator has to inject additional code to convert it to the proper object. For example, {{{Map.getKeys()}}} in python would be {{{set(map.keys())}}} where the extra {{{set}}} converts the dict_keys into a proper set.
    4756
    48 Some more notes:
     57==== More notes:
    4958* some classes like {{{Arrays}}} or {{{Override}}} do not have a direct python equivalent. calls to static functions in these classes can still be translated.
    5059* 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.