<?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>Reacties op: Java best practices 4 &#8211; Native Arrays and Not Using Java 5.</title>
	<atom:link href="http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/feed/" rel="self" type="application/rss+xml" />
	<link>http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/</link>
	<description>designing a new generation of software</description>
	<lastBuildDate>Wed, 10 Mar 2010 23:29:38 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Door: arjan</title>
		<link>http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/comment-page-1/#comment-91</link>
		<dc:creator>arjan</dc:creator>
		<pubDate>Wed, 05 Sep 2007 11:27:22 +0000</pubDate>
		<guid isPermaLink="false">http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/#comment-91</guid>
		<description>&lt;p&gt;&gt;You forgot one group - those of us stuck on 1.4 because&lt;br /&gt;&gt;their app is still running on Weblogic 8.1.&lt;/p&gt;&lt;p&gt;&#160;&lt;/p&gt;&lt;p&gt;Isn&#039;t that the same as saying being stuck on 1.4 since your app is still running on Tomcat 4?&lt;/p&gt;&lt;p&gt;&#160;&lt;/p&gt;&lt;p&gt;The fact is that BEA Weblogic Server 10 has been released and it (of course) supports JDK 1.5. Heck, even Weblogic 9, which has been out for quite some time, supported JDK 1.5 and even took advantage of some JDK 1.5 specific features. E.g. annotations for webservices, using the XML parser from Java 5, etc. See http://edocs.bea.com/wls/docs90/notes/new.html &lt;/p&gt;&lt;p&gt;&#160;&lt;/p&gt;&lt;p&gt;Again, some ultra conservative businesses simply never upgrade any of their software (e.g. banks still running on mainframes dating back to the 70-ties), if you&#039;re in such a business the blog obviously doesn&#039;t apply to you. But for companies that &#039;merely&#039; have a 1 year behind or 1 version behind policy there is very little excuse not the use Java 5 (including upgrades for the layers on top of it).&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>&gt;You forgot one group &#8211; those of us stuck on 1.4 because<br />&gt;their app is still running on Weblogic 8.1.</p>
