java 7 from the nyjavasig

Google java 7 a bug’s life – for approach to bug

Java 7 has come a long way since the Java road show 14 months ago when I blogged about what may or may not be in Java 7. And not always forwards. Oracle sent Donald Smith (director of project management with some coding knowledge) to the NY Java Sig.  In this blog entry, we’ll look at what features made it in, the strategy discussion from Oracle and then some details.

How does Java 7 shape up compared to the road show?

Before we get to what actually happened at the sig, let’s see how Java 7 shaped up compared to the road show.

Category Feature How to Use or Status
Modularity Project Jigsaw Java 8 – modularize the JDK to address the “Java is too big” problem.  Will not replace OSGi.
Multi-lingual Support DaVinci Machine Includes invokedynamic and more. See docs
invokeDynamic Implemented in virtual machine/bytecode to make dynamic languages faster. Invokevirtual was closest but slow because doing extra type checking. Builds CallSite so only does that extra work once and improves performance of subsequent calls. JRuby noted 20% perfromance increase.
Small languages changes (Project Coin) Diamond Operator List>Map<String, Integer> list = new ArrayList<>();
Integer Literals int num = 1_234_567;
Try Catch With Resources try (InputStream s = …) {  … }
Collection literals (like associative array) Didn’t go anywhere. Haven’t seen talked about for Java 8 either.
Other While other (undetermined) features weren’t publicized last year, they will be part of Java 8.
Performance Fork Join New APIs in Java 7.  See end of post for details.
ParallelIntArray Not in Java 7. Didn’t go anywhere.
Closures Closures/Lambda Expressions Deferred to Java 8.  Will include support for multi-core.

High Level/Strategy

Donald didn’t sound like a typical Oracle speaker. He was funny, easy to relate to and started out by talking about his biases/background It felt more personal than corporate. Usualy when Oracle prents something it sounds like legal reviewed it and stripped out a lot. The slide deck did have the standard nine line Oracle disclaimer. He did note that IBM’s Sarbanes Oxley disclaimer is twice as long as Oracle’s. People asked tough questions and he answered honestly when not knowing the answer.

Interesting things from Strategy and Q&A

  1. Timelines
    • Java 6 came out in 2006.  The four years to Java 7 was the longest time between releases anywhere.
    • Java 7 update 1 is due out in early September and will contain the major bug fixes.
    • Java 7 update 2 is due out in October and will contain garbage collection enhancements.
    • Java 8 is targeting 2012.  The speaker thinks 18 months is too soon for Java 8 because the industry is no longer used to a 2 year release cycle anymore, let alone more frequent..  He thinks we need time for the tooling to catch up.
  2. Java heath (just Java; doesn’t include JVM languages)
  3. Official terms for past are “legacy sun employee” or “legacy bea employee”.
  4. HotSpot vs JRockit
    • Survey says 70% use Sun JDK and only 5% use JRockit.
    • Oracle decided to officially kill the JRockit JVM and just use the JRockit tooling. (Mission Control, Flight Recorder and RT)
    • Over time, the two will merge with the JRockit tools being premium features.
    • Oracle emphasized performance will also be free and part of the main JDK.
    • Googlefight between the two shows Hotspot as the clear winner.
  5. JavaOne – Oracle is holding back announcements for JavaOne.  Expect some on
    • Java 7 Certifications
    • Something about the Mac.  Maybe with respect to Java 8.  (Oracle claims the delay in Java 7 on the Mac is to “make things right” with the Apple UI.)
    • Recognition that Oracle needs to clean up their name in community by announcing things at JavaOne and doing them without surprises.
  6. Open jdk is slowly becoming more open. For example, Oracle recognizes the need to open bugs to public before Oracle sees/runs triage. Looking at using jira for this.
  7. Java 7 theme is “moving Java forward.”  In other words, just get something out without waiting for all the features.

More on Java 7

