| Summary: | [compiler] Switching on a null expression doesn't always throw NullPointerException | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | yogy.namara | ||||||
| Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | Olivier_Thomann, srikanth_sankaran | ||||||
| Version: | 3.6 | Flags: | srikanth_sankaran:
review+
|
||||||
| Target Milestone: | 3.6.1 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows Vista | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
yogy.namara
We are too aggressive on the optimization.
For:
switch((Integer) null) {};
we optimize out the whole switch statement when we should at least evaluate the expression.
I'll take a look.
Candidate for 3.6.1.
Created attachment 170539 [details]
Proposed fix + regression tests
Srikanth, please review. (In reply to comment #2) > Created an attachment (id=170539) [details] > Proposed fix + regression tests A quick glance doesn't reveal any test on enum. I'd just like to point out that currently, enum seems "special" somehow. java.math.RoundingMode mode = null; switch (mode) {}; Integer ii = null; switch (ii) {}; Given the above snippet, currently Eclipse (mine at least) DOES throw NullPointerException, but only on the second switch. (In reply to comment #3) > Srikanth, please review. Other than what is already pointed out in comment #4 it looks good. Created attachment 170844 [details]
Proposed fix + regression tests
Patch to fix the enum case. Under testing.
Srikanth, please review the last patch. Thanks. Looks good. Released in HEAD and 3.6 maintenance stream. Verified for 3.6.1 RC2 using Build id: M20100825-0800 |