<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: JSR 305: a silver bullet or not a bullet at all?</title>
	<atom:link href="http://www.klocwork.com/blog/2009/03/jsr-305-a-silver-bullet-or-not-a-bullet-at-all/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.klocwork.com/blog/2009/03/jsr-305-a-silver-bullet-or-not-a-bullet-at-all/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jsr-305-a-silver-bullet-or-not-a-bullet-at-all</link>
	<description>&#62;kloctalk is a blog and a community for software development professionals who create and maintain mission-critical software and the challenges they face on a daily basis.</description>
	<lastBuildDate>Tue, 24 Jan 2012 14:57:13 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Adam Gent</title>
		<link>http://www.klocwork.com/blog/2009/03/jsr-305-a-silver-bullet-or-not-a-bullet-at-all/comment-page-1/#comment-3055</link>
		<dc:creator>Adam Gent</dc:creator>
		<pubDate>Thu, 19 Aug 2010 18:10:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=133#comment-3055</guid>
		<description>I think the real benefit to having something like @NonNull is better documentation. 
Annotations can be included in Java Doc. 
I can&#039;t tell you how many times have written java doc stating whether or not parameters can be null or whether the return value will be null.

@NonNull would provide a consistent way of documenting this.
Otherwise if you are looking for better static analysis perhaps a language such as Scala or F# would be better suited. Typing final in-front of every object is just to much of a pain in the butt.</description>
		<content:encoded><![CDATA[<p>I think the real benefit to having something like @NonNull is better documentation.<br />
Annotations can be included in Java Doc.<br />
I can&#8217;t tell you how many times have written java doc stating whether or not parameters can be null or whether the return value will be null.</p>
<p>@NonNull would provide a consistent way of documenting this.<br />
Otherwise if you are looking for better static analysis perhaps a language such as Scala or F# would be better suited. Typing final in-front of every object is just to much of a pain in the butt.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andreas Krey</title>
		<link>http://www.klocwork.com/blog/2009/03/jsr-305-a-silver-bullet-or-not-a-bullet-at-all/comment-page-1/#comment-2082</link>
		<dc:creator>Andreas Krey</dc:creator>
		<pubDate>Fri, 16 Apr 2010 15:28:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=133#comment-2082</guid>
		<description>It is quite funny: The exact arguments against @nonnull could also be used against specifying the parameter type in methods (and elsewhere). Those can just as well be inferred by global analysis. After all, @nonnull only exists because the java designer allowed null to be used in places where an Whatever is expected even though null clearly does not honor the contract of any Whatever. When allowed nullness of a value would have to be declared, NullPointerException could easily be a checked exception.</description>
		<content:encoded><![CDATA[<p>It is quite funny: The exact arguments against @nonnull could also be used against specifying the parameter type in methods (and elsewhere). Those can just as well be inferred by global analysis. After all, @nonnull only exists because the java designer allowed null to be used in places where an Whatever is expected even though null clearly does not honor the contract of any Whatever. When allowed nullness of a value would have to be declared, NullPointerException could easily be a checked exception.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How to avoid “!= null” statements in Java? &#171; Technical Jottings</title>
		<link>http://www.klocwork.com/blog/2009/03/jsr-305-a-silver-bullet-or-not-a-bullet-at-all/comment-page-1/#comment-1102</link>
		<dc:creator>How to avoid “!= null” statements in Java? &#171; Technical Jottings</dc:creator>
		<pubDate>Thu, 28 Jan 2010 09:25:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=133#comment-1102</guid>
		<description>[...] Java has proposed for the null type annotation in JSR 305 and the proposal has some contradictions  described here. [...]</description>
		<content:encoded><![CDATA[<p>[...] Java has proposed for the null type annotation in JSR 305 and the proposal has some contradictions  described here. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lars Ræder Clausen</title>
		<link>http://www.klocwork.com/blog/2009/03/jsr-305-a-silver-bullet-or-not-a-bullet-at-all/comment-page-1/#comment-481</link>
		<dc:creator>Lars Ræder Clausen</dc:creator>
		<pubDate>Wed, 29 Jul 2009 12:46:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=133#comment-481</guid>
		<description>I completely disagree with your suggestion that whole program analysis can take the place of annotations. Whole program analysis cannot reason about JNI code or code that is provided at run time, and it cannot say anything about future changes. Furthermore, any automatic analysis is only a conservative guess, whereas explicit annotations are a contract. Having a contract makes it a lot easier for the compiler to check - doing full-program analysis is most certainly a huge task in the presence of large libraries. I look forward to having @Nonnull available (especially since they added the @Default annotation).</description>
		<content:encoded><![CDATA[<p>I completely disagree with your suggestion that whole program analysis can take the place of annotations. Whole program analysis cannot reason about JNI code or code that is provided at run time, and it cannot say anything about future changes. Furthermore, any automatic analysis is only a conservative guess, whereas explicit annotations are a contract. Having a contract makes it a lot easier for the compiler to check &#8211; doing full-program analysis is most certainly a huge task in the presence of large libraries. I look forward to having @Nonnull available (especially since they added the @Default annotation).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikhail Ksenzov</title>
		<link>http://www.klocwork.com/blog/2009/03/jsr-305-a-silver-bullet-or-not-a-bullet-at-all/comment-page-1/#comment-164</link>
		<dc:creator>Mikhail Ksenzov</dc:creator>
		<pubDate>Thu, 09 Apr 2009 16:01:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=133#comment-164</guid>
		<description>Thank you for your comments guys. Here is a couple of thoughts:

About maintenance cost: 

I tend to agree that it is a good idea to invest time and effort in automated testing (such as junit tests) or automated verification (such as adding some metadata with annotations). However it makes sense only in the cases when the testing and verification are the only way to check your code. There is no reason to add tests for the defects which would be caught by compiler. You can think of the static analysis tool as a compiler on steroids. Most NPEs can be detected by modern tools w/o any human effort, if the tools are doing their jobs. 

In the following posts I would like to show when using the annotations for defect detection makes sense and where it does not.

About final values:

Even if you declare all the variables and parameters as final ones it would not fix the NPE problems in the snippets above. Saying that I think that using final values where possible is the good practice, though totally unrelated to the blog post.</description>
		<content:encoded><![CDATA[<p>Thank you for your comments guys. Here is a couple of thoughts:</p>
<p>About maintenance cost: </p>
<p>I tend to agree that it is a good idea to invest time and effort in automated testing (such as junit tests) or automated verification (such as adding some metadata with annotations). However it makes sense only in the cases when the testing and verification are the only way to check your code. There is no reason to add tests for the defects which would be caught by compiler. You can think of the static analysis tool as a compiler on steroids. Most NPEs can be detected by modern tools w/o any human effort, if the tools are doing their jobs. </p>
<p>In the following posts I would like to show when using the annotations for defect detection makes sense and where it does not.</p>
<p>About final values:</p>
<p>Even if you declare all the variables and parameters as final ones it would not fix the NPE problems in the snippets above. Saying that I think that using final values where possible is the good practice, though totally unrelated to the blog post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TeLryarroma</title>
		<link>http://www.klocwork.com/blog/2009/03/jsr-305-a-silver-bullet-or-not-a-bullet-at-all/comment-page-1/#comment-158</link>
		<dc:creator>TeLryarroma</dc:creator>
		<pubDate>Thu, 09 Apr 2009 06:28:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=133#comment-158</guid>
		<description>FANTASTIC!</description>
		<content:encoded><![CDATA[<p>FANTASTIC!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ex Boyfriend</title>
		<link>http://www.klocwork.com/blog/2009/03/jsr-305-a-silver-bullet-or-not-a-bullet-at-all/comment-page-1/#comment-153</link>
		<dc:creator>Ex Boyfriend</dc:creator>
		<pubDate>Wed, 08 Apr 2009 22:49:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=133#comment-153</guid>
		<description>Not that I&#039;m impressed a lot, but this is a lot more than I expected for when I stumpled upon a link on SU telling that the info   is quite decent. Thanks.</description>
		<content:encoded><![CDATA[<p>Not that I&#8217;m impressed a lot, but this is a lot more than I expected for when I stumpled upon a link on SU telling that the info   is quite decent. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fabrizio Giudici</title>
		<link>http://www.klocwork.com/blog/2009/03/jsr-305-a-silver-bullet-or-not-a-bullet-at-all/comment-page-1/#comment-120</link>
		<dc:creator>Fabrizio Giudici</dc:creator>
		<pubDate>Thu, 02 Apr 2009 20:11:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=133#comment-120</guid>
		<description>I agree with Mikko&#039;s second paragraph: indeed I think the time spent to put annotations and ensure they are consistent is very well spent, as it forces you to be precise with your design. Also, if you adopt standard practices such as using mostly @NotNull (e.g. by using NullObject or SpecialCase patterns) the amount of work is really reduced.

The fact that things in Java are not final by default is no excuse for developers not using the &quot;final&quot; keyword as much as possible ;-)</description>
		<content:encoded><![CDATA[<p>I agree with Mikko&#8217;s second paragraph: indeed I think the time spent to put annotations and ensure they are consistent is very well spent, as it forces you to be precise with your design. Also, if you adopt standard practices such as using mostly @NotNull (e.g. by using NullObject or SpecialCase patterns) the amount of work is really reduced.</p>
<p>The fact that things in Java are not final by default is no excuse for developers not using the &#8220;final&#8221; keyword as much as possible ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikko Kauppila</title>
		<link>http://www.klocwork.com/blog/2009/03/jsr-305-a-silver-bullet-or-not-a-bullet-at-all/comment-page-1/#comment-118</link>
		<dc:creator>Mikko Kauppila</dc:creator>
		<pubDate>Wed, 01 Apr 2009 16:25:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.klocwork.com/blog/?p=133#comment-118</guid>
		<description>The tragedy is that Java designers chose to make all variables non-final and nullable by default. This makes inter-procedural analysis difficult since the analyzer cannot assume pretty much anything. Also, classes are non-final by default, which makes inter-procedural analysis even harder (since dynamic dispatch due to inheritance may occur).

I disagree about the maintenance cost associated with annotations. This is akin to saying that unit tests are bad since they need to be updated whenever contracts change. Maintaining the annotations -- or unit tests, for that matter -- means that you&#039;re managing the correctness of your code, which is only right. 

The last snippet (with methods &quot;test&quot; and &quot;saveName&quot;) you present is indeed hard to analyze. However, it can be argued that it duplicates information: whether the entity has a qualified name is a property of the entity itself, and should not be passed as a separate parameter (&quot;boolean qualified&quot;). My humble opinion is that programmers should strive to write code that&#039;s easy to analyze.

Otherwise, your post was good and informative.</description>
		<content:encoded><![CDATA[<p>The tragedy is that Java designers chose to make all variables non-final and nullable by default. This makes inter-procedural analysis difficult since the analyzer cannot assume pretty much anything. Also, classes are non-final by default, which makes inter-procedural analysis even harder (since dynamic dispatch due to inheritance may occur).</p>
<p>I disagree about the maintenance cost associated with annotations. This is akin to saying that unit tests are bad since they need to be updated whenever contracts change. Maintaining the annotations &#8212; or unit tests, for that matter &#8212; means that you&#8217;re managing the correctness of your code, which is only right. </p>
<p>The last snippet (with methods &#8220;test&#8221; and &#8220;saveName&#8221;) you present is indeed hard to analyze. However, it can be argued that it duplicates information: whether the entity has a qualified name is a property of the entity itself, and should not be passed as a separate parameter (&#8220;boolean qualified&#8221;). My humble opinion is that programmers should strive to write code that&#8217;s easy to analyze.</p>
<p>Otherwise, your post was good and informative.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

