Summary: | [compiler][null]redundant null check not caught by warnings checker | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Jon Stevens <latchkey> |
Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> |
Status: | VERIFIED WORKSFORME | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | amj87.iitr, Olivier_Thomann, satyam.kandula, stephan.herrmann |
Version: | 3.7 | ||
Target Milestone: | 3.7 M6 | ||
Hardware: | Macintosh | ||
OS: | Mac OS X - Carbon (unsup.) | ||
Whiteboard: |
Description
Jon Stevens
2011-03-02 13:50:15 EST
I don't see this problem on either 3.6.2 or 3.7 latest I build. Though it does exist on 3.6.1. Since it now seems fixed, closing this as WORKSFORME. While trying to find the bug by which this issue was fixed I couldn't even reproduce in any version I tried. So, WORKSFORME, seems to be the correct resolution after all. BTW: this is the full source I used: public class Bug { private Foo getFoo(Var vo) { Foo ack; switch (vo.getBlah()) { default: break; } ack.setBoo(vo == null ? null : vo.getBoo()); return ack; } class Foo { void setBoo(String s) {} } class Var{ int getBlah() { return 0; } String getBoo() { return ""; } } } This invocation: $ java -jar ecj-3.6.1.jar -warn:+null Bug.java Gives these problems: ---------- 1. WARNING in Bug.java (at line 2) private Foo getFoo(Var vo) { ^^^^^^^^^^^^^^ The method getFoo(Bug.Var) from the type Bug is never used locally ---------- 2. ERROR in Bug.java (at line 8) ack.setBoo(vo == null ? null : vo.getBoo()); ^^^ The local variable ack may not have been initialized ---------- 3. WARNING in Bug.java (at line 8) ack.setBoo(vo == null ? null : vo.getBoo()); ^^ Null comparison always yields false: The variable vo cannot be null at this location ---------- 4. ERROR in Bug.java (at line 9) return ack; ^^^ The local variable ack may not have been initialized ---------- 4 problems (2 errors, 2 warnings) Weird. Sorry about that. Maybe it has something to do with my Eclipse install? The upgrade process always seems kind of dubious to me. =) I'll download a new version of 3.6.2, reinstall my plugins, wipe my .metadata and try it again. Verified for 3.7M6 |