Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: null checks Date: Fri, 7 Jul 2017 12:12:04 -0400 Organization: Aioe.org NNTP Server Lines: 37 Message-ID: References: <70f5af57-8dc0-416c-b2aa-0bbbb47fc7b5@googlegroups.com> NNTP-Posting-Host: PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:36817 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