You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Netbeans User 2019 (Jira)" <ji...@apache.org> on 2020/03/06 11:36:00 UTC
[jira] [Created] (NETBEANS-3967) Hint about dereferencing null
pointer is wrong
Netbeans User 2019 created NETBEANS-3967:
--------------------------------------------
Summary: Hint about dereferencing null pointer is wrong
Key: NETBEANS-3967
URL: https://issues.apache.org/jira/browse/NETBEANS-3967
Project: NetBeans
Issue Type: Bug
Components: editor - Hints & Annotations, java - Hints
Affects Versions: 11.2, 11.3
Environment: OpenJDK 11.0.2
Reporter: Netbeans User 2019
public static void main(String[] args) {
Optional.ofNullable(getValue())//as instance of java.util.Optional
.map((o)->o instanceof String ? ((String)o).substring(0) : o.toString());
}
private static Object getValue() {
return "";
}
o.toString() show hint about dereferencing possible null pointer, but this is not possible in that case as check is ensured by optional. In example is used "String" for simplification, but in more abstract case you want to get value one way if it is instance of anything and other way from "o" if it is not instance of that type.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists