Bug 423578 - Add Missing @NonNull annotation warning
Summary: Add Missing @NonNull annotation warning
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-09 06:31 EST by Ed Willink CLA
Modified: 2013-12-09 08:59 EST (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 Ed Willink CLA 2013-12-09 06:31:39 EST
I've just improved an API to return @NonNull and as a result found that many if guards were redundant, As I removed them I suddenly had a doubt; how can I tell whether a null guard is deliberately or accidentally missing? How do I know to reintroduce the deliberately missing null guards if the invoked code changes to require them again?

Solution: put an explicit @NonNull on each local variable whose non-nullness is exploited.

Suggestion for enforcement. Provide a compiler option to give me a warning for usage of a probably but unannotated non-null variable.

This is just the same as a missing @Override. If the underlying code changes I get a warning. Ditto, if the invoked @NonNull API changes I will get a warning.
Comment 1 Noopur Gupta CLA 2013-12-09 07:20:18 EST
Moving to JDT/Core for comment.