You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "ams-tschoening (via GitHub)" <gi...@apache.org> on 2023/06/21 07:27:12 UTC
[GitHub] [netbeans] ams-tschoening opened a new issue, #6106: Wrong Warning - Dereferencing possible null pointer
ams-tschoening opened a new issue, #6106:
URL: https://github.com/apache/netbeans/issues/6106
### Apache NetBeans version
Apache NetBeans 18
### What happened
NetBeans warns about dereferencing possible null pointer where I'm somewhat sure that no NPE can happen at all, because null-checks are available already. But the results of those are stored as additional booleans and NetBeans seems unable to take those results into account. There's some [old bug report](https://bz.apache.org/netbeans/show_bug.cgi?id=223031) with similar problems in the archived Bugzilla.
### How to reproduce
The following code triggers the warning:
```java
Supplier s = (Supplier) li.getFullEntity();
boolean hasSupp = s != null;
boolean hasAllow = allowListIf != null;
if (hasSupp && (!hasAllow || allowListIf.contains(s.id)))
{
ret.add(s);
}
```
OTOH, replacing the booleans with the direct null checks removes the warning:
```java
Supplier s = (Supplier) li.getFullEntity();
boolean hasSupp = s != null;
boolean hasAllow = allowListIf != null;
if ((s != null) && (!(allowListIf != null) || allowListIf.contains(s.id)))
{
ret.add(s);
}
```
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
Windows 10 64 Bit 22H2 Build 19045.3086
### JDK
openjdk version "17.0.7" 2023-04-18, OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7), OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode, sharing)
### Apache NetBeans packaging
Apache NetBeans provided installer
### Anything else
_No response_
### Are you willing to submit a pull request?
No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists