Community
Participate
Working Groups
The following will cause eclipse to issue a "potential null pointer" warning on the last line, even though there's no possibility for s1 to be null at that point. public boolean areDifferent(String s1, String s2) { if(s1 == null && s2 == null) { return false; } if((s1 == null) ^ (s2 == null)) { return true; } return !s1.equals(s2); } As proof, the following lines do not cause a NullPointerException: areDifferent(null, null); areDifferent("a", null); areDifferent(null, "a"); areDifferent("a", "a");
Still a problem on I20090811-0800. If you use |, the warning will also appear.
Fixing this would require analysis of the correlation of s1 and s2, which we currently don't do. Closing as duplicate despite the slight different in logic. *** This bug has been marked as a duplicate of bug 290263 ***
*** This bug has been marked as a duplicate of bug 538421 ***