<p>&nbsp;</p>
<p>Isn&#8217;t that the same as saying being stuck on 1.4 since your app is still running on Tomcat 4?</p>
<p>&nbsp;</p>
<p>The fact is that BEA Weblogic Server 10 has been released and it (of course) supports JDK 1.5. Heck, even Weblogic 9, which has been out for quite some time, supported JDK 1.5 and even took advantage of some JDK 1.5 specific features. E.g. annotations for webservices, using the XML parser from Java 5, etc. See <a href="http://edocs.bea.com/wls/docs90/notes/new.html" rel="nofollow">http://edocs.bea.com/wls/docs90/notes/new.html</a> </p>
<p>&nbsp;</p>
<p>Again, some ultra conservative businesses simply never upgrade any of their software (e.g. banks still running on mainframes dating back to the 70-ties), if you&#8217;re in such a business the blog obviously doesn&#8217;t apply to you. But for companies that &#8216;merely&#8217; have a 1 year behind or 1 version behind policy there is very little excuse not the use Java 5 (including upgrades for the layers on top of it).</p>
<p></p>
]]></content:encoded>
	</item>
	<item>
		<title>Door: Mike Miller</title>
		<link>http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/comment-page-1/#comment-89</link>
		<dc:creator>Mike Miller</dc:creator>
		<pubDate>Tue, 04 Sep 2007 20:37:09 +0000</pubDate>
		<guid isPermaLink="false">http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/#comment-89</guid>
		<description>You forgot one group - those of us stuck on 1.4 because their app is still running on Weblogic 8.1.</description>
		<content:encoded><![CDATA[<p>You forgot one group &#8211; those of us stuck on 1.4 because their app is still running on Weblogic 8.1.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Door: arjan</title>
		<link>http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/comment-page-1/#comment-88</link>
		<dc:creator>arjan</dc:creator>
		<pubDate>Tue, 04 Sep 2007 10:35:46 +0000</pubDate>
		<guid isPermaLink="false">http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/#comment-88</guid>
		<description>&lt;p&gt;Kirill, I understand what you&#039;re saying. A small percentage of highly critical application platforms are very slow in upgrading. It&#039;s not uncommon for these kind of businesses to still run on a 2.2 kernel with a Java 1.3 VM and an ancient appserver. &lt;br /&gt;&lt;br /&gt;Most companies however have a one year behind or one version behind policy, instead of a 5 years behind or a 3 versions behind policy.&lt;/p&gt;&lt;p&gt;Also, websphere itself is certified for running on JDK 5 since more than a year. See the info page about Websphere 6.1 (2006): http://www-306.ibm.com/software/webservers/appserv/was/features/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&#160;&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>Kirill, I understand what you&#8217;re saying. A small percentage of highly critical application platforms are very slow in upgrading. It&#8217;s not uncommon for these kind of businesses to still run on a 2.2 kernel with a Java 1.3 VM and an ancient appserver. </p>
<p>Most companies however have a one year behind or one version behind policy, instead of a 5 years behind or a 3 versions behind policy.</p>
<p>Also, websphere itself is certified for running on JDK 5 since more than a year. See the info page about Websphere 6.1 (2006): <a href="http://www-306.ibm.com/software/webservers/appserv/was/features/" rel="nofollow">http://www-306.ibm.com/software/webservers/appserv/was/features/</a></p>
<p>&nbsp;</p>
]]></content:encoded>
	</item>
	<item>
		<title>Door: kirill</title>
		<link>http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/comment-page-1/#comment-87</link>
		<dc:creator>kirill</dc:creator>
		<pubDate>Tue, 04 Sep 2007 08:41:52 +0000</pubDate>
		<guid isPermaLink="false">http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/#comment-87</guid>
		<description>You&#039;ve forgot one more option against Java 5 - legacy applications and EE platform. E.g. IBM Websphere Application Server is still using Java 1.4</description>
		<content:encoded><![CDATA[<p>You&#8217;ve forgot one more option against Java 5 &#8211; legacy applications and EE platform. E.g. IBM Websphere Application Server is still using Java 1.4</p>
]]></content:encoded>
	</item>
	<item>
		<title>Door: arjan</title>
		<link>http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/comment-page-1/#comment-49</link>
		<dc:creator>arjan</dc:creator>
		<pubDate>Mon, 03 Sep 2007 21:05:36 +0000</pubDate>
		<guid isPermaLink="false">http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/#comment-49</guid>
		<description>&lt;p&gt;You are indeed right about the inability to making arrays immutable. This is just one of the many consequences of not being able to code to an interface, although probably one of the most important ones. I was willing to save this example for the talk about coding to an interface, so you spoiled the excitement a bit ;)&lt;/p&gt;&lt;br/&gt;&lt;br/&gt;
