| Summary: | More flexible null analysis for fields in single threaded classes | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Andrew Eisenberg <andrew.eisenberg> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | stephan.herrmann |
| Version: | 4.3.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| Whiteboard: | stalebug | ||
|
Description
Andrew Eisenberg
Hi Andrew, (seeing your example explicitly saying "lazy", may I assume you saw bug 414237?) If we enter that realm, the question would be: how long would the knowledge from a field null-check survive? Your examples only contain immediate usage of the knowledge, but we still shouldn't accept: public Object getLazy() { if(lazy == null) { lazy = new Object(); } else { return lazy.toString(); } bar(); return lazy; } private bar() { this.lazy = null; } And even this is unsafe even in single threaded contexts: public Object getLazy() { if(lazy == null) { lazy = new Object(); } else { return lazy.toString(); } other.zork.lazy = foo.bar; return lazy; } (other.zork could point back to this, and foo.bar could be null). I'm asking because I'm not sure that users will understand and accept the remaining limitations due to side effects and aliasing. In fact, the time to live of the information from a null check is not much longer than the crude compromise implemented as "syntactic null analysis for fields". OIOW: between the existing syntactic null analysis and the proposed @LazyNonNull, would this current proposal show significant additional value not covered by the other two? Oops, should've put my "destructive" statements inside the else branch. Do you see what I mean? One problem is that I am not exactly sure what is covered by "syntactic null analysis" and LazyNonNull. So, maybe my proposal doesn't cover much more than that, but at least the name seems more clear to me. I'll comment on bug 414237. ps- yes, the example was lifted directly from Bug 414191. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |