<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Code Fix &#187; Java</title>
	<atom:link href="http://www.code-fix.com/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.code-fix.com</link>
	<description>Fix it or fixate.</description>
	<lastBuildDate>Sun, 04 Mar 2007 01:53:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Here we go</title>
		<link>http://www.code-fix.com/2007/02/26/here-we-go/</link>
		<comments>http://www.code-fix.com/2007/02/26/here-we-go/#comments</comments>
		<pubDate>Tue, 27 Feb 2007 03:33:40 +0000</pubDate>
		<dc:creator>Jordan</dc:creator>
				<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.code-fix.com/?p=4</guid>
		<description><![CDATA[Enough time has been spent fixing bugs and getting basic things working. Hopefully, this site will help fix that.
I mostly work with Java and Eclipse, but do enough web stuff to beat my head against a wall every once in a while. This site will have tips, tutorials, bug workarounds, and anything else I can [...]]]></description>
			<content:encoded><![CDATA[<p>Enough time has been spent fixing bugs and getting basic things working. Hopefully, this site will help fix that.</p>
<p>I mostly work with Java and Eclipse, but do enough web stuff to beat my head against a wall every once in a while. This site will have tips, tutorials, bug workarounds, and anything else I can think of that people might find worthwhile.</p>
<p>I suppose I could start with the simplest and most embarrassing debugging problem I ever hit&#8230;</p>
<p><span id="more-4"></span>In Eclipse (and most interactive debuggers), you can set up expressions that are evaluated whenever the debugged process halts. Because these expressions are evaluated in the current thread context, they have full access to read (or write to) local variables. I happened to put a typo in one of these expressions, and did the ol&#8217; &#8220;assign instead of compare&#8221; trick, evaluating &#8220;str = null&#8221; instead of &#8220;str == null&#8221;.</p>
<p>I didn&#8217;t really notice the bug, and didn&#8217;t end up needing to see whether str was null or not, so I went back to another view, hiding the debug expressions I had set (out of sight, out of mind, right?). It was about that time I started noticing a bizarre new bug&#8230; whenever I would hit a breakpoint, str would be null, even if the code I was stepping through didn&#8217;t do a <em>thing</em> with str! Fancy that!</p>
<p>Lesson 1: If there is weird behavior when debugging, check to see if expressions are being evaluated without you knowing.</p>
<p>Lesson 2: Use &#8220;null == str&#8221; instead of &#8220;str == null&#8221; to avoid assignment vs. compare bugs. (this actually doesn&#8217;t work in all languages&#8230; wait for a future post)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.code-fix.com/2007/02/26/here-we-go/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
