Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 190170

Summary: [compiler][null] false positive null reference with boolean logical &
Product: [Eclipse Project] JDT Reporter: Thierry Monney <thierry.monney>
Component: CoreAssignee: Stephan Herrmann <stephan.herrmann>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P5 CC: chalin, h.klene, stephan.herrmann
Version: 3.3   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Thierry Monney CLA 2007-05-31 06:55:30 EDT
The followin code gives warnings when the potential null reference preference is enabled:

public void foo(Object a, Object b) {
    if (a != null & b != null) {
        System.out.println(a.toString() + b.toString());
    }
}

The same code using the logical && does not show the warning.
Comment 1 Maxime Daniel CLA 2007-07-12 09:15:23 EDT
Reproduced with I20070625-1500.

In fact, it seems that boolean expressions else than boolean shortcut expressions have received insufficient attention.
Comment 2 Maxime Daniel CLA 2007-08-30 10:45:21 EDT
Further investigations unveiled that the && case works because of the opportunistic reuse of ConditionalFlowInfo by the null analysis, which is not a viable option for the & case. Since the severity is minor and the fix would need significant changes, deferring.
Comment 3 Stephan Herrmann CLA 2011-02-28 07:55:32 EST
Still relevant in 3.7M5
Comment 4 Stephan Herrmann CLA 2011-02-28 12:21:47 EST
I'll take a look.
Comment 5 Holger Klene CLA 2013-07-30 17:38:45 EDT
Reproduced with:
Version: 4.3.0
Build id: I20130605-2000
Comment 6 Eclipse Genie CLA 2020-03-08 04:52:04 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Holger Klene CLA 2020-03-18 17:28:14 EDT
Please reopen - Still an issue in:
Version: 2019-03 (4.11)
Build id: I20190301-0040
Comment 8 Stephan Herrmann CLA 2020-03-18 18:49:02 EDT
(In reply to Holger Klene from comment #7)
> Please reopen - Still an issue in:
> Version: 2019-03 (4.11)
> Build id: I20190301-0040

Please understand that we do have to set priorities in fixing bugs. So when this bug got closed automatically, I briefly scanned the situation and decided that using '&' to join boolean operands is not a particular common nor useful idiom.

Before we re-open, you'd need to convince me of the high relevance of '&' for boolean values. :)