[jira] [Commented] (LANG-1598) Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected NullPointerExceptions
[ https://issues.apache.org/jira/browse/LANG-1598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17751797#comment-17751797 ] Jens Dietrich commented on LANG-1598: - A quick update. Our [tool|https://github.com/jensdietrich/null-annotation-inference] has been used successfully on a few projects, resulting in the addition of annotations in guava ([https://github.com/google/guava/issues/6510] ) and spring ([https://github.com/spring-projects/spring-framework/pull/29150]) , with an additional issue still open in errorprone ([https://github.com/google/error-prone/issues/3792]) . A paper published at ECOOP'23 describing the algorithm can be found here: [https://drops.dagstuhl.de/opus/volltexte/2023/18203/pdf/LIPIcs-ECOOP-2023-10.pdf] . > Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected > NullPointerExceptions > -- > > Key: LANG-1598 > URL: https://issues.apache.org/jira/browse/LANG-1598 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* >Affects Versions: 3.11 >Reporter: Alexander Guril >Priority: Major > Labels: newbie > Time Spent: 20m > Remaining Estimate: 0h > > Use the javax.annotation-API for Null-Analysis to avoid NPEs. > {code:XML} > > > com.google.code.findbugs > jsr305 > 3.0.2 > > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (LANG-1598) Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected NullPointerExceptions
[ https://issues.apache.org/jira/browse/LANG-1598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17484903#comment-17484903 ] Jens Dietrich commented on LANG-1598: - I might be able to help here. I have developed a tool that infers and injects annotations. Only @Nullable annotations are inferred and added to the code (via manipulating the ASTs), the default assumption is that both arguments and returns are @NonNull. This is consistent with the approach used by the [infer-eradicate checker|https://fbinfer.com/docs/next/checker-eradicate/]. The tool performs the following steps: # tests are executed with an agent that logs null usage in arguments and returns, the respective logs are recorded in json files. # a lightweight bytecode analysis is then used to detect negative tests, i.e. tests designed to trigger abnormal behaviour, recognised by using an exception oracle. Example: a test containing assertThrows(IllegalArgumentException.class,() -> foo(null)) would not be used to infer a @Nullable annotation for the foo argument as this tests a precondition that the argument must not be null. # then @Nullable annotations are propagated to overriding (for arguments) or overridden (for returns) methods to comply with liskovs substitution principle (LSP). There are a few parameters that can be adjusted: Firstly, by default, JSR305 annotations are used, but this can be changed (to some semantically equivalent @Nullable annotation – there is an abstraction in the tool that defines the annotations and the dependency to be added to the pom). Secondly, which test cases should be used? The obvious choice is the project itself, but it is also possible to use a wider set from downstream clients such as other commons projects. Also, the tool currently does not annotate fields, only method signatures. I plan to add this feature in the future. Finally, I wonder what kind of provenance the project would expect or require. For instance, should there be a comment next to each inferred annotation stating how it has been inferred? Or is a standalone report sufficient? The tool itself is not yet open-source, for the simple reason as this may complicate the publication process (I am an academic, but the project is actually sponsored by a gift from Oracle Labs Australia). I could open-source this now if this turns out to be a showstopper though. I am keen to get some feedback. I thought it might be better to have a discussion before creating a PR out of the blue. > Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected > NullPointerExceptions > -- > > Key: LANG-1598 > URL: https://issues.apache.org/jira/browse/LANG-1598 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* >Affects Versions: 3.11 >Reporter: Alexander Guril >Priority: Major > Labels: newbie > Time Spent: 20m > Remaining Estimate: 0h > > Use the javax.annotation-API for Null-Analysis to avoid NPEs. > {code:XML} > > > com.google.code.findbugs > jsr305 > 3.0.2 > > {code} -- This message was sent by Atlassian Jira (v8.20.1#820001)
[jira] [Commented] (LANG-1598) Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected NullPointerExceptions
[ https://issues.apache.org/jira/browse/LANG-1598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17247551#comment-17247551 ] Caleb Cushing commented on LANG-1598: - I might be willing to supply a patch/PR for the classes I need something from. If you decide to use the checker framework instead of jetbrains there are some additional annotations that it looks like should be provided, `@AnnotatedFor` > Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected > NullPointerExceptions > -- > > Key: LANG-1598 > URL: https://issues.apache.org/jira/browse/LANG-1598 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* >Affects Versions: 3.11 >Reporter: Alexander Guril >Priority: Major > Labels: newbie > Time Spent: 20m > Remaining Estimate: 0h > > Use the javax.annotation-API for Null-Analysis to avoid NPEs. > {code:XML} > > > com.google.code.findbugs > jsr305 > 3.0.2 > > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (LANG-1598) Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected NullPointerExceptions
[ https://issues.apache.org/jira/browse/LANG-1598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17247546#comment-17247546 ] Caleb Cushing commented on LANG-1598: - these days jetbrains annotations should be fine, most frameworks seem to support multiple ones since the javax ones don't all work anymore on the latest version of java. I came here because I've been playing with using the Checker Framework, and Checker says I can't pass `null` to `BooleanUtils.toBoolean` which explicitly states in the documentation that null is recognized as false. As far as this being huge, maybe this could be done 1 class at a time? with periodic releases including said work. It doesn't all have to be done for some of it to be done. > Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected > NullPointerExceptions > -- > > Key: LANG-1598 > URL: https://issues.apache.org/jira/browse/LANG-1598 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* >Affects Versions: 3.11 >Reporter: Alexander Guril >Priority: Major > Labels: newbie > Time Spent: 20m > Remaining Estimate: 0h > > Use the javax.annotation-API for Null-Analysis to avoid NPEs. > {code:XML} > > > com.google.code.findbugs > jsr305 > 3.0.2 > > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (LANG-1598) Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected NullPointerExceptions
[ https://issues.apache.org/jira/browse/LANG-1598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17183753#comment-17183753 ] Julian Reschke commented on LANG-1598: -- In Jackrabbit Oak, we moved away from javax.annotation (to Jetbrains). You may want to look at OAK-7511. > Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected > NullPointerExceptions > -- > > Key: LANG-1598 > URL: https://issues.apache.org/jira/browse/LANG-1598 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* >Affects Versions: 3.11 >Reporter: Alexander Guril >Priority: Major > Labels: newbie > Time Spent: 20m > Remaining Estimate: 0h > > Use the javax.annotation-API for Null-Analysis to avoid NPEs. > {code:XML} > > > com.google.code.findbugs > jsr305 > 3.0.2 > > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (LANG-1598) Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected NullPointerExceptions
[ https://issues.apache.org/jira/browse/LANG-1598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17183732#comment-17183732 ] Jin Xu commented on LANG-1598: -- Agreed this idea, but it is a HUGE work if we want to add NotNull and Nullable to all public functions in commons-lang. Also I'd prefer using jetbrains Annotations {code:java} org.jetbrains annotations 20.0.0 provided {code} for example. Well it might not be politely but I really doubt any java codes from google people. I had a bad experience in handling a really awful google java repo, so I just, don't think google people can write normal java codes. > Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected > NullPointerExceptions > -- > > Key: LANG-1598 > URL: https://issues.apache.org/jira/browse/LANG-1598 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* >Affects Versions: 3.11 >Reporter: Alexander Guril >Priority: Major > Labels: newbie > Time Spent: 20m > Remaining Estimate: 0h > > Use the javax.annotation-API for Null-Analysis to avoid NPEs. > {code:XML} > > > com.google.code.findbugs > jsr305 > 3.0.2 > > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (LANG-1598) Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected NullPointerExceptions
[ https://issues.apache.org/jira/browse/LANG-1598?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17177754#comment-17177754 ] Michael Osipov commented on LANG-1598: -- NPEs should be anyway avoided by rejecting null values with the {{Validate}} class. > Use JSR-305 (javax.annotation) for Null-Analysis to avoid unexpected > NullPointerExceptions > -- > > Key: LANG-1598 > URL: https://issues.apache.org/jira/browse/LANG-1598 > Project: Commons Lang > Issue Type: Improvement > Components: lang.* >Affects Versions: 3.11 >Reporter: Alexander Guril >Priority: Major > Labels: newbie > Time Spent: 20m > Remaining Estimate: 0h > > Use the javax.annotation-API for Null-Analysis to avoid NPEs. > {code:XML} > > > com.google.code.findbugs > jsr305 > 3.0.2 > > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)