The emphasis was the need to be careful about protecting the platform, the amount of work in the smallest of changes and the desire to not change the type system.  Changes fall into three categories:

  1. Language changes
    • All project coin changes noted in table up top
    • + Allowing Strings in the switch statement
    • + @SafeVarargs allowing the method itself to declare safety so all callers don’t have to suppress warnings.
    • + AutoClosable interface for I/O and JDBC 4.1 resources.  Using these within the try with resources syntax in the table above means they will get automatically closed.  It also means exceptions thrown in that auto generated finally will be suppressed but still available in the stack trace.
    • + Catching multiple unrelated exceptions catch(ExceptionType1 | ExceptionType2 e)
  2. Library changes
    • NIO – Better exceptions, more extensible to different file systems, rename behavior more consistent , more access to metadata
      • Path is the replacement for File. It understands symbolic links cross platform consistently and provides many methods.
      • Lots of methods to create/navigate/transform paths
      • Can call path.toFile() to get file from path to call old apis
      • Paths helper class to get path
      • Files helper class to copy files with lots of options such as copy with attributes or replacing exisiting attributes.  Also supports atomic move.
    • Concurrency (Fork/Join)
      • Phaser class which is similar to the cyclic barrier and countdown latch but has better synchronization and deadlock protection.  Can also add and remove threads on fly.
      • TransferQueue interface which is implmented by LinkedTransferQueue – the producer or consumer can block while waiting so dont get too far ahead
      • The key class to implement your logic in should implement RecursiveTask.  It is like RecursiveAction except that it returns a result.  All you have to do is implement the compute() method.
      • The ForkJoinPool is the executor so you can submit your task to have it run.  Methods are provided to see if it is done and get the result.  By default it uses the # available processors or you can specify explicitly.
  3. Runtime changes
    • See table up top for changes.
    • Oracle listed all the languages that can run on a JVM.  They noted that some are research projects by students and not “real” or “ready.”  I laughed because C# was on the list.  Why would you want to run C# on a JRE?
  4. Other
    • Swing nimbus look and feel is completed.  Metal is still the default.
    • Eliptic curve cryptography
    • Deadlock avoidance in classloader
    • Close method for UrlClassloader
    • Javadoc now has support for CSS.  Which means the JavaDoc now has “nice looking annoying frames”

virtualbox between mac lion and ubuntu

I installed VirtualBox a few weeks ago.   A few wrinkles when actually using it.

Copy/paste

By default, you can’t copy/paste between your Mac and VirtualBox VM machine.  It’s easy to enable though:

  1. Devices > Install Guest Addons
  2. Wait a few minutes for a terminal window to open and install
  3. When prompted, press return to close terminal window
  4. Restart the VM
  5. Now copy and paste works naturally.
Keyboard shortcuts
On the Mac, you use command c to copy and on Ubuntu you use ctrl c.  It was a bit annoying to switch between the two frequently.  I don’t really have a good way of dealing with this other than press command c and wonder why nothing happens.  Ideas?
Command tab
I’m big on command tab.  The problem is that Virtualbox eats/disables it.  Which means every time I switched from my browser or Open Office to the VirtualBox install, it was awkward to get back.  I would up solving this by creating three desktops on Lion (spaces.)  One was VirtualBox Ubuntu Linux.  The second was the Open Office document with the book I was technical proofreading (Well Grounded Java Developer.)  The third was my browser/finder windows/etc.  This was helpful.  It let me three finger swipe as I was reading and command tab for the “little swaps” within my main desktop.  This fit my mental model well.  The only thing I didn’t like was that I had to put Open Office back in desktop #2 each time I opened a new chapter.

Apple OS X Lion Review – Part 2

In my release-day review of Apple’s Mac OS X Lion, I shared my initial impressions of the operating system while highlighting the key differences from previous versions. I also pointed some features users might not like. Now, two weeks later, I am much more appreciative of OS X Lion and wondering how I lived without certain features, such as full-screen mode. There are still some things I am not too fond of, but overall I have a much more favorable view of the new OS X after spending two weeks with it.

1. Full-Screen & Spaces Magic

Apple originally released Spaces with Mac OS Leopard 10.5, but until OS X Lion 10.7 I had never really used it. Spaces utilizes multiple virtual desktops in which to launch applications. The beauty of Apple’s implementation of full-screen mode is that it auto-magically creates and removes Spaces as the user switches into and out of full-screen mode. As a developer, I’m impressed by the clever re-use of existing functionality in an entirely new way. As a user, I like the new interface and beauty with which it works.

I was in the Apple Store over the weekend and compared the new 11″ MacBook Air running Safari in full-screen mode with a 13″ MacBook Air running the same application in windowed mode. Surprisingly, the height of the window was nearly the same. By introducing full-screen mode, Apple has essentially increased the screen size of all existing Macs, making the 11″ feasible as a true laptop replacement for the first time.

The addition of full-screen mode throughout the OS is probably the single most important feature Apple has release in OS X Lion. I only wish more third party applications, such as Microsoft Office and TextMate (the best Mac text editor) supported it automatically, but we will have to wait for a software update from the vendors. For those using Eclipse, Alex Blewitt has provided an unofficial update to support full-screen mode in OS X Lion that works perfectly in Eclipse 3.7 Indigo, although unfortunately not in previous versions of Eclipse. There is some concern that large manufacturers, like Adobe and Microsoft, could charge an upgrade fee for the next version that includes full-screen support, but this is up the individual vendors to decide.

