<?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>sellmic.com &#187; jsr-277</title>
	<atom:link href="http://sellmic.com/blog/tag/jsr-277/feed/" rel="self" type="application/rss+xml" />
	<link>http://sellmic.com/blog</link>
	<description>Augusto's corner of art, code and fun</description>
	<lastBuildDate>Sun, 24 Jul 2011 06:25:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Classpath hell just froze over</title>
		<link>http://sellmic.com/blog/2009/06/11/classpath-hell-just-froze-over/</link>
		<comments>http://sellmic.com/blog/2009/06/11/classpath-hell-just-froze-over/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 21:09:37 +0000</pubDate>
		<dc:creator>Augusto</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[classpath]]></category>
		<category><![CDATA[jigsaw]]></category>
		<category><![CDATA[jsr-277]]></category>
		<category><![CDATA[jsr-294]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[osgi]]></category>

		<guid isPermaLink="false">http://sellmic.com/blog/?p=276</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style" addthis:url='http://sellmic.com/blog/2009/06/11/classpath-hell-just-froze-over/' addthis:title='Classpath hell just froze over' ><a class="addthis_button_facebook_like"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_compact"></a></div>&#8220;The classpath is dead&#8220; &#8230; that&#8217;s what Mark Reinhold (Principal Engineer @ Sun) said at a general session during JavaOne 2009. It&#8217;s the type of statement that should resonate with any of us who have been victims of classpath/jar hell. Mark announced this in the context of reviewing the new language features due to be [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://sellmic.com/blog/2009/06/11/classpath-hell-just-froze-over/' addthis:title='Classpath hell just froze over ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style" addthis:url='http://sellmic.com/blog/2009/06/11/classpath-hell-just-froze-over/' addthis:title='Classpath hell just froze over' ><a class="addthis_button_facebook_like"></a><a class="addthis_button_tweet"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_compact"></a></div><p style="text-align: center;"><a href="http://sellmic.com/gallery2/main.php?g2_itemId=8046"><img class="size-full wp-image-308 aligncenter" style="border: 1px solid gray;" title="Classpath Hell" src="http://sellmic.com/blog/wp-content/uploads/2009/06/classpath_hell.jpg" alt="Classpath Hell" width="589" height="399" /></a></p>
