Bug 399018 - [compiler][null] new SuppressWarnings token "initialize"
Summary: [compiler][null] new SuppressWarnings token "initialize"
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.3   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-24 15:37 EST by Stephan Herrmann CLA
Modified: 2013-01-25 01:56 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2013-01-24 15:37:10 EST
From bug 383371 comment 58
> I have a idea I wanted to share while thinking of EJB-Entities:
> 
> It is basically the empty-Constructor that is used by the framework to
> construct the Entity from the Database. In that case the initialization is
> done by the framework, and we do not need an initialization-check.
> If you create a new Entity in your code you probably use another
> constructor, with parameters to initialize the NonNull-fields. So an
> initialization-check would be useful in the second case, but not in the
> first case.
> 
> I think it would make sense to annotate *Construtors* with a
> @SupressWarning("initialization"). Maybe allow it on the Class itself for
> all constructors. Static fields should still be checked though, since those
> are usually constants.
> 
> If you have no constructor at all (only the default one then), I don't think
> it is too much work to simply add the empty constructor for the annotation
> in that case.

One might argue that we already have @SuppressWarnings("null") which could be applied to the constructors in question.
However, this would obviously hide other relevant warnings. @SuppressWarnings("null") even for an entire class is a no-go, whereas @SuppressWarnings("initialization") on a class might be fair.

BTW, I suggest to shorten the token to "initialize".

Another point to consider: missing initialization of @NonNull fields is ranked as NullSpecViolation, which by default is set to "Error". This means in typical situations the new warning token would only help in conjunction with [x] Suppress optional errors with '@SuppressWarnings'. Is everybody fine with that?

OK, I thinks this is an interesting proposal but we currently can't commit to it.