Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #36844

Re: null checks

From Lothar Kimmeringer <news201705@kimmeringer.de>
Newsgroups comp.lang.java.programmer
Subject Re: null checks
Date 2017-07-09 15:59 +0200
Organization Organization?! Only chaos here!
Message-ID <3ubp2nji6vw$.dlg@kimmeringer.de> (permalink)
References <fb0314ea-bd97-4348-8af1-3ac9f9f46bdc@googlegroups.com>

Show all headers | View raw


Eric Douglas wrote:

> Correct me if I'm wrong but the NonNull is pointless?
> 
> https://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftask-using_null_type_annotations.htm
> 
> We should just use the null check?
> 
> https://docs.oracle.com/javase/8/docs/api/java/util/Objects.html#requireNonNull-T-

In addition to all that has been said about this already I might
add the argument that an annotation also is some kind of
documentation for the user of a library. The annotation shows
up in Javadoc and e.g. within Eclipse when you use the
autocompletiton so you as a programmer know that null is not
accepted as parameter value.

You still need the check for null within the actual implementation
of the method but with the annotation you don't realize your
error when a NPE shows up but you can use your eyes and brain
to get a heads-up beforehand and can use tools showing you
errors/warnings before you put your code into production.


Cheers, Lothar
-- 
Lothar Kimmeringer                E-Mail: spamfang@kimmeringer.de
               PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

Always remember: The answer is forty-two, there can only be wrong
                 questions!

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

null checks Eric Douglas <e.d.programmer@gmail.com> - 2017-07-07 08:03 -0700
  Re: null checks Arne Vajhøj <arne@vajhoej.dk> - 2017-07-07 11:49 -0400
    Re: null checks Eric Douglas <e.d.programmer@gmail.com> - 2017-07-07 08:54 -0700
      Re: null checks Arne Vajhøj <arne@vajhoej.dk> - 2017-07-07 12:12 -0400
        Re: null checks Eric Douglas <e.d.programmer@gmail.com> - 2017-07-07 10:16 -0700
        Re: null checks Joerg Meier <joergmmeier@arcor.de> - 2017-07-08 22:33 +0200
          Re: null checks Martin Gregorie <martin@address-in-sig.invalid> - 2017-07-08 21:14 +0000
            Re: null checks Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-08 17:51 -0400
              Re: null checks Martin Gregorie <martin@address-in-sig.invalid> - 2017-07-08 22:26 +0000
            Re: null checks Arne Vajhøj <arne@vajhoej.dk> - 2017-07-08 18:28 -0400
            Re: null checks Joerg Meier <joergmmeier@arcor.de> - 2017-07-25 07:26 +0200
              Re: null checks Martin Gregorie <martin@address-in-sig.invalid> - 2017-07-25 12:12 +0000
          Re: null checks Arne Vajhøj <arne@vajhoej.dk> - 2017-07-08 18:20 -0400
            Re: null checks Eric Douglas <e.d.programmer@gmail.com> - 2017-07-10 05:35 -0700
        Re: null checks Robert Klemme <shortcutter@googlemail.com> - 2017-07-09 13:10 +0200
      Re: null checks Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-07 12:53 -0400
        Re: null checks lewbloch@gmail.com - 2017-07-26 11:16 -0700
          Re: null checks Eric Douglas <e.d.programmer@gmail.com> - 2017-07-26 11:40 -0700
            Re: null checks Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-07-26 16:40 -0400
            Re: null checks lewbloch@gmail.com - 2017-07-28 18:47 -0700
  Re: null checks Wayne <wayne@nospam.invalid> - 2017-07-07 16:24 -0400
  Re: null checks Joerg Meier <joergmmeier@arcor.de> - 2017-07-08 22:32 +0200
  Re: null checks Lothar Kimmeringer <news201705@kimmeringer.de> - 2017-07-09 15:59 +0200
    Re: null checks Arne Vajhøj <arne@vajhoej.dk> - 2017-07-11 20:30 -0400

csiph-web