Changes between Version 52 and Version 53 of j2p


Ignore:
Timestamp:
12/05/23 15:56:44 (11 months ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • j2p

    v52 v53  
    172172The translators generally follow the same inheritance hierarchy as the original classes. So if {{{a.b.P}}} is the parent class of {{{a.b.C}}}, then there usually is a glass {{{tudelft.utilities.j2p.t.a.b.P}}} that is the parent translator of {{{tudelft.utilities.j2p.t.a.b.C}}}. The latter forwards shared translation matters to the parent class as much as possible. A simple example can be seen in {{{tudelft.utilities.j2p.t.java.lang.ArithmeticException}}}, which forwards almost everything to the RuntimeException translator which in turn forwards everything to Exception etc.
    173173
     174Translators should all be public classes, even if the real class is abstract. This is because java will handle calls to abstract classes and interfaces and these will be translated with the translator for that abstract class. For example, if we have
     175{{{
     176List<String> l=...some expression or function call...
     177l.get(0)
     178}}}
     179
     180then l is of type List (the Interface) and l.get is a function in the interface which needs to be translated. Note that in general any type of List can end up in l at runtime, the compiler has to compile it such that the compiled code will work regardless (thus using only functions available in python's equivalent of the List class).
    174181
    175182== Resulting file