<?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: Mystery of Accessibility in Local Inner Classes</title>
	<atom:link href="http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/</link>
	<description>Tracing the course of Web Technology</description>
	<lastBuildDate>Sun, 13 May 2012 05:47:02 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Hareesh sarma</title>
		<link>http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/comment-page-1/#comment-41375</link>
		<dc:creator>Hareesh sarma</dc:creator>
		<pubDate>Tue, 27 Mar 2012 19:48:36 +0000</pubDate>
		<guid isPermaLink="false">http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/#comment-41375</guid>
		<description>Ultimastic Answer... thanks!!!!</description>
		<content:encoded><![CDATA[<p>Ultimastic Answer&#8230; thanks!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Why the arguments must be final to an anonymous class ?</title>
		<link>http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/comment-page-1/#comment-41294</link>
		<dc:creator>Why the arguments must be final to an anonymous class ?</dc:creator>
		<pubDate>Sat, 04 Feb 2012 21:37:59 +0000</pubDate>
		<guid isPermaLink="false">http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/#comment-41294</guid>
		<description>[...]         This looks to be a decent discussion of this issue: Mystery of Accessibility in Local Inner Classes &#124; Techtracer       How to use Code Tags  How to Ask Smart Questions The Short, Self Contained, Correct [...]</description>
		<content:encoded><![CDATA[<p>[...]         This looks to be a decent discussion of this issue: Mystery of Accessibility in Local Inner Classes | Techtracer       How to use Code Tags  How to Ask Smart Questions The Short, Self Contained, Correct [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Josh09</title>
		<link>http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/comment-page-1/#comment-34140</link>
		<dc:creator>Josh09</dc:creator>
		<pubDate>Sat, 28 Nov 2009 18:47:19 +0000</pubDate>
		<guid isPermaLink="false">http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/#comment-34140</guid>
		<description>I&#039;m the perfect coder so it all takes me awhile to get things to work correctly</description>
		<content:encoded><![CDATA[<p>I&#8217;m the perfect coder so it all takes me awhile to get things to work correctly</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pravin Jain</title>
		<link>http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/comment-page-1/#comment-30409</link>
		<dc:creator>Pravin Jain</dc:creator>
		<pubDate>Tue, 01 Sep 2009 09:33:49 +0000</pubDate>
		<guid isPermaLink="false">http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/#comment-30409</guid>
		<description>Pl. Note:
The instance variables of the enclosing class cannot be accessed from the local method of a static method.</description>
		<content:encoded><![CDATA[<p>Pl. Note:<br />
The instance variables of the enclosing class cannot be accessed from the local method of a static method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bhaswati Sarkar</title>
		<link>http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/comment-page-1/#comment-19694</link>
		<dc:creator>Bhaswati Sarkar</dc:creator>
		<pubDate>Tue, 03 Mar 2009 00:44:28 +0000</pubDate>
		<guid isPermaLink="false">http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/#comment-19694</guid>
		<description>great explanation ... but can u tell me .... if any one ask me &quot; how do you know java bite code makes a copy of final variable under the inner class ? &quot; ... what will be my answer</description>
		<content:encoded><![CDATA[<p>great explanation &#8230; but can u tell me &#8230;. if any one ask me &#8221; how do you know java bite code makes a copy of final variable under the inner class ? &#8221; &#8230; what will be my answer</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sergey</title>
		<link>http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/comment-page-1/#comment-13103</link>
		<dc:creator>Sergey</dc:creator>
		<pubDate>Mon, 17 Nov 2008 20:39:55 +0000</pubDate>
		<guid isPermaLink="false">http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/#comment-13103</guid>
		<description>I think the explanation is not as self-evident as your post makes it sound; in fact, it explains only half of the problem. The compiler does not need to insist on the variable to be final to use the val$var trick - it is sufficient for it to know that the variable has been assigned to prior to the call of the inner class constructor. Compiler already knows how to track that - this is how it alerts you of the variables used before being assigned to; this rule applies to all variables.

The second part of the puzzle has to do with semantic of the Java language. Imagine that the compiler drops the &#039;final&#039; requirement, requiring only that the variable is initialized prior to the call of the constructor. The data can make into the inner class just OK, but since we&#039;ve made a copy, the new variable gets a lifecycle of its own. This means that any assignments to it will not be reflected in the value of the local variable, thus exposing the fact that the compiler has performed a copy. In other words, the programmers will see two variables when in fact they have declared only one; a requirement of declaring the variable final gracefully deals with this inconsistency.</description>
		<content:encoded><![CDATA[<p>I think the explanation is not as self-evident as your post makes it sound; in fact, it explains only half of the problem. The compiler does not need to insist on the variable to be final to use the val$var trick &#8211; it is sufficient for it to know that the variable has been assigned to prior to the call of the inner class constructor. Compiler already knows how to track that &#8211; this is how it alerts you of the variables used before being assigned to; this rule applies to all variables.</p>
<p>The second part of the puzzle has to do with semantic of the Java language. Imagine that the compiler drops the &#8216;final&#8217; requirement, requiring only that the variable is initialized prior to the call of the constructor. The data can make into the inner class just OK, but since we&#8217;ve made a copy, the new variable gets a lifecycle of its own. This means that any assignments to it will not be reflected in the value of the local variable, thus exposing the fact that the compiler has performed a copy. In other words, the programmers will see two variables when in fact they have declared only one; a requirement of declaring the variable final gracefully deals with this inconsistency.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Casper Bang</title>
		<link>http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/comment-page-1/#comment-4234</link>
		<dc:creator>Casper Bang</dc:creator>
		<pubDate>Tue, 13 May 2008 12:57:00 +0000</pubDate>
		<guid isPermaLink="false">http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/#comment-4234</guid>
		<description>&gt; I thought this is not allowed in Java, because super() must be the first instruction in the constructor method.

Well it&#039;s not allowed in Java, but it is allowed by the bytecode verifier - which has other ways of ensuring that the superclass constructor is always called.</description>
		<content:encoded><![CDATA[<p>&gt; I thought this is not allowed in Java, because super() must be the first instruction in the constructor method.</p>
<p>Well it&#8217;s not allowed in Java, but it is allowed by the bytecode verifier &#8211; which has other ways of ensuring that the superclass constructor is always called.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dmarks</title>
		<link>http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/comment-page-1/#comment-4233</link>
		<dc:creator>dmarks</dc:creator>
		<pubDate>Tue, 13 May 2008 12:04:52 +0000</pubDate>
		<guid isPermaLink="false">http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/#comment-4233</guid>
		<description>@nitinpai: It seems to work property since JDK 1.5. I tested it with JDK 1.4.2, and it did not work. 

Decompilation reveals why:

JDK 1.4.2:

class Outer$1 {
  Outer$1(final s) { var$s = s } 
}

JDK 1.5:
class Outer$1{
  Outer$1(final s) { var$s = s; 
  super(); }
}

So JDK 1.4 calls the super-constructor before setting the hidden var$s, and JDK 1.5 first sets the var$s and then calls the super-constructor (I thought this is not allowed in Java, because super() must be the first instruction in the constructor method).</description>
		<content:encoded><![CDATA[<p>@nitinpai: It seems to work property since JDK 1.5. I tested it with JDK 1.4.2, and it did not work. </p>
<p>Decompilation reveals why:</p>
<p>JDK 1.4.2:</p>
<p>class Outer$1 {<br />
  Outer$1(final s) { var$s = s }<br />
}</p>
<p>JDK 1.5:<br />
class Outer$1{<br />
  Outer$1(final s) { var$s = s;<br />
  super(); }<br />
}</p>
<p>So JDK 1.4 calls the super-constructor before setting the hidden var$s, and JDK 1.5 first sets the var$s and then calls the super-constructor (I thought this is not allowed in Java, because super() must be the first instruction in the constructor method).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karthik</title>
		<link>http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/comment-page-1/#comment-4218</link>
		<dc:creator>Karthik</dc:creator>
		<pubDate>Sun, 11 May 2008 07:53:14 +0000</pubDate>
		<guid isPermaLink="false">http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/#comment-4218</guid>
		<description>I just did the javap -c MyLocalInnerClass

u will get the source code</description>
		<content:encoded><![CDATA[<p>I just did the javap -c MyLocalInnerClass</p>
<p>u will get the source code</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nitinpai</title>
		<link>http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/comment-page-1/#comment-4216</link>
		<dc:creator>nitinpai</dc:creator>
		<pubDate>Sun, 11 May 2008 07:11:16 +0000</pubDate>
		<guid isPermaLink="false">http://techtracer.com/2008/04/14/mystery-of-accessibility-in-local-inner-classes/#comment-4216</guid>
		<description>@Karthik - Thanks for your inputs. Could you provide me a link to the source.</description>
		<content:encoded><![CDATA[<p>@Karthik &#8211; Thanks for your inputs. Could you provide me a link to the source.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

