[
https://issues.apache.org/jira/browse/NETBEANS-3967?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Netbeans User 2019 updated NETBEANS-3967:
-----------------------------------------
Affects Version/s: 12.0
> 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: 12.0, 11.2, 11.3
> Environment: OpenJDK 11.0.2
> Reporter: Netbeans User 2019
> Priority: Major
> Labels: hints
>
> 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: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists