Bug 531584 - extend null analysis to allow support for Findbugs DefaultAnnotation
Summary: extend null analysis to allow support for Findbugs DefaultAnnotation
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.8   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-23 06:27 EST by James Nord CLA
Modified: 2022-09-21 17:58 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Nord CLA 2018-02-23 06:27:22 EST
SpotBugs (the successor to Findbugs) does not have a single "NonNullByDefault" annotation.

Rather it provides several different annotations that set defaults for a given type (or catch all) and take an annotation to configure if they are Nullable or nonNull etc.

e.g.
  DefaultAnnotation
  DefaultAnnotationForFields
  DefaultAnnotationForMethods
  DefaultAnnotationForParameters

This is a request to support the Eclipse compiler null check to be more flexible for the defaults.

Even without support for these Findbugs annotations the NonNullByDefault is mostly useless if paramters are going to be Nullable, yet return values are never null.

re: https://javadoc.io/doc/com.github.spotbugs/spotbugs-annotations/3.1.1
Comment 1 Till Brychcy CLA 2018-02-23 16:37:15 EST
(In reply to James Nord from comment #0)
>   DefaultAnnotation
>   DefaultAnnotationForFields
>   DefaultAnnotationForMethods
>   DefaultAnnotationForParameters
> 
What I don't like about these annotations:
- They are not only for NonNull
- We'd have to hardcode the names because of the different targets.


OTOH, I've just implemented bug 518839, which is similar so implementing this wouldn't be hard.

> Even without support for these Findbugs annotations the NonNullByDefault is
> mostly useless if paramters are going to be Nullable, yet return values are
> never null.

With the changes for bug 518839, you can in 4.8 also define multiple NonNullByDefault-like annnotations with DefaultLocation[] value (with different defaults) when using declaration null annotations and use multiple different ones at the same target.
Comment 2 Stephan Herrmann CLA 2018-02-24 04:51:13 EST
Maybe @Andrey has an idea how to bridge this gap :)

Maybe we can open up for the SpotBugs Eclipse plugin to interpret these default annotations on JDT's behalf (which would be strictly an IDE-only solution, since the batch compiler is not pluggable).
Comment 3 Eclipse Genie CLA 2022-09-21 17:58:32 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.