Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365763 - Improve wording of warnings messages for null annotations
Summary: Improve wording of warnings messages for null annotations
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-06 11:26 EST by Deepak Azad CLA
Modified: 2011-12-07 08:28 EST (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Deepak Azad CLA 2011-12-06 11:26:17 EST
I think 'Type mismatch' is a bit odd in the following strings. It should probably be 'Nullness mismatch'.

910 = Type mismatch: required ''@{0} {1}'' but the provided value is null
911 = Type mismatch: required ''@{0} {1}'' but the provided value can be null
912 = Potential type mismatch: required ''@{0} {1}'' but nullness of the provided value is unknown

i.e. the new messages should be
910 = Nullness mismatch: required ''@{0}'' but the provided value is null
911 = Nullness mismatch: required ''@{0}'' but the provided value can be null
912 = Potential Nullness mismatch: required ''@{0}'' but nullness of the provided value is unknown

where {0} is the annotation name. 

While M4 would be ideal, it is also OK to fix this in M5.
Comment 1 Stephan Herrmann CLA 2011-12-06 14:16:41 EST
(In reply to comment #0)
> I think 'Type mismatch' is a bit odd in the following strings. It should
> probably be 'Nullness mismatch'.
> 
> 910 = Type mismatch: required ''@{0} {1}'' but the provided value is null
> 911 = Type mismatch: required ''@{0} {1}'' but the provided value can be null
> 912 = Potential type mismatch: required ''@{0} {1}'' but nullness of the
> provided value is unknown

What's wrong with the message? null is not a legal value for the type
'@NonNull Object' etc. Only provably non-null values are (safely) assignable
to a variable of that type.

Please see bug 186342 comment 110, where I switched from speaking of
null contracts to considering null annotations as an extension of the
type system. That's when the "Type mismatch:" wording got introduced -
intentionally :)
Also the wiki (http://wiki.eclipse.org/JDT_Core/Null_Analysis)
uses this terminology since August. So this is nothing we should change
in a hurry, if at all.
Comment 2 Ayushman Jain CLA 2011-12-06 14:39:12 EST
I also considered this in my review but the reasoning for moving from "contracts" to extension of a type system seemed sound. Also, I believe this was already clarified in discussions between Stephan and markus at ECE '11.
Anyway, definitely *not* for M4 please, whatever you decide :)
Comment 3 Deepak Azad CLA 2011-12-06 14:40:02 EST
(In reply to comment #1)
> Please see bug 186342 comment 110, where I switched from speaking of
> null contracts to considering null annotations as an extension of the
> type system. That's when the "Type mismatch:" wording got introduced -
> intentionally :)
I like your original messages! :-) 
Sure researchers may think of null annotations as an extension of the type system, but would an average Java user also do so, given that Java does not have null-safe types at this point in time? 

- In Java do we have a precedent of '@Someannotation SomeType' being thought of as a different type from 'SomeType'? 
- Can you search for references of 'type' '@Nullable SomeType' in JDT?

> Also the wiki (http://wiki.eclipse.org/JDT_Core/Null_Analysis)
> uses this terminology since August. So this is nothing we should change
> in a hurry, if at all.
Sure, this can be done in M5 also.
Comment 4 Srikanth Sankaran CLA 2011-12-07 04:04:10 EST
This may be splitting hairs: These error messages are not coming from
the eclipse java compiler, but are coming from the annotation processor
for the null family of annotations. It is a different matter that in the
current scenario, the compiler doubles as the annotation processor when
a switch is on.

If the notion of a type constrains the domain and range of values a
typed entity may assume, then @Nullable and @NonNull, by virtue of
further constraining or making express the range, act as modifiers for
the type system. So personally I am comfortable with the current set
of messages.
Comment 5 Markus Keller CLA 2011-12-07 06:45:53 EST
I first agreed that considering nullness as part of a type is not exactly what the JLS considers as a type. But from the view of the nullness annotation processor, the annotations are indeed considered as an extension of the type system, so from that POV, the term "Type mismatch" is fine.

I'm a bit indifferent now, but I'd like to keep the type in the message. If we ever get JSR 308, then the annotation can even show up embedded in the type, e.g. "required '@NonNull List<@NonNull String>' but the provided value is '@NonNull List<String>'".
Comment 6 Deepak Azad CLA 2011-12-07 08:28:45 EST
Given the overwhelming majority in favor of letting things be, closing this as WONTFIX.