Community
Participate
Working Groups
Eclipse is reporting "The variable s may be null" at s.lenght() in the following code. It seems has something todo with "break"... private void aa() { for(int i = 0; i < 10; i++) { String s = get(); if(s != null) { for(int j = 0; j < 1; j++) { break; } s.length(); } } } private String get() { return null; }
This is related to the cancellation of null related information at the very beginning of the loop. As a side effect, the inits on break lack knowledge about the upstream null info (here, s is protected non null before entering the loop). The proposed remedy is to reinject the upstream null info when needed (as we do for the null info resulting from the loop action). Added test cases NullReferenceTest #732 to 735 to illustrate the case in all loops.
Created attachment 36737 [details] Suggested patch + test cases
Fixed and released in HEAD. Verification can use the initial test case and other loop combinations.
Target Milestone must be 3.2M6 and not 3.2RC1. I correct it. Verified for 3.2 M6 using build 3.2M6