2. New Mail App

In my initial Mac OS X Lion review, I indicated that I liked the Mail application, but did not go into much detail. After two weeks of using it, I’ve come to the realization that I love the streamlined, full-screen interface. It makes reading mail much simpler and less cumbersome than most modern mail applications, such as Mozilla Thunderbird or Microsoft Outlook. Also, I really like the conversations interface, borrowed a bit from Google’s Gmail web interface, which shows related messages, including your replies, in a single vertical view. Overall, this makeover makes for a much more solid, user-friendly application.

3. New Multi-Touch Gestures

The new 3-finger gestures are quite fun to use, such as pinching to make the Launchpad appear, or sliding the current page back in Safari, as an alternative to the back button. While it is getting a little difficult to remember all the different gestures available, they are playful and add a new level to the Mac. I have noticed some novice users trip up on multi-touch gestures though. For example, a particular family member of mine accidentally zoomed out on her Desktop resulting in all of the desktop icons shrinking to an unusable size. I would recommend that Apple turns off many of the advanced multi-touch gestures and enables them gradually and with the user’s permission, so that less skilled users understand how they work better.

4. All My Files: The Onion Prophecy Comes True!

Over two years ago, The Onion released a video showing a mock MacBook Wheel laptop, in which the entire keyboard is replaced by a single button, in part to mock Apple’s reliance on single-button hardware. In the video [at 1:06], they show a user searching their computer with all of the files in a single folder. Apparently, someone at Apple was taking notes, because the new version OS X Lion comes with an “All My Files” option in the finder menu. If you are like me, and have thousands of documents, I have no idea when this feature would ever be useful. In fact, if you use iPhoto and iTunes to manage all of your photos and music, there is never a reason to include them in this window. Overall, this feature seems like a last minute addition by an unskilled developer that probably should have never made it to the final build. You can turn this feature off by either right-clicking on it and removing it from the Sidebar, or unchecking the option in Finder -> Preferences -> Sidebar. Since it found thousands of useless icons and web files, I turned this feature off after a week as I decided it was a complete waste of time for anyone with more than a few dozen content items on their computer.

5. The Leftovers: What’s still bad

After reflecting on the topic, I’ve come to realize Mission Control, while useful, is so much like Exposé, that Apple really shouldn’t be highlighting this as a brand new feature. Perhaps not enough people were using Exposé, but this feels like a completely recycled feature with nothing of value added.

As for Natural Scrolling, in which they reversed horizontal and vertical scroll directions in OS X Lion, one person suggested they were trying to make a consistent interface with the iPad. If Apple ever does release a touch-screen Mac, this would certainly be the ground work for it. I decided to re-enable the natural scrolling following launch day and ultimately, it makes no difference to me which method I use. I still contend changing a major component of a user interface without explicitly informing the user is a horrible idea, as it tends to confuse the less-informed user base.

Finally, if you are Rosetta user who depends on older versions of applications, you may want to postpone upgrading at this time. I still content Microsoft Office 2004, which no longer works in OS X Lion, is the best version of Office released for Mac in the last decade due to its exclusion of the annoying ribbon, and inclusion of scripting support removed in Microsoft Office 2008. Users of Adobe CS2 or earlier, or those Photoshop CS3/CS4 users that rely on Droplets for batch processing, should likewise wait, as these products no longer function in OS X Lion and Adobe products can be quite pricey to replace. Unfortunately, Adobe has announced that it will not be providing Droplet support for CS3/CS4 users.

Minor Installation Woes

Having experienced serious installations issues on release day with Snow Leopard, I am pleased to report the installation of OS X Lion amongst my family members went almost entirely without problems. One computer did have a minor issue in which it restarted in Lion Recovery mode following the first reboot part of the installation. I needed to select the built-in hard drive as the Start Up disk, reboot the computer, then restart the entire installation. This solution worked, and have not seen any other installation issues.

Conclusion

The performance issues that I reported in my first review of OS X Lion eventually subsided, although it took all day. Between Spotlight indexing the entire hard drive and Time Machine backing up all of the changes, my computer was so hot I couldn’t touch it for hours after installation. Since then, the performance has been about the same as in 10.6 Snow Leopard, the previous version of Mac OS X. At this point, I am changing my satisfaction with OS X Lion from 35% previously reported to 90%, with the bulk of it stemming from the new full-screen mode that makes an 11″ MacBook Air perform like a 13″ MacBook Air.

There are still some rough edges, but overall this update is a welcome change and, unless you are one of those unfortunate users dependent on a Rosetta application, it is no-brainer upgrade at a $30 per household and a nearly error-free installation.