Community
Participate
Working Groups
Here is rather sily piece of code that is confusing null refrence analyzer. Code in for loop is neve executed when args is null, but yet reported that args variable can be null. public void aaa(String[] args) { String[] vars = new String[args == null ? 0 : args.length]; for (int i = 0; i < vars.length; ++i) { System.err.println(args[i]); } } Unfortunately this happening in some legacy code that can't be easily changed to eliminate such warning.
Variables correlation in general is not in scope for our null analysis, as far as 3.2 is concerned. Here, we would need args null status to be guarded by vars length. At the extreme, a pattern could be hard coded. It would be quite convoluted though, and still would need that vars be made final, which is not practical in legacy code either.
I wonder how FindBugs analyzer approached this case. It does not raise false positive for this.
I haven't looked at their code.
Reopening as P5 (since RESOLVED LATER is deprecated).
*** Bug 260293 has been marked as a duplicate of this bug. ***
Bulk closing all compiler bugs tagged [null][correlation], because we have no plans to add such a feature: it would be a tremendous implementation effort, beyond our current man power, and may be impossible to achieve within the desired performance bounds. If s.o. has a viable strategy or even implementation for such a feature, I'm all ears.
Verified for 4.7 M1
I created a new umbrella RFE outlining what would be needed to address this issue. *** This bug has been marked as a duplicate of bug 538421 ***