-
Notifications
You must be signed in to change notification settings - Fork 786
Enable Null annotations warnings/errors in IDE and Maven #3906
Enable Null annotations warnings/errors in IDE and Maven #3906
Conversation
Signed-off-by: Stefan Triller <stefan.triller@telekom.de>
Signed-off-by: Stefan Triller <stefan.triller@telekom.de>
Signed-off-by: Stefan Triller <stefan.triller@telekom.de>
@@ -19,6 +19,7 @@ Require-Bundle: org.eclipse.xtext;visibility:=reexport, | |||
org.eclipse.smarthome.model.lazygen;resolution:=optional | |||
Import-Package: com.google.common.base, | |||
com.google.common.collect, | |||
javax.annotation, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should mark it optional, so that it is only required at compile time, but not at runtime.
@@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.xtext;visibility:=reexport, | |||
org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional, | |||
org.eclipse.smarthome.model.lazygen;resolution:=optional, | |||
org.eclipse.xtext.xbase.lib | |||
Import-Package: org.apache.log4j, | |||
Import-Package: javax.annotation, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should mark it optional, so that it is only required at compile time, but not at runtime.
pom.xml
Outdated
</extraClasspathElements> | ||
<compilerArgs> | ||
<arg>-err:+nullAnnot(javax.annotation.Nullable|javax.annotation.Nonnull|org.eclipse.jdt.annotation.NonNullByDefault),+inheritNullAnnot</arg> | ||
<arg>-warn:+null</arg> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace tabs by spaces on this line
Signed-off-by: Stefan Triller <stefan.triller@telekom.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks.
@maggu2810 Are you ok with this solution for the null annotations? Imho it brings a good value as we can more precisely specify our APIs with it now.
I would like to give it a try, add some annotations on the API, remove the annotation stubs in my projects and check if it play well together... One question about the optional import... |
At first I should mention that we are using I just did the following test but I am not sure if it is what you meant: Inside In a binding like the astro binding for example, I can call that method and get a warning if I pass Is that what you wanted to know? |
@triller-telekom Thanks |
How about adding a word to the documentation here: |
I guess first we have to agree on what to use where in #4080 before we write a documentation. |
I started with a summary in the wiki (as @triller-telekom also referenced in his linked comment). |
Enables a warning on a potential Nullpointer access and an Error if a null value is passed to a @nonnull argument
Fixes #3624