<?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>The Dumping Ground &#187; Java</title>
	<atom:link href="http://ardvaark.net/category/technology/java/feed" rel="self" type="application/rss+xml" />
	<link>http://ardvaark.net</link>
	<description>And who cares?</description>
	<lastBuildDate>Thu, 19 Jan 2012 16:29:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How To Make Java Ignore IPv6</title>
		<link>http://ardvaark.net/how-to-make-java-ignore-ipv6</link>
		<comments>http://ardvaark.net/how-to-make-java-ignore-ipv6#comments</comments>
		<pubDate>Sun, 11 Oct 2009 03:43:53 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[ipv4]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[jaunty]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://ardvaark.net/?p=764</guid>
		<description><![CDATA[Sure, IPv6 is going to save us all from the apocalypse, defeat communism, cure the swine flu, and bake you the most delicious brownies you’ve ever tasted.  Someday.  But in the meantime, for real people trying to do real work, it’s a fucking nuisance. As more systems have started shipping with the technology, little compatibility [...]]]></description>
			<content:encoded><![CDATA[<p>Sure, IPv6 is going to save us all from the apocalypse, defeat communism, cure the swine flu, and bake you the most delicious brownies you’ve ever tasted.  Someday.  But in the meantime, for real people trying to do real work, it’s a fucking nuisance.</p>
<p>As more systems have started shipping with the technology, little compatibility issues continue to crop up.  One of the more recurrent problems I’ve encountered is incompatibilities between Java and IPv6 on Linux – specifically Ubuntu.  Up until recently, it was quite easy to eliminate the problem by merely blacklisting the appropriate kernel modules, thusly:</p>
<p>
<p class="code"># echo 'blacklist net-pf-10' &gt;&gt; /etc/modprobe.d/blacklist.conf
# echo 'blacklist ipv6' &gt;&gt; /etc/modprobe.d/blacklist.conf
</p>
<p>However, as of Ubuntu 9.04 (Jaunty), IPv6 support is no longer a module – it’s hard-compiled into the shipping kernels.  No big deal, though, because there’s a system control variable that allows you to remove IPv6 support from the kernel.</p>
<p>
<p class="code"># echo 1 &gt; /proc/sys/net/ipv6/conf/all/disable_ipv6</p>
</p>
<p>Except that doesn’t work.  It seems there was a kernel bug where that setting was just plain broken.  And it hasn’t been shipped with the normal Ubuntu kernels yet.  So, what is one to do, short of re-compiling their own kernel?</p>
<p>Here is a copy-paste from an IM exchange I had with Java earlier:</p>
<blockquote><p>
# Java has entered the chat.</p>
<p>Java: Hey dude, what&#8217;s up?</p>
<p>Ardvaark: hey, i&#8217;m having a problem getting you to listen to an ipv4 socket when ipv6 is installed on my ubuntu box</p>
<p>Java: Yeah! I totally support IPv6 now! You didn&#8217;t even have to do anything because I abstract you from the OS details!  Isn&#8217;t that great?!</p>
<p>Ardvaark: awesome, i guess, except that it doesn&#8217;t work.</p>
<p>Ardvaark: i really need you to just listen on ipv4, because the tivo just doesn&#8217;t like <a href="http://galleon.sourceforge.net/">galleon</a> on ipv6</p>
<p>Ardvaark: so sit the hell down, shut the hell up, and use ipv4</p>
<p>Ardvaark: pretty please</p>
<p>Java: Okay, geez, no need to get all pissy about it.</p>
<p>Ardvaark: and while you&#8217;re at it, could  you please stop using like half a gig RAM just for a silly hello world program?</p>
<p>Java: Don&#8217;t push your luck.</p>
<p># Java has left the chat.
</p></blockquote>
<p>And now that we’re back in reality, the magic word is <span class="code">-Djava.net.preferIPv4Stack=true.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://ardvaark.net/how-to-make-java-ignore-ipv6/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hadoop World 2009</title>
		<link>http://ardvaark.net/hadoop-world-2009</link>
		<comments>http://ardvaark.net/hadoop-world-2009#comments</comments>
		<pubDate>Mon, 05 Oct 2009 14:05:00 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Digital Libraries]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[2009]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[hadoop]]></category>
		<category><![CDATA[hadoop world]]></category>

		<guid isPermaLink="false">http://ardvaark.net/hadoop-world-2009</guid>
		<description><![CDATA[I had the privilege of attending Hadoop World 2009 on Friday.&#160; It was amazing to meet, listen to, and pick the brains of so many smart people.&#160; The quantity of good work being done on this project is simply stunning, but it is equally stunning how much farther there remains to go.&#160; Some interesting points [...]]]></description>
			<content:encoded><![CDATA[<p>I had the privilege of attending Hadoop World 2009 on Friday.&#160; It was amazing to meet, listen to, and pick the brains of so many smart people.&#160; The quantity of good work being done on this project is simply stunning, but it is equally stunning how much farther there remains to go.&#160; Some interesting points for me include:</p>
<h3>Yahoo’s Enormous Clusters</h3>
<p>Eric Baldeschwieler from Yahoo gave an impressive talk about what they’re doing with Hadoop.&#160; Yahoo is running clusters at a simply amazing scale.&#160; They have several different clusters, totally some 86 PB of disk space, but their largest is a 4000-node cluster with 16 PB of disk, 64 TB of RAM, and 32,000 CPU cores.&#160; One of the most compelling points they made was that Yahoo’s experiences prove that Hadoop really does scale as designed.&#160; If you start with a small grid now, you can be sure that it will scale up – way up.</p>
<p>Eric made it clear that Yahoo uses Hadoop because it so vastly improves the productivity of their engineers.&#160; He noted that, though the hardware is commodity, the grid isn’t necessarily a cheaper solution; however, it easily pays for itself through the increased turnaround on problems.&#160; In the old days, it was difficult for engineers to try out new ideas, but now you can try out a Big Data idea in a few hours, and see how it goes.</p>
<p>A great example is the search suggestion on the front page.&#160; Using Hadoop, they cut the time to generate the search suggestions on the front page from 26 days to 20 minutes.&#160; Wow!&#160; For the icing on the cake, the code was converted from C++ to Python, and development time went from 2-3 weeks to 2-3 days.</p>
<h3>HDFS For Archiving</h3>
<p>HDFS hasn’t been used much as an archival system yet, especially not with the time horizons of someplace like <a title="Library of Congress" href="http://loc.gov">my employer</a>.&#160; When I asked him about it, Eric told me that the oldest data on Yahoo’s clusters is not much more than a year old.&#160; Ironically, they tend to be concerned more about <em>removing</em> data from the servers due to legal mandates and privacy requirements, rather than keeping it around for a Very Long Time.&#160; But he sees the need to hold some data for longer periods coming soon, and has promised he’ll be thinking about it.</p>
<p>Facebook, though, is already making moves in this area.&#160; They currently “back up” their production HDFS grid using Hive replication to a secondary grid, but they are working on (or already have – it wasn’t quite clear how far along this all was) an “archival cluster” solution.&#160; A daemon would scan for least-recently used files and opportunistically move them to a cluster built with more storage-heavy nodes, leaving a symlink stub in place of the file.&#160; When a request for that stub file comes in, the daemon intercepts it and begins pulling the data back off the archive grid.&#160; This is quite similar to how SAM-QFS works today.&#160; I had a chance to speak with with Dhruba Borthakur for a bit afterwards, and he had some interesting ideas about modifying the HDFS block scheduler to make it friendly for something like MAID.</p>
<p>Jaesun Han from NexR gave a talk on Terapot, a system for long-term storage and discovery of emails due to legal requirements and litigation.&#160; I asked him about whether they were relying on HDFS as their primary storage mechanism, or if they “backed up” to some external solution.&#160; He laughed, and said that they weren’t using one now, but would probably get some sort of tape solution in the near future.&#160; He also said that he believed HDFS was quite capable of being the sole archival solution, and I believe he was implying that it was fear from the legal and/or management folks that was driving a “back up” solution.&#160; At this point, the Cloudera CTO noted that both Yahoo and Facebook had no “back up” solution for HDFS, except for other HDFS clusters.&#160; It certainly seems like at least a couple multi-million dollar companies are willing to put their data where their mouth is on the reliability of HDFS.</p>
<h3>What’s Coming</h3>
<p>There is a tremendous sense that Hadoop has really matured in the last year or so.&#160; But it’s also been noted that the APIs are still thrashing a bit, and it’s still awfully Java-centric.&#160; Now that the underlying core is pretty solid, it seems like a lot of the work is moving towards making your Hadoop grid accessible to the rest of the company – not just the uber-geek Java coders.</p>
<p>Doug Cutting talked about how they’re working on building some solid, future-proof APIs for 0.21.&#160; Included in this is switching the RPC format to <a title="Apache Hadoop: Avro" href="http://hadoop.apache.org/avro/">Avro</a>, which is intended to solve some of the underlying issues with <a title="Apache Thrift" href="http://incubator.apache.org/thrift/">Thrift</a> and <a title="Google Code: Protocol Buffers" href="http://code.google.com/p/protobuf/">Protocol Buffers</a> while opening up the RPC and data format to a broader class of languages.&#160; It’s worth noting that Avro and JSON are pretty easily transcoded to one another.&#160; Also, they’ll finally be putting some serious thought into a real authentication and authorization scheme.&#160; Yahoo (I think) mentioned Kerberos – let’s hope we get some OpenID up in that joint, too.</p>
<p>There is a sudden push towards making Hadoop accessible via various UIs.&#160; Cloudera introduced their <a title="Cloudera: Hadoop Desktop" href="http://www.cloudera.com/desktop">Hadoop Desktop</a>, Karmasphere gave a whirlwind tour of their <a title="Karmasphere Studio" href="http://www.karmasphere.com/products/">Netbeans-based IDE</a>, and IBM was showing off a spreadsheet metaphor on top of Hadoop called M2 (I can’t find any good links for it).&#160; I hadn’t thought about that before, and it seemed so simple it was brilliant; Doug Cutting mentioned the idea, too, so it has some cachet.</p>
<h3>Final Thoughts</h3>
<p>It is worth noting that Facebook seems to be driving a lot of the really cool backend stuff, and people are noticing.&#160; That’s not to say other organizations aren’t doing cool things, but during the opening presentations, <a title="Ardvaark&#39;s Twitter" href="http://twitter.com/Ardvaark/status/4555117386">Facebook got all the questions</a>.&#160; I mean, Dhruba recently <a title="Apache JIRA: Hadoop HDFS:  Implement erasure coding as a layer on HDFS" href="http://issues.apache.org/jira/browse/HDFS-503">posted a patch adding error-correcting codes on top of HDFS</a>.&#160; How cool is that?!</p>
]]></content:encoded>
			<wfw:commentRss>http://ardvaark.net/hadoop-world-2009/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multi-Threading with VFS</title>
		<link>http://ardvaark.net/multi-threading-with-vfs</link>
		<comments>http://ardvaark.net/multi-threading-with-vfs#comments</comments>
		<pubDate>Thu, 14 May 2009 15:32:19 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Digital Libraries]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[apache commons]]></category>
		<category><![CDATA[bagit]]></category>
		<category><![CDATA[threading]]></category>
		<category><![CDATA[vfs]]></category>

		<guid isPermaLink="false">http://ardvaark.net/multi-threading-with-vfs</guid>
		<description><![CDATA[One of the new features in the BagIt Library will be multi-threading CPU-intensive bag processing operations, such as bag creation and verification.  Modern processors are all multi-core, but because the current version of the BagIt Library is not utilizing those cores, bag operations take longer than they should.  The new version of BIL should create [...]]]></description>
			<content:encoded><![CDATA[<p>One of the new features in the <a title="Library of Congress Transfer Utilities on SourceForge" href="https://sourceforge.net/projects/loc-xferutils">BagIt Library</a> will be multi-threading CPU-intensive bag processing operations, such as bag creation and verification.  Modern processors are all multi-core, but because the current version of the BagIt Library is not utilizing those cores, bag operations take longer than they should.  The new version of BIL should create and verify bags significantly faster than the old version.  Of course, as we add CPUs, we shift the bottleneck to the hard disk and IO bus, but it’s an improvement nonetheless.</p>
<p>Writing proper multi-threaded code is a tricky proposition, though.  Threading is a notorious minefield of subtle errors and difficult-to-reproduce bugs.  When we turned on multi-threading in our tests, we ran into some interesting issues with the <a title="Apache Commons VFS" href="http://commons.apache.org/vfs/index.html">Apache Commons VFS library</a> we use to keep track of file locations.  It turns out that VFS is not really designed to be thread-safe.  Some <a title="Email Thread: Status of current snapshot build" href="http://www.mail-archive.com/user@commons.apache.org/msg02718.html">recent list traffic</a> seems to indicate that this might be fixed sometime in the future, but it’s certainly not the case now.</p>
<p>Now, we don’t want to lose VFS – it’s a huge boon.  Its support for various serialization formats and virtual files makes modeling serialized and holey bags a lot easier.  So we had to figure out how to make VFS work cleanly across multiple threads.</p>
<p>The <a title="FileSystemManager JavaDoc" href="http://commons.apache.org/vfs/apidocs/org/apache/commons/vfs/FileSystemManager.html">FileSystemManager</a> is the root of one’s access to the VFS API.  It does a lot of caching internally, and the child objects coming from its methods often hold links back to each other via the <span class="code">FileSystemManager</span>.  If you can isolate a <span class="code">FileSystemManager</span> object per-thread, then you should be good to go.</p>
<p>The usual way of obtaining a VFS is through the <a title="VFS.getManager() Javadoc" href="http://commons.apache.org/vfs/apidocs/org/apache/commons/vfs/VFS.html#getManager()">VFS.getManager()</a> method,which returns a singleton <span class="code">FileSystemManager</span> object.  Our solution was to replace the singleton call with a <a title="ThreadLocal Javadoc" href="http://java.sun.com/javase/6/docs/api/java/lang/ThreadLocal.html">ThreadLocal</a> variable, with the <a title="ThreadLocal.initialValue() Javadoc" href="http://java.sun.com/javase/6/docs/api/java/lang/ThreadLocal.html#initialValue()">initialValue() method</a> overloaded to create and initialize a new <a title="VFS StandardFileSystemManager Javadoc" href="http://commons.apache.org/vfs/apidocs/org/apache/commons/vfs/impl/StandardFileSystemManager.html">StandardFileSystemManager</a>.  The code for that looks like this.</p>
<p>
<p class="code">private static final ThreadLocal<FileSystemManager> fileSystemManager = new ThreadLocal<FileSystemManager>() { 
    @Override 
    protected FileSystemManager initialValue() { 
        StandardFileSystemManager mgr = new StandardFileSystemManager(); 
        mgr.setLogger(LogFactory.getLog(VFS.class)); 

        try 
        { 
            mgr.init(); 
        } 
        catch (FileSystemException e) 
        { 
            log.fatal("Could not initialize thread-local FileSystemManager.", e); 
        } 

        return mgr; 
    } 
};
</p>
</p>
<p>The downside is that we lose the internal VFS caching that the manager does (although it still caches inside of a thread).  But that’s a small price to pay for it working.</p>
]]></content:encoded>
			<wfw:commentRss>http://ardvaark.net/multi-threading-with-vfs/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Funny Smelling Code &#8211; Endlessly Propagating Parameters</title>
		<link>http://ardvaark.net/funny-smelling-code-endlessly-propagating-parameters</link>
		<comments>http://ardvaark.net/funny-smelling-code-endlessly-propagating-parameters#comments</comments>
		<pubDate>Fri, 08 May 2009 12:45:48 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Digital Libraries]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[bagit]]></category>
		<category><![CDATA[code smell]]></category>
		<category><![CDATA[loc]]></category>

		<guid isPermaLink="false">http://ardvaark.net/funny-smelling-code-endlessly-propagating-parameters</guid>
		<description><![CDATA[We’re currently working on a new version of the BagIt Library: adding some new functionality, making some bug fixes, and refactoring the interfaces pretty heavily.&#160; If you happen to be one of the people currently using the programmatic interface, the next version will likely break your code.&#160; Sorry about that. The BagIt spec is pretty [...]]]></description>
			<content:encoded><![CDATA[<p>We’re currently working on a new version of the <a title="Library of Congress Transfer Tools on SourceForge" href="https://sourceforge.net/projects/loc-xferutils/">BagIt Library</a>: adding some new functionality, making some bug fixes, and refactoring the interfaces pretty heavily.&#160; If you happen to be one of the people currently using the programmatic interface, the next version will likely break your code.&#160; Sorry about that.</p>
<p>The <a title="The BagIt File Packaging Format (V0.96)" href="http://tools.ietf.org/html/draft-kunze-bagit-03">BagIt spec</a> is pretty clear about what makes a bag valid or complete, and it might seem a no-brainer to strictly implement validation based on the spec.&#160; Unfortunately, the real-world is not so simple.&#160; For example, the spec is unambiguous about the required existence of the <span class="code">bagit.txt</span>, but we have real bags on-disk (from before the spec existed) that lack the bag declaration and yet need to be processed.&#160; As another example, hidden files are not mentioned at all by the spec, and the current version of the code treats them in an unspecified manner.&#160; On Windows, when the bag being validated has been checked out from Subversion, the hidden <span class="code" span="span">.svn</span> folders cause unit tests to fail all over the place.</p>
<p>It seems an easy enough feature to add some flags to make the bag processing a bit more lenient.&#160; In fact, the <span class="code">checkValid()</span> method already had an overloaded version which took a boolean indicating whether or not to tolerate a missing bagit.txt.&#160; I began by creating an enum which contained two flags (<span class="code">TOLERATE_MISSING_DECLARATION</span> and <span class="code">IGNORE_HIDDEN_FILES</span>), and began retrofitting the enum in place of the boolean.</p>
<p>And then I got <a title="CodeSmell on Martin Fowler&#39;s Bliki" href="http://martinfowler.com/bliki/CodeSmell.html">a whiff</a>.</p>
<p>I found that, internally, the various validation methods call one another, passing the same parameters over and over.&#160; Additionally, the validation methods weren’t using any privileged internal information during processing – only public methods were being called.</p>
<p>I called Justin this morning to discuss refactoring the validation operations using a <a title="Strategy pattern on Wikipedia" href="http://en.wikipedia.org/wiki/Strategy_pattern">Strategy pattern</a>.&#160; This would allow us to:</p>
<ol>
<li>Encapsulate the parameters to the algorithm, making the code easier to read and maintain.&#160; No more long lists of parameters passed from function call to function call.</li>
<li>Vary the algorithm used for processing based on the needs of the caller.</li>
<li>Re-use standard algorithm components (either through aggregation or inheritance), simplifying one-off cases.</li>
</ol>
<p>He had also come to the same conclusion, although driven by a different parameter set.&#160; It’s a good sign you’re headed in the right direction when two developers independently hacking on the code come up with the same solution to the same problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://ardvaark.net/funny-smelling-code-endlessly-propagating-parameters/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adventures in Enormous Lucene Indexes on AIX</title>
		<link>http://ardvaark.net/adventures-in-enormous-lucene-indexes-on-aix</link>
		<comments>http://ardvaark.net/adventures-in-enormous-lucene-indexes-on-aix#comments</comments>
		<pubDate>Sat, 30 Sep 2006 18:05:37 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Digital Libraries]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I have been working hard over the last several weeks to port our system at work from our x86 Linux development environment to the PowerPC AIX production environment. Fortunately for us, most of the platform differences are well hidden because our code is generally platform independent: Java, XSLT, and JavaScript. There are a few cases [...]]]></description>
			<content:encoded><![CDATA[<p>I have been working hard over the last several weeks to port our system at work from our x86 Linux development environment to the PowerPC AIX production environment.  Fortunately for us, most of the platform differences are well hidden because our code is generally platform independent: Java, XSLT, and JavaScript.  There are a few cases where we make calls to a JNI library, but the libraries exist and are supported for the varying platforms, and we have had no trouble with those.</p>
<p>What we unexpectedly had trouble with, though, was our fulltext Lucene index.  Weighing in at a massive 55 GB, and only expected to get bigger, we were duly impressed at our development environment&#8217;s ability to process the index with no hiccups, in addition to consistently speedy search times.  When I moved it to AIX, however, something went amiss.  We started receiving this exception, which the stack trace revealed was coming from Lucene&#8217;s index reading code:</p>
<p><code>java.io.IOException: Unknown format version:-16056063</code></p>
<p>We confirmed with MD5 hashes that the files were identical in both environments, and we confirmed that the Lucene libraries were all correct.  That left us with some obscure platform difference we had to track down.</p>
<p>Using a smaller test index, we were able to confirm that Lucene was able to successfully open an index on AIX, confirming Lucene&#8217;s own touted endian agnosticism.  We also lifted file write size ulimits on certain users to confirm that that limit didn&#8217;t unintentionally affect the ability to read files as well.</p>
<p>Finally, we discovered through some documentation (of all places!) that 32-bit IBM programs are limited to file reads of no more than ~2 GB &#8211; that magic 2^31 &#8211; 1 limit &#8211; and our Java virtual machine was only 32-bit!  Simply upgrading to the 64-bit JVM solved the problem.</p>
<p>We hadn&#8217;t thought of this because we were using a 32-bit JVM in development, with no problems, but the crucial difference is that it was the Sun JVM.  We later installed the 32-bit IBM JVM onto a development environment and confirmed that it cannot open our index file there, either.  Notably, however, it provided a much more useful error message:</p>
<p><code>java.io.IOException: Value too large for defined data type<br />
         at java.io.RandomAccessFile.length(Native Method)<br />
         at org.apache.lucene.store.FSIndexInput.<init>(FSDirectory.java:440)</code></p>
<p>Rather than throwing an IOException from the <code>java.io</code> code, the IBM JVM on AIX simply returned bogus data.  This caused Lucene&#8217;s index reader to throw an exception because, coincidentally, the number it was trying to read at that magic signed integer limit was expected to be a file version number.  It was expecting to see -1, but instead got -16056063.</p>
<p>And so everything seems to running swimmingly now.  The moral of the story is: Beware of big files on 32-bit machines.</p>
]]></content:encoded>
			<wfw:commentRss>http://ardvaark.net/adventures-in-enormous-lucene-indexes-on-aix/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Published vs. Public</title>
		<link>http://ardvaark.net/published-vs-public</link>
		<comments>http://ardvaark.net/published-vs-public#comments</comments>
		<pubDate>Wed, 05 Apr 2006 14:16:38 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I&#8217;m really like the idea of separating published interfaces from public interfaces. Apparently, a JSR has been started to add an idea like this to Java. In this case, the idea is to provide superpackage, and the initially proposed syntax (taken from that site) is something like: super package com.sun.myModule { export com.sun.myModule.myStuff.*; export com.sun.myModule.yourStuff.Interface; [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m really like the idea of <a href="http://martinfowler.com/bliki/PublishedInterface.html" title="PublishedInterface">separating published interfaces from public interfaces</a>.  Apparently, a <a href="http://blogs.sun.com/roller/page/gbracha?entry=developing_modules_for_development" title="Developing Modules for Development">JSR has been started</a> to add an idea like this to Java.  In this case, the idea is to provide <tt>superpackage</tt>, and the initially proposed syntax (taken from that site) is something like:</p>
<p><code><br />
super package com.sun.myModule<br />
{<br />
   export com.sun.myModule.myStuff.*;<br />
   export com.sun.myModule.yourStuff.Interface;<br />
   com.sun.myModule.myStuff;<br />
   com.sun.myModule.yourStuff;<br />
   com.sun.SomeOtherModule.theirStuff;<br />
   org.someOpenSource.someCoolStuff;<br />
}<br />
</code></p>
<p>Despite the author&#8217;s numerous warnings that this syntax is arbitrary and just for exemplifying the general idea, I have to say this syntax sucks.  How about we just reuse the <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html" title="Annotations">recently introduced support for annotations</a> and add a <a href="http://ardvaark.net/publishedattribute.html" title="PublishedAttribute">Published attribute</a> to Java.  No need to change the language, no need to add another arbitrary source file.  No mess, no fuss.</p>
<p>(via <a href="http://lambda-the-ultimate.org/node/1400" title="Lambda the Ultimate">LtU</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://ardvaark.net/published-vs-public/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Suppressing Deprecation Warnings in Import Statements</title>
		<link>http://ardvaark.net/suppressing-deprecation-warnings-in-import-statements</link>
		<comments>http://ardvaark.net/suppressing-deprecation-warnings-in-import-statements#comments</comments>
		<pubDate>Tue, 13 Dec 2005 02:23:59 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I&#8217;ve got an import statement that references a deprecated class. However, it&#8217;s old and tested, and I don&#8217;t want to change it. For a long time, I annoyed the nagging warnings about such problems because there wasn&#8217;t anything I could do about them. Along comes Java 1.5 with support for annotations (that&#8217;s attributes for you [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve got an import statement that references a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Deprecated.html">deprecated</a> class.  However, it&#8217;s old and tested, and I don&#8217;t want to change it.  For a long time, I annoyed the nagging warnings about such problems because there wasn&#8217;t anything I could do about them.</p>
<p>Along comes Java 1.5 with support for <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html">annotations</a> (that&#8217;s <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vclrfintroductiontoattributes.asp">attributes</a> for you .NET folk).  In particular, the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/SuppressWarnings.html">SuppressWarnings</a> attribute provides the ability to selectively disable warnings &#8211; precisely what I want.</p>
<p>So I&#8217;ve got something like this:</p>
<p><code><br />
package foo;</p>
<p>import old.package.OldClass;</p>
<p>@SuppressWarnings("deprecation")<br />
public class Bar<br />
{<br />
   private OldClass iAmDeprecated;<br />
}<br />
</code></p>
<p>And everything works great, except for that pesky import statement.  It still tosses a warning at me, and I can&#8217;t get it to go away!  Putting the attribute into the <a href="http://www.onjava.com/pub/a/onjava/2004/04/21/declarative.html?page=3">package-info.java</a> file doesn&#8217;t work, either, because the <code>SuppressWarnings</code> attribute isn&#8217;t declared as a <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/annotation/ElementType.html#PACKAGE">package</a> annotation <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/annotation/Target.html">target</a>.</p>
<p>For now, I&#8217;ve worked around the problem by removing the import and fully quaifying the class name in my code, but that&#8217;s lame.  If anybody knows the &#8220;right&#8221; way to do this, please <a href="/user/1/contact">contact me</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ardvaark.net/suppressing-deprecation-warnings-in-import-statements/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

