Bug 413759 - [compiler][null] "can only be null" message could be better
Summary: [compiler][null] "can only be null" message could be better
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.2   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-25 13:54 EDT by Paul Benedict CLA
Modified: 2013-08-01 10:59 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 Paul Benedict CLA 2013-07-25 13:54:15 EDT
Message: "Null pointer access: The variable x can only be null at this location"

This sentence sounds as if Eclipse must have the variable set to null.

I would rephrase to this:
"Null pointer access: The variable x is always null at this location"

PS: Any other sentences using "can" ?
Comment 1 Srikanth Sankaran CLA 2013-07-26 01:34:05 EDT
(In reply to comment #0)
> Message: "Null pointer access: The variable x can only be null at this
> location"
> 
> This sentence sounds as if Eclipse must have the variable set to null.

IMO, the existing message is clear enough. This is a fairly long standing
diagnostic and we have not heard complaints so far.
Comment 2 Paul Benedict CLA 2013-07-29 11:10:41 EDT
I don't know how many complaints you'll get on this due the triviality. A developer is surely able to figure out the message. However, since Eclipse is stating a fact, the use of "is" over "can" should be preferred. The former is measures clearer than the latter because "can" can imply optionality or a permission based on your background.
Comment 3 Stephan Herrmann CLA 2013-07-31 19:48:09 EDT
I think in combinations as "can only" and "cannot" the statement is already
strong enough.

OTOH, looking at all 131 compiler messages using "can" or "cannot" the vast majority
speaks about things which a programmer is not allowed to write, e.g.:
  "The final field {0}.{1} cannot be assigned"
Compare this to
  "The variable {0} cannot be null at this location"

The semantics of both sentences is indeed different, a difference that is blurred
by the similar wording. I could see that this slightly confuses a user.

I wouldn't generally mind changing:
  can only be null -> is always null
  cannot be null -> is never null

All other uses seem to fall into one of these:
- what can or cannot be written as a legal Java program
- "cannot be resolved"


... but I'm not an English linguist

BTW: I'm surprised nobody ever complained about a variable "being" null or not null.
We're actually cheating about the difference between a variable and the bound value,
but I guess in this matter simplicity trumps dotting the last i for correctness :)
Comment 4 Paul Benedict CLA 2013-08-01 10:59:08 EDT
Thanks for everyone's feedback. I asked my coworker, who has a BS in Writing and MA in English Literature, to look at this ticket and give his opinion. He responded: "My suggestion: 'X is null always at this location.' That's intuitive, and according to Malcom Forbes keep nouns and verbs close for easy reading. When possible, end your sentences with a noun or verb. It gives your language more force."

If you require him to create a Bugzilla account to give first-hand feedback, just let me know.