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”

what may or may not be in java 7 from the java road trip

Oracle talked about Java 7 at the first stop of the Java Road Trip. The main speaker was Brian Goetz, author of Java Concurrency In Practice.

Despite the disclaimer that everything including syntax is subject to change, the talk was pretty interesting.  Here are my notes.  (this was largely written on my iPad; please excuse any typos)


  • The JRE download is 13mb, but most code doesn’t get run by ordinary apps
  • The monolithic jdk makes new releases of platform take longer to roll out
  • Modularizing apps helps with jar hell and finding out at runtime that something is missing/wrong
  • Will provide mechanism for apps to express dependencies in way useful to both humans and tools
  • Based on concepts in Maven and OSGI
  • Current draft has: defining module and version number along with what module and versions or ranges you depend on
  • Classpath will be legacy mode, preferred mode will be to turn your app into a module

Multi lingual support

  • JVM is a managed code environment
  • Scala is a lot like java, but other dynamic languages (like Ruby) run slower because need to rely on reflection or code generation.
  • JVM is more like Smalltalk than like Java , but some places is tied to Java
  • Da Vinci machine project is targeted to adding features to better support dynamic languages. In particular dynamic method linkage which is being able to select version of method based on type of arguments
  • Invokedynamic vs invokevirtual for method selection and linking. Once calls stabilize, don’t look up in vm anymore, then inlines and is as fast as in  java.  This is a goal, need to get there.


  • Project coin – add half a dozen small language changes to simplify everyday tasks.  Would be at  level of enhanced for loop
  1. Reduce boilerplate of generics with the the diamond operator (not really an operator)
    Map<String, String> map  = new HashMap<>();
  2. Better numerical literals to make long numbers more readable.  Similarly for binary (long string of 0’s and 1’s)
    long cc= 123_5678_567;
  3. Collection literals – declare inline like we do with arrays and hard coded data.  More declarative. Like associative array in Perl, but may not go that far
  4. Automatically close resources in try/catch.  Better idiom
    try (InputStream in = createInputStream()){
    // code that reads in from stream goes here
    } // compiler will call close for you here


  • Goal: facilitate scalability across multiple cores
  • Fork join extend recursive action to split into subtasks and join to get answer.
  • Will be added to concurrency utilities.
  • Don’t have to tell it how many cores you have
  • ParallelIntArray class automates common operations filter, map and reduce so can say what want to do declaratively


  • Saving the best for last.
  • Like anonymous inner classes but without boilerplate of anonymous inner classes
  • Still debating syntax
  • Still debating whether return type should be declared
  • Still discussing how to extend interfaces (will be used to add closures for Collections).  Options are “static extension methods” like in C# where you statically “pretend there were these methods are on the class and call the static methods instead.”  Also discussing ” virtual extension methods.”  Either way the closures project will finally address the issue of api evolution
#(int x)(x*3).domorestuff()