<?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"
	>
<channel>
	<title>Comments on: When will Sun&#8217;s JDK start following code conventions?</title>
	<atom:link href="http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/</link>
	<description>Computers are useless. They can only give you answers.</description>
	<pubDate>Tue, 09 Mar 2010 20:48:13 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Atif Khan</title>
		<link>http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/#comment-82</link>
		<dc:creator>Atif Khan</dc:creator>
		<pubDate>Fri, 15 Dec 2006 15:36:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/#comment-82</guid>
		<description>Messi and Kevin,
   I have updated the post with your inputs. Thanks for the contribution.</description>
		<content:encoded><![CDATA[<p>Messi and Kevin,<br />
   I have updated the post with your inputs. Thanks for the contribution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Riff</title>
		<link>http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/#comment-79</link>
		<dc:creator>Kevin Riff</dc:creator>
		<pubDate>Wed, 13 Dec 2006 21:45:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/#comment-79</guid>
		<description>All compile-time constants (which includes strings and numerical values) are inlined by the compiler. All string constants, whether they are literals or not, are encoded with the ldc instruction by the compiler. The first time that ldc is encountered there may be a slight delay to resolve the constant pool entry at that location, but after that it's as fast (or faster) as an array lookup. So feel free to create a constant if you want to define the string's value in one place, but it makes no difference to the way it's referenced in the byte code. 

The 'final' modifier on local variables only has an effect at compile time. In fact, it isn't even possible to tell the JVM which local variables are final. That's not surprising really if you realize that even the type of local variables (not parameters) is not encoded in the class and must be inferred by the JVM based on the bytecodes used. Some coding standards require the use of 'final' to prevent accidental modifications, but it has absolutely no effect on the compiled code.</description>
		<content:encoded><![CDATA[<p>All compile-time constants (which includes strings and numerical values) are inlined by the compiler. All string constants, whether they are literals or not, are encoded with the ldc instruction by the compiler. The first time that ldc is encountered there may be a slight delay to resolve the constant pool entry at that location, but after that it&#8217;s as fast (or faster) as an array lookup. So feel free to create a constant if you want to define the string&#8217;s value in one place, but it makes no difference to the way it&#8217;s referenced in the byte code. </p>
<p>The &#8216;final&#8217; modifier on local variables only has an effect at compile time. In fact, it isn&#8217;t even possible to tell the JVM which local variables are final. That&#8217;s not surprising really if you realize that even the type of local variables (not parameters) is not encoded in the class and must be inferred by the JVM based on the bytecodes used. Some coding standards require the use of &#8216;final&#8217; to prevent accidental modifications, but it has absolutely no effect on the compiled code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Atif Khan</title>
		<link>http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/#comment-78</link>
		<dc:creator>Atif Khan</dc:creator>
		<pubDate>Wed, 13 Dec 2006 21:11:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/#comment-78</guid>
		<description>Messi,
   Thanks for the clarification. I do see the bytecode instruction for the string constant being pushed on the stack. Now this raises some questions:

1). Since the compiler generates a "ldc" for loading the reference to the string literal, is there any value in defining a constant even if the literal is used several times? The only cases I can think of is for programmatic accuracy and having a single point for future changes. Can anyone think of something else?

2). I understand "field != local variable". But as far as the memory allocation for two, wouldn't they both benefit from "final" declaration as they will be marked as immutable?

3). I do like the brackets and spaces instead of tabs. But, that's just my personal preference :)</description>
		<content:encoded><![CDATA[<p>Messi,<br />
   Thanks for the clarification. I do see the bytecode instruction for the string constant being pushed on the stack. Now this raises some questions:</p>
<p>1). Since the compiler generates a &#8220;ldc&#8221; for loading the reference to the string literal, is there any value in defining a constant even if the literal is used several times? The only cases I can think of is for programmatic accuracy and having a single point for future changes. Can anyone think of something else?</p>
<p>2). I understand &#8220;field != local variable&#8221;. But as far as the memory allocation for two, wouldn&#8217;t they both benefit from &#8220;final&#8221; declaration as they will be marked as immutable?</p>
<p>3). I do like the brackets and spaces instead of tabs. But, that&#8217;s just my personal preference <img src='http://www.khanspot.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: messi</title>
		<link>http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/#comment-73</link>
		<dc:creator>messi</dc:creator>
		<pubDate>Wed, 13 Dec 2006 19:45:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/#comment-73</guid>
		<description>3) "ldc" is the instruction's mnemonic.</description>
		<content:encoded><![CDATA[<p>3) &#8220;ldc&#8221; is the instruction&#8217;s mnemonic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: messi</title>
		<link>http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/#comment-72</link>
		<dc:creator>messi</dc:creator>
		<pubDate>Wed, 13 Dec 2006 19:33:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.khanspot.com/2006/12/12/when-will-suns-jdk-start-following-code-conventions/#comment-72</guid>
		<description>1) Just a guess. I checked java/lang/StringBuilder.java in src.zip from JDK5 and JDK6 and both methods contain tabs.

2) Sorry, you're right. I didn't scroll down to the //AVOID comment example. I'm glad Sun doesn't follow that convention.

3) String constants are loaded by a the const_n bytecode instruction which means directly pushing the reference onto the stack. No lookup required.

4) field != local variable</description>
		<content:encoded><![CDATA[<p>1) Just a guess. I checked java/lang/StringBuilder.java in src.zip from JDK5 and JDK6 and both methods contain tabs.</p>
<p>2) Sorry, you&#8217;re right. I didn&#8217;t scroll down to the //AVOID comment example. I&#8217;m glad Sun doesn&#8217;t follow that convention.</p>
<p>3) String constants are loaded by a the const_n bytecode instruction which means directly pushing the reference onto the stack. No lookup required.</p>
<p>4) field != local variable</p>
]]></content:encoded>
	</item>
</channel>
</rss>