&lt;p&gt;&#160;&lt;/p&gt;
&lt;p&gt;The thread-safeness issue could be attributed too to not being able to code to an interface (so a specific thread safe implementation can be passed in). On the other hand, arrays have a small advantage in thread-safeness when iterating over them. Even the best internally synchronized collection requires external synchronization when iterating (even when only readers access it). E.g. &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/util/Collections.html#synchronizedCollection(java.util.Collection)&quot; rel=&quot;nofollow&quot;&gt;Collections.synchronizedCollection&lt;/a&gt;&#039;s Javadoc states: &lt;em&gt;&quot;It is imperative that the user manually synchronize on the returned collection when iterating over it&quot; &lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&#160;&lt;/p&gt;
&lt;p&gt;Since for arrays the index is by definition managed by the code using the array (and is thus not internal to the array), it&#039;s thread-safe to iterate over a shared array when you can guarantee that only readers access it.&lt;/p&gt;
&lt;p&gt;&#160;&lt;/p&gt;
&lt;p&gt;The reifiable types issue is a good point too. I typically blame Java for this because of the type erasure. I.e. you also can&#039;t do a new T(); so it feels only logical you can&#039;t do a new T[]; either, but it&#039;s a very practical disadvantage for native arrays indeed.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&#160;&lt;/p&gt;
&lt;p&gt;There is a small workaround for this though, involving &lt;a href=&quot;http://java.sun.com/javase/6/docs/api/java/lang/reflect/Array.html#newInstance(java.lang.Class,%20int)&quot;  rel=&quot;nofollow&quot;&gt;java.lang.reflect.Array.newInstance.&lt;/a&gt; This workaround does require that code that binds generic parameters also passes a Class object in. &lt;/p&gt;&lt;p&gt;E.g. instead of writing something like: MyStructure&lt;Foo&gt; ms = new MyStructure&lt;Foo&gt;();, you would have to write MyStructure&lt;Foo&gt; ms = new MyStructure&lt;Foo&gt;(Foo.class); Inside this structure you can then use Foo.class to create a new instance and cast it to a T[]. I know it&#039;s not pretty ;)&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&#160;&lt;/p&gt;
&lt;p&gt;I agree that native arrays should as much as possible be treated as a &#039;deprecated data type&#039;, although they shouldn&#039;t be banned from the language. Data structures (like ArrayList) of course still have to use it for their internal workings.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
		<content:encoded><![CDATA[<p>You are indeed right about the inability to making arrays immutable. This is just one of the many consequences of not being able to code to an interface, although probably one of the most important ones. I was willing to save this example for the talk about coding to an interface, so you spoiled the excitement a bit <img src='http://jdevelopment.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<p>The thread-safeness issue could be attributed too to not being able to code to an interface (so a specific thread safe implementation can be passed in). On the other hand, arrays have a small advantage in thread-safeness when iterating over them. Even the best internally synchronized collection requires external synchronization when iterating (even when only readers access it). E.g. <a href="http://java.sun.com/javase/6/docs/api/java/util/Collections.html#synchronizedCollection(java.util.Collection)" rel="nofollow">Collections.synchronizedCollection</a>&#8217;s Javadoc states: <em>&quot;It is imperative that the user manually synchronize on the returned collection when iterating over it&quot; </em></p>
<p>&nbsp;</p>
<p>Since for arrays the index is by definition managed by the code using the array (and is thus not internal to the array), it&#8217;s thread-safe to iterate over a shared array when you can guarantee that only readers access it.</p>
<p>&nbsp;</p>
<p>The reifiable types issue is a good point too. I typically blame Java for this because of the type erasure. I.e. you also can&#8217;t do a new T(); so it feels only logical you can&#8217;t do a new T[]; either, but it&#8217;s a very practical disadvantage for native arrays indeed.</p>
<p>&nbsp;</p>
<p>There is a small workaround for this though, involving <a href="http://java.sun.com/javase/6/docs/api/java/lang/reflect/Array.html#newInstance(java.lang.Class,%20int)"  rel="nofollow">java.lang.reflect.Array.newInstance.</a> This workaround does require that code that binds generic parameters also passes a Class object in. </p>
<p>E.g. instead of writing something like: MyStructure&lt;Foo&gt; ms = new MyStructure&lt;Foo&gt;();, you would have to write MyStructure&lt;Foo&gt; ms = new MyStructure&lt;Foo&gt;(Foo.class); Inside this structure you can then use Foo.class to create a new instance and cast it to a T[]. I know it&#8217;s not pretty <img src='http://jdevelopment.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<p>I agree that native arrays should as much as possible be treated as a &#8216;deprecated data type&#8217;, although they shouldn&#8217;t be banned from the language. Data structures (like ArrayList) of course still have to use it for their internal workings.</p>
<p></p>
<p></p>
<p></p>
]]></content:encoded>
	</item>
	<item>
		<title>Door: Alex Miller</title>
		<link>http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/comment-page-1/#comment-37</link>
		<dc:creator>Alex Miller</dc:creator>
		<pubDate>Mon, 03 Sep 2007 18:58:50 +0000</pubDate>
		<guid isPermaLink="false">http://jdevelopment.nl/java/java-best-practices-4-native-arrays-and-not-using-java-5/#comment-37</guid>
		<description>On arrays, there are some other downsides to arrays over collections as well:1) Cannot be made immutable (esp a problem if returning local state from a class and expecting it not to be modified by the caller).&#160; 2) Cannot be made thread-safe without adding external synchronization.3) Can only contain reifiable types, which can lead to some weird situations when combined with generics (like the inability to create a new array based on a generic type).&#160; The &quot;Java Generics and Collections&quot; book goes so far as to recommend that native arrays should be treated as a &quot;deprecated data type&quot; in Java!&#160; </description>
		<content:encoded><![CDATA[<p>On arrays, there are some other downsides to arrays over collections as well:1) Cannot be made immutable (esp a problem if returning local state from a class and expecting it not to be modified by the caller).&nbsp; 2) Cannot be made thread-safe without adding external synchronization.3) Can only contain reifiable types, which can lead to some weird situations when combined with generics (like the inability to create a new array based on a generic type).&nbsp; The &quot;Java Generics and Collections&quot; book goes so far as to recommend that native arrays should be treated as a &quot;deprecated data type&quot; in Java!&nbsp;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
