[ https://issues.apache.org/jira/browse/NETBEANS-5667?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nakarukatoshi updated NETBEANS-5667: ------------------------------------ Description: As posted on NETBEANS-1480, here is another clear example of the fake NullPointerException: {{public static void foo(Object bar) {}} {{ Objects.requireNonNull(bar, "[bar] must not be null.");}} {{ if (bar instanceof String) {}} {{ System.out.println(bar.toString());}} {{ } else {}} {{ throw new IllegalArgumentException("[" + bar.{color:#de350b}getClass{color}().getSimpleName() + "] not supported.");}} } } {{In other words, after the Objects#requireNonNull(Object, String) check, if I do an if-else with an instanceof operator, the "else" section will warn about a NullPointerException (the red method)}} was: As posted on [NETBEANS-1480], here is another clear example of the fake NullPointerException: {{public static void foo(Object bar) {}} {{ Objects.requireNonNull(bar, "[bar] must not be null.");}} {{ if (bar instanceof String) {}} {{ System.out.println(bar.toString());}} {{ } else {}} {{ throw new IllegalArgumentException("[" + bar.{color:#de350b}getClass{color}().getSimpleName() + "] not supported.");}} {{ }}} {{ }}} {{In other words, after the Objects#requireNonNull(Object, String) check, if I do an if-else with an instanceof operator, the "else" section will warn about a NullPointerException (the red method)}} > False positive: Dereferencing possible Null Pointer Exception > ------------------------------------------------------------- > > Key: NETBEANS-5667 > URL: https://issues.apache.org/jira/browse/NETBEANS-5667 > Project: NetBeans > Issue Type: Bug > Affects Versions: 12.3 > Reporter: Nakarukatoshi > Priority: Minor > Labels: false, npe, nullpointerexception, warn, warning > Attachments: prove.png > > > As posted on NETBEANS-1480, here is another clear example of the fake > NullPointerException: > > {{public static void foo(Object bar) {}} > {{ Objects.requireNonNull(bar, "[bar] must not be null.");}} > {{ if (bar instanceof String) {}} > {{ System.out.println(bar.toString());}} > {{ } else {}} > {{ throw new IllegalArgumentException("[" + > bar.{color:#de350b}getClass{color}().getSimpleName() + "] not supported.");}} > } > } > {{In other words, after the Objects#requireNonNull(Object, String) check, if > I do an if-else with an instanceof operator, the "else" section will warn > about a NullPointerException (the red method)}} -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists