nullpointerexception - Strange Java compiler warning: incorrect "potential null access warning" -
(jdk 1.6.0_23, eclipse 3.7.0 "potential null pointer access" warning level @ "warning") consider following example code:
object obj = null; (;;) { obj = getobject(); if (obj != null) break; thread.sleep(25); } obj.tostring();
i'm getting following warning on last line: potential null pointer access: variable obj may null @ location
. there real way obj
null
or why compiler thinks so?
the compiler seeing potential object not initialized. not able see loop breaking condition object not null or run forever or until no longer null. warning on jdk mentioned. using more updated version warning not appear.
Comments
Post a Comment