<?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: How the hell did I miss that?</title>
	<atom:link href="http://blog.xcski.com/2008/01/10/how-the-hell-did-i-miss-that/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.xcski.com/2008/01/10/how-the-hell-did-i-miss-that</link>
	<description>Everything I used to bore people on newsgroups and mailing lists with, now in one inconvenient place.</description>
	<pubDate>Fri, 09 Jan 2009 00:36:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jed Davis</title>
		<link>http://blog.xcski.com/2008/01/10/how-the-hell-did-i-miss-that/comment-page-1#comment-72241</link>
		<dc:creator>Jed Davis</dc:creator>
		<pubDate>Thu, 10 Jan 2008 17:42:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xcski.com/2008/01/10/how-the-hell-did-i-miss-that#comment-72241</guid>
		<description>I apologize for the unintended insult, then.

This has bothered me enough to go rummaging through the Java Language Spec (third edition) and find section 12.7, Unloading of Classes and Interfaces[*].  But I can't tell if it's attempting a "must not" or a "should not" or what.

So, my best guess is that, assuming there are no actual instances of DBAsset floating around, the runtime thinks no-one cares about the class, unloads it, and then reloads it  later when someone else refers to it -- and the spec feels that this Really Shouldn't Happen, but is unable to entirely forbid it, and why would a decent Java program have an uninstantiated class with actual state?

(Which could explain why I can't reproduce it: my little test program with an int counter isn't generating any memory pressure, or my JRE is different, or both.)


[*] http://java.sun.com/docs/books/jls/third_edition/html/execution.html#12.7 (and hopefully the URL won't be a problem)</description>
		<content:encoded><![CDATA[<p>I apologize for the unintended insult, then.</p>
<p>This has bothered me enough to go rummaging through the Java Language Spec (third edition) and find section 12.7, Unloading of Classes and Interfaces[*].  But I can&#8217;t tell if it&#8217;s attempting a &#8220;must not&#8221; or a &#8220;should not&#8221; or what.</p>
<p>So, my best guess is that, assuming there are no actual instances of DBAsset floating around, the runtime thinks no-one cares about the class, unloads it, and then reloads it  later when someone else refers to it &#8212; and the spec feels that this Really Shouldn&#8217;t Happen, but is unable to entirely forbid it, and why would a decent Java program have an uninstantiated class with actual state?</p>
<p>(Which could explain why I can&#8217;t reproduce it: my little test program with an int counter isn&#8217;t generating any memory pressure, or my JRE is different, or both.)</p>
<p>[*] <a href="http://java.sun.com/docs/books/jls/third_edition/html/execution.html#12.7" rel="nofollow">http://java.sun.com/docs/books/jls/third_edition/html/execution.html#12.7</a> (and hopefully the URL won&#8217;t be a problem)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Tomblin</title>
		<link>http://blog.xcski.com/2008/01/10/how-the-hell-did-i-miss-that/comment-page-1#comment-72236</link>
		<dc:creator>Paul Tomblin</dc:creator>
		<pubDate>Thu, 10 Jan 2008 16:13:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xcski.com/2008/01/10/how-the-hell-did-i-miss-that#comment-72236</guid>
		<description>This is my code, very new and very small.  Nobody else is using it or monkeying with it.  

I put a System.out.println in the code where insertStmt was initialized, and where it was used, and somewhere between being initialized (and it was printing out as non-null) and it being used, it just spontaneously changed to null.  The only other culprit was the "private static PreparedStatement insertStmt = null;".  I took out the "= null", and it worked perfectly.</description>
		<content:encoded><![CDATA[<p>This is my code, very new and very small.  Nobody else is using it or monkeying with it.  </p>
<p>I put a System.out.println in the code where insertStmt was initialized, and where it was used, and somewhere between being initialized (and it was printing out as non-null) and it being used, it just spontaneously changed to null.  The only other culprit was the &#8220;private static PreparedStatement insertStmt = null;&#8221;.  I took out the &#8220;= null&#8221;, and it worked perfectly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jed Davis</title>
		<link>http://blog.xcski.com/2008/01/10/how-the-hell-did-i-miss-that/comment-page-1#comment-72234</link>
		<dc:creator>Jed Davis</dc:creator>
		<pubDate>Thu, 10 Jan 2008 15:55:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xcski.com/2008/01/10/how-the-hell-did-i-miss-that#comment-72234</guid>
		<description>(Um.  I'm assuming this is part of a large and, uh, not-well-understood codebase; thus the slightly uncharitable "monkeying with" comment.)</description>
		<content:encoded><![CDATA[<p>(Um.  I&#8217;m assuming this is part of a large and, uh, not-well-understood codebase; thus the slightly uncharitable &#8220;monkeying with&#8221; comment.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jed Davis</title>
		<link>http://blog.xcski.com/2008/01/10/how-the-hell-did-i-miss-that/comment-page-1#comment-72233</link>
		<dc:creator>Jed Davis</dc:creator>
		<pubDate>Thu, 10 Jan 2008 15:54:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.xcski.com/2008/01/10/how-the-hell-did-i-miss-that#comment-72233</guid>
		<description>It can't be.  Not only were the designers of Java not *quite* that insane, but a minimal test program fails to show this spurious reinitialization of static fields.  There must be something else going on -- if not the obvious, then maybe someone monkeying with class loading?</description>
		<content:encoded><![CDATA[<p>It can&#8217;t be.  Not only were the designers of Java not *quite* that insane, but a minimal test program fails to show this spurious reinitialization of static fields.  There must be something else going on &#8212; if not the obvious, then maybe someone monkeying with class loading?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