<p><em>&#8220;<strong>The classpath is dead</strong>&#8220;</em> &#8230; that&#8217;s what <a href="http://blogs.sun.com/mr/">Mark Reinhold</a> (Principal Engineer @ Sun) said at a general session during <a href="http://developers.sun.com/learning/javaoneonline/j1online.jsp?track=embedded&amp;yr=2009">JavaOne 2009</a>. It&#8217;s the type of statement that should resonate with any of us who have been victims of <a href="http://c2.com/cgi/wiki?ClasspathHell">classpath</a>/<a href="http://en.wikipedia.org/wiki/JAR_hell#JAR_hell">jar hell</a>. Mark announced this in the context of reviewing the new language features due to be released in <a href="https://jdk7.dev.java.net/">JDK 7</a> (ETA 2010) or more specifically the new Java module system codenamed <a href="http://openjdk.java.net/projects/jigsaw/">Jigsaw</a>.</p>
<h3>Module Systems and Jigsaw</h3>
<p>Jigsaw is a low level implementation of a module system, which also includes some language and VM changes that are specified in <a href="http://jcp.org/en/jsr/detail?id=294">JSR 294</a> (note that Jigsaw is being done outside of any JSR and is not a reference implementation of 294). Another implementation of a module system most Java developers are likely more familiar with is <a href="http://www.osgi.org/Main/HomePage">OSGi</a>. But what is a module system and why do we need one?</p>
<div id="attachment_322" class="wp-caption alignleft" style="width: 310px"><img class="size-full wp-image-322" title="Module dependencies" src="http://sellmic.com/blog/wp-content/uploads/2009/06/module_depencies.jpg" alt="Depencies on multiple versions (of module B in this example)" width="300" height="207" /><p class="wp-caption-text">Depencies on multiple versions (of module B in this example)</p></div>
<p>A module system enables <a href="http://en.wikipedia.org/wiki/Module_system">modular programming</a>, it allows developers to separate code into clearly defined modules that can specify what other modules they depend on and their versions, can be internally modified without breaking other modules that depend on it and can hide its own internals from external modules.</p>
<p>A module system can solve the classpath/jar hell problem by leveraging the previously mentioned features in order to allow an application to use the right versions of the set of libraries it requires. In the diagram shown here, we have an APP module that depends on the A, B and C modules. But module C also depends on B, however this dependency is to a different version of B than the one APP needs. A useful module system would then allow us to have 2 versions of the B module, with the compatible version and implementation visible to the appropriate modules (in this case APP and C).</p>
<p>Also, by clearly expressing module dependencies, we no longer have to look at random lib folders or hidden documentation when using a 3rd party library, just so we can guess what the corresponding jar files are needed to run it. With the system implemented by Jigsaw, we can simply introspect the module and let it tell us what those dependencies are. It takes the guesswork and the dark magic completely out of the equation.</p>
<p>But back to Mark&#8217;s presentation at the general session. The main reasons to introduce Jigsaw into JDK 7 are the following:</p>
<ul>
<li>Eliminate classpath complexity (classpath/jar hell problem already discussed).</li>
<li>Increase performance. The VM download size can be made smaller, and startup time should improve because for small programs (say HelloWorld) unnecessary classes don&#8217;t have to be loaded at all. Mark showed how he could run HelloWorld by only using 2 modules listed by the new <strong>jmod</strong> command; <strong>jdk.base@7-ea</strong> and <strong>jdk.boot@7-ea</strong>.</li>
<li>Enable native integration for installing modules.</li>
</ul>
<p><span id="more-276"></span>Mark demonstrated that last point by showing a demo of him installing various JDK packages via the Synaptic Package Manager.</p>
<div id="attachment_327" class="wp-caption aligncenter" style="width: 460px"><img class="size-full wp-image-327" title="Synaptic Package Manager" src="http://sellmic.com/blog/wp-content/uploads/2009/06/synaptic_package_manager.jpg" alt="Installing Java modules via Synaptic Package Manager" width="450" height="258" /><p class="wp-caption-text">Installing Java modules via Synaptic Package Manager</p></div>
<h3>Alex Buckley&#8217;s presentation</h3>
<p>I attended <a href="http://www.doc.ic.ac.uk/~abuckley/">Alex Buckley</a>&#8216;s (Computational Theologist @ Sun) session on <a href="http://developers.sun.com/learning/javaoneonline/sessions/2009/pdf/TS-4954.pdf">&#8220;Modularity in the Java Programming Language: JSR 294 and beyond&#8221;</a>, which had a lot more details on the specific language changes to be implemented in order to support this new feature.</p>
<p>The most noticeable aspect of this is the introduction of <em><strong>module-info.java</strong></em>. This file goes at the top of your module filesystem, and is the class that specifies at compile and runtime the definition of the module. Here is an example, coming from Alex&#8217;s slides;</p>
<pre name="code" class="java">module org.planetjdk.aggregator {
          system jigsaw;
          requires module jdom;
          requires module tagsoup;
          requires module rome;
          requires module rome-fetcher;
          requires module joda-time;
          requires module java-xml;
          requires module java-base;
          class org.planetjdk.aggregator.Main;
 }</pre>
