| Summary: | [1.7][compiler] Null pointer access warning for strings in switch | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Deepak Azad <deepakazad> | ||||
| Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | enhancement | ||||||
| Priority: | P3 | CC: | amj87.iitr, daniel_megert, deepakazad, srikanth_sankaran | ||||
| Version: | 3.7 | ||||||
| Target Milestone: | 3.7.1 | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
This is the only case in which strings can cause an NPE. So needs to be included in null analysis. Created attachment 197414 [details]
proposed fix v1.0 + regression tests
Released in BETA_JAVA7 branch. Verified using "Eclipse Java Development Tools Patch for Java 7 Support (BETA) 1.0.0.v20110623-0900 org.eclipse.jdt.patch.feature.group Eclipse.org" |
The compiler should show a warning on switch(s). -------------------------------------------------------------- void foo() { String s = null; switch (s) { // should be a warning here case "abcd": System.out.println("abcd"); break; case "xyz": System.out.println("xyz"); break; default: System.out.println("oops"); break; } } --------------------------------------------------------------