Community
Participate
Working Groups
Build Identifier: 3.7.1 - Build id: M20110909-1335 I am getting the following warning, when I shouldn't. Description Resource Path Location Type Null pointer access: The variable cb can only be null at this location Fixup.java /ContactsRPS/src/org/runnymedecouncil/contacts line 42 Java Problem I will attach two screenshots, one that shows the warning, and one that shows that the warning goes away when I deleted the if statement. Reproducible: Always
Created attachment 206239 [details] screenshot that shows the error You will notice from this screenshot, that there is a similar fragment of code (that is above the code that is in error), that doesn't have the warning.
Created attachment 206240 [details] screenshot with the if statement removed If I remove the if statement, the warning goes away.
I briefly tried this in 3.8M3 but failed to reproduce. I can take a closer look once I'm back from EclipseCon. Meanwhile, perhaps you could attach a small self-contained sample program showing the bug?
(In reply to comment #3) > I briefly tried this in 3.8M3 but failed to reproduce. > Even with 3.7.1 I couldn't reproduce. Must be something specific in Gary's test case.
(In reply to comment #3) > I briefly tried this in 3.8M3 but failed to reproduce. > > I can take a closer look once I'm back from EclipseCon. > Meanwhile, perhaps you could attach a small self-contained sample > program showing the bug? I doubt that I can create a small self-contained sample that still illustrates the problem. I can send you my workspace if that would help you. This is the only warning in the entire workspace :-) I tried simplifying the class and it still shows the problem. I atatched a screenshot.
Created attachment 206320 [details] screenshot of small test class
Created attachment 206321 [details] screenshot of strange fix Notice that if I comment out the line that is below the problem section, the warning goes away.
(In reply to comment #7) Thanks for the screenshots. The foreach loop and the last line give better clarity. Please try to post the snippet here rather than just the screenshot. Its easier for someone to copy paste that and test it out. :)
Up-to 4.5M3 (incl) we report: ---------- 1. WARNING in /tmp/BugTest.java (at line 10) if (cb == null) cb = contact.asBuilder(); ^^ Redundant null check: The variable cb can only be null at this location ---------- 2. WARNING in /tmp/BugTest.java (at line 16) cb.toString(); ^^ Null pointer access: The variable cb can only be null at this location ---------- The first warning is correct, the second is not. Starting with 4.5M4 the incorrect warning is no longer issued. *** This bug has been marked as a duplicate of bug 453483 ***
Created attachment 250809 [details] example source file (In reply to Ayushman Jain from comment #8) > Please try to post the snippet here rather than just the screenshot. Its > easier for someone to copy paste that and test it out. :) Yes! :) In that vein, here's the source file I used for testing.