{"id":607,"date":"2011-08-04T22:48:52","date_gmt":"2011-08-05T02:48:52","guid":{"rendered":"http:\/\/efsavage.com\/blog\/?p=607"},"modified":"2011-08-04T23:28:35","modified_gmt":"2011-08-05T03:28:35","slug":"java-7","status":"publish","type":"post","link":"https:\/\/efsavage.com\/blog\/posts\/java-7\/","title":{"rendered":"Java 7"},"content":{"rendered":"<p>Java 7 (AKA Java 1.7.0) is out!  What does this mean, is this a Big Deal like Java 3 or 5 or a snoozer like Java 6 or something in the middle like Java 4?  It all depends on what you do with it, but for most Java developers, we&#8217;re looking at a Java 4-ish release.  There are some new APIs, and some really nice syntax cleanup, but ultimately it&#8217;s not a big deal.<\/p>\n<p>Here&#8217;s the list of what&#8217;s changed:<\/p>\n<h2>The stuff I hope I don&#8217;t have to care about (AKA The Boring Stuff)<\/h2>\n<p>These are the under-the-hood changes I will probably only encounter when debugging someone else&#8217;s code.<\/p>\n<h4>Strict class-file checking<\/h4>\n<p>I&#8217;m not entirely sure what this is, and it doesn&#8217;t seem like too many other people are either. \u00a0I think it means that Java 7 files have to declare themselves as different than previous versions and do some pre-verification as part of compilation. \u00a0I don&#8217;t know if this is actually something new or just declared baggage.<\/p>\n<blockquote><p>As specified in JSR 202, which was part of Java SE 6, and in the recently-approved maintenance revision of JSR 924, class files of version 51 (SE 7) or later must be verified with the typechecking verifier; the VM must not fail over to the old inferencing verifier.<\/p><\/blockquote>\n<h4>Upgrade class-loader architecture<\/h4>\n<p>Fixes some deadlock issues when writing non-hierarchal custom classloaders. \u00a0If you&#8217;re writing custom classloaders, this is probably great news. \u00a0Unfortunately if you&#8217;re writing custom classloaders you&#8217;re pretty much screwed with or without this improvement.<\/p>\n<p>More information <a href=\"http:\/\/openjdk.java.net\/groups\/core-libs\/ClassLoaderProposal.html\" target=\"_blank\">here<\/a>.<\/p>\n<h4>Method to close a URLClassLoader<\/h4>\n<p>Pretty self-explanatory. \u00a0if you&#8217;re using a\u00a0URLClassLoader, you may at some point want to close it. \u00a0Now you can.<\/p>\n<p>More information <a href=\"http:\/\/blogs.oracle.com\/CoreJavaTechTips\/entry\/closing_a_urlclassloader\" target=\"_blank\">here<\/a>.<\/p>\n<h4>SCTP (Stream Control Transmission Protocol)<\/h4>\n<p>From what I can gather SCTP is somewhere between UDP&#8217;s lightweight &#8220;spray and pray&#8221; approach and TCP&#8217;s heavy-duty &#8220;armored convoy&#8221;. \u00a0Seems like a good choice for modern media narrowcasting and always-on sensor networks, but don&#8217;t quote me on that.<\/p>\n<p>More information\u00a0<a href=\"`java.sun.com\/developer\/technicalArticles\/javase\/jdk7-sctp\/\" target=\"_blank\">here<\/a>.<\/p>\n<h4>SDP (Sockets Direct Protocol)<\/h4>\n<blockquote><p>Implementation-specific support for reliable, high-performance network streams over Infiniband connections on Solaris and Linux.<\/p><\/blockquote>\n<p>SDP and\/or Infiniband seem to networking where you can get more throughput by bypassing the nosy TCP stack, but without completely ignoring it. \u00a0Kind of like flashing your badge to the security guard and letting all your friends in, I think?<\/p>\n<p>More information\u00a0<a href=\"http:\/\/www.rdmaconsortium.org\/home\/SDP_tutorial_v1.0d.pdf\" target=\"_blank\">here<\/a>.<\/p>\n<h4>Use the Windows Vista IPv6 stack<\/h4>\n<p>I&#8217;m assuming that this also applies to Windows 7, but I&#8217;ll worry about this when my great-grandkids finally make the switch to IPv6 in 2132.<\/p>\n<h4>TLS 1.2<\/h4>\n<p>Better than TLS 1.1! (TLS 1.2 is\u00a0SSL 3.3).<\/p>\n<p>More information\u00a0<a href=\"http:\/\/en.wikipedia.org\/wiki\/Transport_Layer_Security#TLS_1.2_.28SSL_3.3.29\" target=\"_blank\">here<\/a>.<\/p>\n<h4>Elliptic-curve cryptography (ECC)<\/h4>\n<p>The official description sums it up:<\/p>\n<blockquote><p>A portable implementation of the standard Elliptic Curve Cryptographic (ECC) algorithms, so that all Java applications can use ECC out-of-the-box.<\/p><\/blockquote>\n<h4>XRender pipeline for Java 2D<\/h4>\n<p>Now, when you aren&#8217;t gaming, you can \u00a0leverage some of your GPU power to do image rendering and manipulation in Java instead of just mining BitCoins.<\/p>\n<h4>Create new platform APIs for 6u10 graphics features<\/h4>\n<p>Let&#8217;s you use opacity and non-rectangluar shapes in your Java GUI apps.<\/p>\n<p>More information\u00a0<a href=\"http:\/\/java.sun.com\/developer\/technicalArticles\/GUI\/translucent_shaped_windows\/\" target=\"_blank\">here<\/a>.<\/p>\n<h4>Nimbus look-and-feel for Swing<\/h4>\n<p>Your Swing apps can now look like outdated OS X apps.<\/p>\n<p>More information\u00a0<a href=\"http:\/\/download.oracle.com\/javase\/tutorial\/uiswing\/lookandfeel\/nimbus.html\" target=\"_blank\">here<\/a>.<\/p>\n<h4>Swing JLayer component<\/h4>\n<p>Useful way to write less spaghetti when trying to make Java GUI apps behave like other modern frameworks.<\/p>\n<p>More information\u00a0<a href=\"http:\/\/www.pbjar.org\/blogs\/jxlayer\/jxlayer40\/\" target=\"_blank\">here<\/a>.<\/p>\n<h4>Gervill sound synthesizer<\/h4>\n<p>Looks like a decent audio synthesis toolkit. \u00a0Not sure if this really needs to be in the JDK but now you can add reverb to your log file monitor&#8217;s beeping.<\/p>\n<p>More information\u00a0<a href=\"http:\/\/java.net\/projects\/gervill\/pages\/Home\" target=\"_blank\">here<\/a>.<\/p>\n<h2>The important stuff I don&#8217;t really use\u00a0(AKA The Stuff I&#8217;m Glad Someone Thought Of)<\/h2>\n<p>These are the changes that probably only help if you&#8217;re on the cutting edge of certain facets of using Java. \u00a0Eventually these will probably benefit us all but I doubt many people were waiting for these.<\/p>\n<h4>Unicode 6.0<\/h4>\n<p>Also self-explanatory, new version of Unicode. \u00a0Has the new Indian Rupee Sign (?) and over 2,000 other new glyphs, so it&#8217;s certainly important if you use those, but otherwise not so much. \u00a0I don&#8217;t know enough about switching versions of Unicode to say if this is something to be worried about, but if you have lots of it in your app, it&#8217;s probably safe to say you should do some major tests before switching.<\/p>\n<p>More information <a href=\"http:\/\/unicode.org\/versions\/Unicode6.0.0\/\" target=\"_blank\">here<\/a>.<\/p>\n<h4>Locale enhancement<\/h4>\n<p style=\"text-align: justify;\">Locale was previously based on <a href=\"http:\/\/www.ietf.org\/rfc\/rfc1766.txt\" target=\"_blank\">RFC 1766<\/a>, now it is based on <a href=\"http:\/\/tools.ietf.org\/html\/bcp47\" target=\"_blank\">BCP 47<\/a> and <a href=\"http:\/\/unicode.org\/reports\/tr35\/\" target=\"_blank\"><\/a><a href=\"http:\/\/unicode.org\/reports\/tr35\/\">UTR 3<\/a>5.<\/p>\n<p style=\"text-align: justify;\">This isn&#8217;t just new data, this is a new data structure, as the number and classification of languages on computers has evolved beyond the capabilities of RFC 1766. \u00a0I&#8217;ve always been glad that Java is so robust in it&#8217;s internationalization support even though I&#8217;ve never really taken advantage of most of it.<\/p>\n<h4>Separate user locale and user-interface locale<\/h4>\n<p>Now this is interesting, but I can&#8217;t find any good use cases yet. \u00a0My guess is that this is part of Java&#8217;s ongoing push towards multi-platform\/multi-language interfaces, notably Android. \u00a0You can set a Locale (and the rules a locale dictates) not only on geo\/cultural basis but on a device\/environment basis. \u00a0<a href=\"http:\/\/download.oracle.com\/javase\/7\/docs\/api\/java\/util\/Locale.Category.html\" target=\"_blank\">Locale.Category<\/a> only has two entries but I wouldn&#8217;t be surprised if more of them creep in in future versions.<\/p>\n<h4>JDBC 4.1<\/h4>\n<p>java.sql.Connection, java.sql.Statement, and java.sql.ResultSet are AutoCloseable (see try-with-resources below).<\/p>\n<p>Also, you can now get RowSets from a\u00a0RowSetFactory that you get from a\u00a0RowSetProvider. \u00a0If you&#8217;re still writing JDBC this probably makes your life easier, but only in the &#8220;at least I&#8221;m not writing custom classloaders&#8221; way.<\/p>\n<h4>Update the XML stack<\/h4>\n<blockquote><p>Upgrade the components of the XML stack to the most recent stable versions: JAXP 1.4, JAXB 2.2a, and JAX-WS 2.2<\/p><\/blockquote>\n<p>Your XML library is always a version that&#8217;s too old or too new, so you might as well go with the new one.<\/p>\n<h2>The important stuff I don&#8217;t use yet (AKA The Cool Stuff)<\/h2>\n<h4>InvokeDynamic &#8211;\u00a0Support for dynamically-typed languages (JSR 292)<\/h4>\n<p>The short version is that this makes things better for people implementing dynamically-typed languages on the JVM, like Clojure. \u00a0While the JVM is actually less statically typed than you might think if you&#8217;ve only used it via normal Java, methods in particular were difficult for these languages.<\/p>\n<p>The long version is\u00a0<a href=\"http:\/\/blog.headius.com\/2008\/09\/first-taste-of-invokedynamic.html\" target=\"_blank\">here<\/a>.<\/p>\n<h4>Enhanced MBeans<\/h4>\n<p>I&#8217;ve never knowingly used\u00a0<a href=\"http:\/\/download.oracle.com\/javase\/1.5.0\/docs\/guide\/management\/overview.html#mbeans\" target=\"_blank\">MBeans<\/a> (Managed Beans), but they do seem useful for large systems. \u00a0Regardless, they&#8217;ve been enhanced:<\/p>\n<blockquote><p>Enhancements to the existing com.sun.management MBeans to report the recent CPU load of the whole system, the CPU load of the JVM process, and to send JMX notifications when GC events occur (this feature previously included an enhanced JMX Agent, but that was dropped due to lack of time).<\/p><\/blockquote>\n<h4><span style=\"font-size: 20px;\">The Important Stuff I Use (AKA The Good Stuff)<\/span><\/h4>\n<p>These are the reasons I&#8217;ve even bothered to look at Java 7. \u00a0I&#8217;ll probably write a follow-up on each of these when I have some experience with them.<\/p>\n<h4>JSR 203: More new I\/O APIs for the Java platform (NIO.2)<\/h4>\n<p>I&#8217;m including this here because I&#8217;m actually doing some data\/file work where this will come in handy. \u00a0Basically this exposes a lot of I\/O and Filesystem functionality that you previously had to dip into native libraries for, like actually telling the OS to copy a file rather than reading and writing the data yourself. \u00a0If you&#8217;re not doing any file-based work right now, keep a mental note to look into this the next time you type &#8220;File&#8221;.<\/p>\n<p>More information <a href=\"http:\/\/today.java.net\/pub\/a\/today\/2008\/07\/03\/jsr-203-new-file-apis.html\" target=\"_blank\">here<\/a>.<\/p>\n<h4>NIO.2 filesystem provider for zip\/jar archives<\/h4>\n<p>Included here for similar reasons as the previous item, but I think it&#8217;s pretty cool that you can treat a zip file as a filesystem and operate within it. \u00a0Unfortunately it looks like the basic implementation is read-only, but I&#8217;m guessing the pieces are there for a read\/write version.<\/p>\n<p>More information <a href=\"http:\/\/blogs.oracle.com\/rajendrag\/entry\/zip_file_system_provider_implementation\" target=\"_blank\">here<\/a>.<\/p>\n<h4>Concurrency and collections updates (jsr166y)<\/h4>\n<p>java.util.concurrent, as far as I&#8217;m concerned, is something everyone who considers\u00a0him\/herself\u00a0a senior Java dev should be familiar with. \u00a0It&#8217;s rare that your code will not be able to take advantage of it in some way. \u00a0One of the missing pieces was a good fork\/join component, where you can split jobs and wait for them all to complete in parallel before moving on. \u00a0I actually built a version of this approach (sadly not open sourced), so I&#8217;m eager to tinker with the new standard one. \u00a0I expect that list most of the concurrent library you&#8217;ll need to sprinkle in some of your own helper code to make things elegant, but the hard parts are solved and built and ready for assembly.<\/p>\n<p>More information <a href=\"http:\/\/download.oracle.com\/javase\/tutorial\/essential\/concurrency\/forkjoin.html\" target=\"_blank\">here<\/a>.<\/p>\n<h4>Project Coin &#8211;\u00a0Small language enhancements (JSR 334)<\/h4>\n<p>Ah, the sugary goodness that you&#8217;ve been waiting for.<\/p>\n<ul>\n<li>Strings in switchNot terribly useful since we could (and probably still should) use enums, and you still have to use if blocks for anything fancy like regex matches.<\/li>\n<li>Binary integral literals and underscores in numeric literalsI never really thought of this as a problem, much less one worth solving, but sure, why not.<\/li>\n<li>Multi-catch and more precise rethrowNow this, as an ardent fan of exceptions, I like. \u00a0It not only cuts down on copy\/paste exception handling, it helps avoid subclassing exceptions, which is almost always the wrong approach. \u00a0More info on this later.<\/li>\n<li>Improved type inference for generic instance creation (diamond)Great idea that really should have always been there. Example:\n<pre>Map&lt;String,Integer&gt; myMap = new HashMap&lt;&gt;();<\/pre>\n<\/li>\n<li><code>try<\/code>-with-resources statementProbably the most important syntax change. \u00a0Now you can skip all of those finally { resource.close(); } blocks that were important but verbose even for my taste. \u00a0Doesn&#8217;t really help with the situation of the close method throwing an exception of its own though, so I&#8217;m curious to see how I end up handling that situation.<\/li>\n<li>Simplified varargs method invocationJust avoids some methods that really never should have been there in the first place.<\/li>\n<\/ul>\n<p>More information <a href=\"http:\/\/blogs.oracle.com\/darcy\/resource\/ProjectCoin\/CoinLaunch.pdf\" target=\"_blank\">here<\/a> (PDF).<\/p>\n<h2>Summary<\/h2>\n<p>So basically, a bunch of &#8220;nice to have&#8221; stuff. \u00a0Code will be a little cleaner, resources will be closed a little more often. \u00a0GUI apps will be a little fancier. \u00a0Some more people might try concurrency. \u00a0Programs will run a little faster. \u00a0The next thing you know we&#8217;ll be looking at <a href=\"http:\/\/openjdk.java.net\/projects\/lambda\/\" target=\"_blank\">Java 8<\/a>&#8230;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java 7 is out! What does this mean, is this a Big Deal like Java 3 or 5 or a snoozer like Java 6 or something in the middle like Java 4?  Let&#8217;s look at everything new and find out.<\/p>\n","protected":false},"author":1,"featured_media":689,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[5],"tags":[321,322],"series":[],"class_list":["post-607","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-java-7","tag-project-coin"],"jetpack_featured_media_url":"https:\/\/efsavage.com\/blog\/wp-content\/uploads\/2011\/08\/javacle.jpg","jetpack_shortlink":"https:\/\/wp.me\/p1AkJt-9N","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/posts\/607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/comments?post=607"}],"version-history":[{"count":12,"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/posts\/607\/revisions"}],"predecessor-version":[{"id":690,"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/posts\/607\/revisions\/690"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/media\/689"}],"wp:attachment":[{"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/media?parent=607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/categories?post=607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/tags?post=607"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/efsavage.com\/blog\/wp-json\/wp\/v2\/series?post=607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}