Changes between Version 73 and Version 74 of j2p
- Timestamp:
- 05/16/24 10:42:13 (6 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
j2p
v73 v74 44 44 Fields in Java have to be initialized in the __init__ function in the python translation. 45 45 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.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. 47 47 48 48 … … 124 124 ==== @NonNull 125 125 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]}}}. 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 this127 {{{@NonNull String val}}} or {{{@NonNull String f() { ... } }}}. Java primitive types like {{{boolean}}} and {{{int}}} can never be null and do not need @ NonNull128 129 The dependency needed for this is (unfortunately @Nonnullis not built in anymore in the JRE)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 this annotation is not built in anymore in the JRE) 130 130 {{{ 131 131 <dependency> … … 144 144 145 145 {{{#!td style="background: #efe" 146 @ NonNullcan 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". 147 147 }}} 148 148 149 149 {{{#!td style="background: #fee" 150 @ NonNull is NOT inherited by subclasses. Therefore @NonNullhas to be repeated in the derived classes.150 @{{{@NonNull}}} is NOT inherited by subclasses. Therefore @{{{@NonNull}}} has to be repeated in the derived classes. 151 151 }}} 152 152