You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "asbachb (via GitHub)" <gi...@apache.org> on 2023/07/08 20:35:22 UTC

[GitHub] [netbeans] asbachb commented on issue #6149: `Objects.requireNonNull` should disable "Null Pointer Dereference" warnings

asbachb commented on issue #6149:
URL: https://github.com/apache/netbeans/issues/6149#issuecomment-1627484452

   Here's an additional test for `NPECheckTest` to prove the problem:
   
   ```java
       public void testObjectsRequireNonNull() throws Exception {
           HintTest.create()
                   .input("package test;\n"
                           + "import java.util.Objects;\n"
                           + "public class Test {\n"
                           + "  public String test(Object obj) {\n"
                           + "    Objects.requireNonNull(obj);\n"
                           + "    if (obj instanceof Number)\n"
                           + "      return \"\";\n"
                           + ""
                           + "    return obj.toString();\n"
                           + "  }\n"
                           + "}")
                   .run(NPECheck.class)
                   .assertNotContainsWarnings("7:15-7:23:verifier:Possibly Dereferencing null");
       }
   ```


-- 
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

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