Changes between Version 73 and Version 74 of j2p


Ignore:
Timestamp:
05/16/24 10:42:13 (6 months ago)
Author:
wouter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • j2p

    v73 v74  
    4444Fields in Java have to be initialized in the __init__ function in the python translation.
    4545
    46 Overloaded methods can not be handled by default python and need to be handled using an external library {{{plum-dispatch==2.2.2}}} and result in additional {{{@dispatch}}} annotations  in the translated code. If you use overloading, you need to have plum installed to run your code. Check also the @NonNull section.
     46Overloaded methods can not be handled by default python and need to be handled using an external library {{{plum-dispatch==2.2.2}}} and result in additional {{{@dispatch}}} annotations  in the translated code. If you use overloading, you need to have plum installed to run your code. Check also the #@NonNull section.
    4747
    4848
     
    124124==== @NonNull
    125125Java 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]}}}.
    126 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
    127 {{{@NonNull String val}}} or {{{@NonNull String f() { ... } }}}. Java primitive types like {{{boolean}}} and {{{int}}} can never be null and do not need @NonNull
    128 
    129 The dependency needed for this is (unfortunately @Nonnull is not built in anymore in the JRE)
     126You 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
     127{{{@NonNull String val}}} or {{{@NonNull String f() { ... } }}}. Java primitive types like {{{boolean}}} and {{{int}}} can never be null and do not need @{{{@NonNull}}}
     128
     129The dependency needed for this is (unfortunately this annotation is not built in anymore in the JRE)
    130130{{{
    131131<dependency>
     
    144144
    145145{{{#!td style="background: #efe"
    146 @NonNull can be used by the java compiler to do extra checks on your code. Eclipse uses this annotation by default, but you may need to enable or customize it in Preferences/Java/Compiler/Errors/Warnings and scroll down to "Null Analysis".
     146@{{{@NonNull}}} can be used by the java compiler to do extra checks on your code. Eclipse uses this annotation by default, but you may need to enable or customize it in Preferences/Java/Compiler/Errors/Warnings and scroll down to "Null Analysis".
    147147}}}
    148148
    149149{{{#!td style="background: #fee"
    150 @NonNull is NOT inherited by subclasses. Therefore @NonNull has to be repeated in the derived classes.
     150@{{{@NonNull}}} is NOT inherited by subclasses. Therefore @{{{@NonNull}}} has to be repeated in the derived classes.
    151151}}}
    152152