Community
Participate
Working Groups
I20070427-0010 Spurious redundant null check warning for "var != null": "Redundant null check: The variable var cannot be null at this location" Very strange: If I remove the field WHY_DOES_THIS_MATTER, the wrong warning goes away. public class Try { private static final char WHY_DOES_THIS_MATTER= '?'; public static void main(String[] dd ) { Try var= null; try { var= new Try(); return; } finally { if (var != null) { System.out.println(var.hashCode()); } } } public Try() { throw new IllegalStateException(); } }
Indeed. This suggests a shift somewhere in UnconditionalFlowInfo bit fields, or a change into the variable index calculation (depending on the maximum number of fields for the class). I'll check that when I am back on Wednesday.
NullReferenceTest#516 covers the case without the field.
Created attachment 65572 [details] Fix + test case As stupid as it may sound, we never propagated maxFieldCount to NullInfoRegistry instances, creating a shift into null info. Note that this only affected try/finally statements, and null related information (not definite assignment analysis).
Kent, could you please review the patch? If you're OK with it I'll release it for 3.3 RC1 (very simple, no risk, fixes a bug).
Released for 3.3 RC1.
Verified for 3.3RC1 using I20070515-0010