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


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

Re: null checks

Newsgroups comp.lang.java.programmer
Date 2017-07-07 10:16 -0700
References <fb0314ea-bd97-4348-8af1-3ac9f9f46bdc@googlegroups.com> <ojoaip$pab$1@gioia.aioe.org> <70f5af57-8dc0-416c-b2aa-0bbbb47fc7b5@googlegroups.com> <ojobsn$rh8$1@gioia.aioe.org>
Message-ID <902b21f6-89f0-40ff-bb48-5feca86ea62d@googlegroups.com> (permalink)
Subject Re: null checks
From Eric Douglas <e.d.programmer@gmail.com>

Show all headers | View raw


On Friday, July 7, 2017 at 12:12:27 PM UTC-4, Arne Vajhøj wrote:
> On 7/7/2017 11:54 AM, Eric Douglas wrote:
> > On Friday, July 7, 2017 at 11:50:05 AM UTC-4, Arne Vajhøj wrote:
> >> I am not sure that I understand the question.
> >>
> >> Annotations can be used by compilers or check tools to
> >> issue warnings/errors and by AOP tools to insert runtime checks
> >> automatically.
> >>
> >> A runtime check is just a piece of code that does a runtime check.
> >>
> >> Two completely different purposes.
> > 
> > So what are you trying to say, if you need a parameter to never be
> > null use both the @NonNull and the new Objects.requireNonNull()? Is
> > the assert verb still necessary or useful?
> 
> You need to choose between approaches:
> 1) Annotate and let IDE/checktool give you warnings during dveelopment
> 2) Make a runtime check
>     A) Insert the check code manually
>     B) Annotate and weave the check code in via AOP
> 
> I only think it makes sense to do one.
> 
> I think approach 2A is the simple safe approach.
> 
> If you are a leading edge environment then 2B
> may fit.
> 
> I don't like to rely on IDE/checktool to enforce
> integrity of application.
> 
> Arne

The @NonNull doesn't appear to be required, so wasn't sure if it's necessary or helpful.
To add it in Eclipse it requires "Copy library with default null annotations to build path".
I just want to ensure a null object is never passed in to a public method.  It appears the simplest way now is the first line of the method call Objects.requireNonNull() which is the Java 8 convenience for if (passin == null) throw NPE.

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