<p>Our module is &#8220;<em>org.planetjdk.aggregator</em>&#8221; and uses the jigsaw module system. Depenencies are denoted by using <em>requires </em>and providing the module name, Alex calls this part of the module metadata the &#8220;<em>logical classpath</em>&#8221; of the module. You can also define the main class for the module which in this case is &#8220;<em>org.planetjdk.aggregator.Main</em>&#8220;.</p>
<p>You&#8217;ll also notice that the module name is quite long &#8220;org.planetjdk.aggregator&#8221;, while the list of required modules uses shorter names. This can be done by supplying a module alias. In the previous example, we could have added the line;</p>
<pre name="code" class="java">provides module aggregator;</pre>
<p>This would then allow other modules to say &#8220;<em>requires module aggregator</em>&#8221; and successfully link to this module by this shorter form of the name.</p>
<p>Also, you can specify your module version and version dependencies in <em>module-info.java</em>. This updated example illustrates this mechanism;</p>
<pre name="code" class="java">module org.planetjdk.aggregator @ 1.0 {
          system jigsaw;
          requires module jdom @ 1.*;
          requires module tagsoup @ 1.2.*;
          requires module rome @ =1.0;
          requires module rome-fetcher @ =1.0;
          requires module joda-time @ [1.6,2.0);
          requires module java-xml @ 7.*;
          requires module java-base @ 7.*;
          class org.planetjdk.aggregator.Main;
}</pre>
<p>Note also that you can only have one <em>module-info.java</em> per module, in only one location, so if you have a big source tree and you want to create multiple modules from it you will have to either separate your source into different trees or use some creative scripting to accomplish this at build time. I believe Mark mentioned they had to use some scripted solution for the jdk base as I believe it's one tree.</p>
<p>The rest of Alex's presentation focused on how to locate modules at compile and runtime by using the "<em>modulepath</em>", the use of the new module keyword and how it affects accessibility, and he gives a glimpse as to how they plan to support other module systems (for example, the version notation can be different when using other module systems).</p>
<p>This is all better explained in Alex's slides, so I encourage everyone to take a look at his presentation (link provided above).</p>
<h3>The Modular Java Platform: Q&amp;A</h3>
<div id="attachment_15" class="wp-caption aligncenter" style="width: 460px"><img class="size-full wp-image-15" title="round table" src="http://sellmic.com/blog/wp-content/uploads/2007/01/jury_duty.jpg" alt="Jury" width="450" height="161" /><p class="wp-caption-text">There were rumors in the meeting that the clown is a secret member of the Java Posse</p></div>
<p>Wednesday night, I attended a BOF like meeting hosted by Mark and Alex setup in order for the community to openly ask and voice any concerns over the work presented by them on modular Java. The setup was sort of a round table configuration (without the round table) in a very informal setting (btw it was hard for participants in the back to listen well, hopefully microphones are used next time). The first question was kind of funny, somebody asked Alex what a "<em><a href="http://bracha.org/Site/Theology.html">Computational Theologist</a></em>" does (the title makes it sound like the equivalent of a Thomas Aquinas for the nerd world).</p>
<p>After that, it seemed some people were very concerned about how to deploy modules, patch jars and other deployment issues. My impression was that a lot of people had a problem with the native installation part of the proposal. Mark answered that Java developers have gotten used to being in our own little jar world, separate from the OS integration issues of module and library management and that it was time for Java to integrate more with these systems. He has a point, do we really have to deploy log4j jars with all our products over and over instead of simply having a log4j installed in the system that all modules can refer to?</p>
<p>However, installation with native package systems is a big change. And it is also unclear what that is going to look like in Windows. It seemed like the Windows part of the equation has not been finalized, would Java 7 include some type of Java specific module registry or would it leverage something like .NET's <a href="http://en.wikipedia.org/wiki/Global_Assembly_Cache">Global Assembly Cache</a>?</p>
<p>Somebody bought up the point that this new system was imposing more work on open source projects. That is, today you want to release your library as a jar, you know it's going to work everywhere. With Jigsaw, projects may have to deliver a large set of native module packages depending on all the platforms they want to deploy to. Many suggested to Mark and Alex that a cross platform package format was needed, but Mark acknowledged that Sun is not really working on that and they're just worrying mainly about specifying the module file structure and leaving the rest to the native package systems.</p>
<p>I noticed a few members from the OSGi community in attendance, I recognized <a href="http://www.aqute.biz/Main/HomePage">Peter Kriens</a> (member of the OSGi Alliance), <a href="http://www.osgicongress.com/speakers_main.asp#33">Richard S. Hall</a> (From Apache Felix, works for Sun in the Glassfish team) and <a href="http://blog.bjhargrave.com/">BJ Hargrave</a> (CTO of the OSGi Alliance, committer on Eclipse Equinox and IBM employee). Peter and Richard are both members of the expert group for JSR 294, so I was a bit surprised they weren't at all in "harmony" with Mark and Alex and the work they've done with Jigsaw. See, last time I saw discussions on this topic, <a href="http://jcp.org/en/jsr/detail?id=277">JSR 277</a> was still active (it is on hold for now) and I was under the impression that Sun and OSGi had reached some type of "gentleman's agreement". That doesn't seem to be the case at all.</p>
<p>OSGi is a very mature technology and has more features than Jigsaw. However OSGi doesn't address the issue of native package installation, and you could argue that it would not be suitable to solve the issue of modularizing the JDK itself. I think on that last point, many people don't mind Jigsaw even on the OSGi side, the arguments come when you say Jigsaw could be used as an application level module system. Additionally OSGi still has some key features that are missing in Jigsaw; it allows more dynamic loading of modules (useful for plugins) and is backwards compatible (Jigsaw will only be supported from Java 7 and up).</p>
<p>Having said that, one thing I like more about Jigsaw is how it defines dependencies is the <strong><em>module-info.java</em></strong> file. It is a much better syntax than the error prone use of manifest files used in OSGi, where an extra space can break the whole thing for you. Adding keywords for module accessibility is also a very nice thing, and it seems the goal is to also let a modular system like OSGi take advantage of these features. Now how can these both systems inter-operate between each other in a single VM? I have no idea how that works ... yet.</p>
<p>In the end, the Q&amp;A showed that there is a lot of controversy and confusion over this new feature. There was also a noticeable lack of questions during the meeting, with a few of the same people asking all the questions. I got the impression that the need and functionality of a module system in Java is not generally fully understood, so to me that means a lot more work needs to be done to explain just what is going on and why there is so much effort going into this area.</p>
<p>Some key questions I'd like to see clarified:</p>
<ul>
<li>A more technical and detailed explanation of why Jigsaw was chosen over OSGi.</li>
<li>Will the JDK provide tools for wrapping modules in native packages?</li>
<li>Is a cross platform package system completely out of the question?</li>
<li>How would multiple modules systems work together in the same VM/application instance?</li>
<li>What happens when an applet or javafx application requires core JDK modules that are not present in the current installation?</li>
<li>Native library module integration issues (I sort of asked this in the Q&amp;A). Where are native packages placed, and what happens when multiple modules include the same native libraries (say 2 modules have the same DLL embedded in them)?</li>
</ul>
<h3>This doesn't affect me, why should I care?</h3>
<p>These changes will affect everybody, at the very least under the hood your core Java packages will be loaded in a more modularized fashion. For people who would like to run Java in other devices, you will notice that you have better ways to split up your Java distribution to only the parts that you need.</p>
<p>However, if you are interested in scaling your code the right way and modularizing it, you should start becoming familiar with what is going on in this space. For your applications, you'll still have the choice of using existing modular systems like OSGi or using the new facilities provided by Java 7. In the future, we should expect more details to come out as to how you can combine both (Jigsaw and OSGi). Others might prefer not to depend on an external Java project like OSGi and leverage the core support that will be provided for modules.</p>
<p>On the other hand, some people criticize that his is a repeat of the <em>java.util.logging</em> fiasco and say they can mostly ignore these changes. The jury is still out, but this is a very fundamental change in the language and platform and a very different scenario than choosing what logging package to include in the core JDK.</p>
<p>Oh and you might soon see new annoying interview or exam code questions trying to trip you up with gems like this one (from Alex's slides and <a href="http://blogs.sun.com/abuckley/en_US/entry/a_wrinkle_with_module">this blog entry</a>):</p>
<pre name="code" class="java">package module;
// BTW you should NEVER write code like this!!!
module class module {
        module module module = new
            module();
        module module() {}
}</pre>
<p>Anyways, sorry for the longish blog post but hopefully this sheds some light into some of the discussions about this topic that took place at JavaOne. If you are interested in getting more in depth details about this topic, please take a look at some of the following links;</p>
<ul> <a href="http://blogs.sun.com/theplanetarium/entry/project_jigsaw_modularizing_jdk_7">Java SE: Project Jigsaw: Modularizing JDK 7</a><br />
<a href="http://blogs.sun.com/mr/entry/jigsaw">Project Jigsaw</a> (Mark's blog)<br />
<a href="http://blogs.sun.com/mr/entry/modular_java_platform">The Modular Java Platform</a> (Mark's blog)<br />
<a href="http://blogs.sun.com/mr/entry/massive_monolithic_jdk">The massive, monolithic JDK</a> (Mark's blog)<br />
<a href="http://blogs.sun.com/mr/entry/packaging_java_code">Packaging Java code</a> (Mark's blog)<br />
<a href="http://openjdk.java.net/projects/jigsaw/doc/language.html">Project Jigsaw: Language changes for Modules</a><br />
<a href="http://www.osgi.org/blog/2008/12/project-jigsaw.html">Project Jigsaw</a> (Peter Kriens, his version of the "saga of Java modularity)<br />
<a href="http://www.osgi.org/blog/2008_12_01_archive.html">Project Jigsaw #2</a> (Peter Kriens, some criticisms of the proposed system)<br />
<a href="http://www.osgi.org/blog/2009/03/project-jigsaw-3.html">Project Jigsaw #3</a> (Peter Kriens, Jigsaw != JSR 294)<br />
<a href="http://www.infoq.com/news/2008/12/jigsaw-jsr277-dead">Jigsaw - the death knell of JSR277?</a><br />
<a href="http://atsatt.blogspot.com/2009/04/jigsaw-vs-osgi.html">Jigsaw vs OSGi?</a><br />
<a href="http://blogs.sun.com/abuckley/en_US/entry/a_wrinkle_with_module">A wrinkle with 'module'</a> (Alex's blog)<br />
<a href="http://blogs.sun.com/abuckley/resource/Devoxx2008-ModularityInJava.pdf">Modularity in Java</a> (Alex's presentation at DEVOXX 2008; covers module friendship, "virtual modules", multi-module packages, type observability and other topics not covered in the JavaOne slides I linked to in this article)</ul>
<p><strong>Update</strong>. Some additional links that have come to my attention after publishing this blog post;</p>
<ul>
<a href="http://robilad.livejournal.com/51325.html">Jigsaw Feedback Roundup</a> (Dalibor Topic)<br />
<a href="http://javaposse.com/index.php?post_id=492239">Java Posse #259 - Jigsaw and JSR 294 Interview</a> (Java Posse podcast interview with Mark Reinhold and Alex Buckley)
</ul>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://sellmic.com/blog/2009/06/11/classpath-hell-just-froze-over/' addthis:title='Classpath hell just froze over ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://sellmic.com/blog/2009/06/11/classpath-hell-just-froze-over/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

