OpenShift wants to provide its users the best environment to run their applications, so we are happy to announce that we now provide support for Java 7. This means OpenShift now supports two versions of Java - 6 and 7. Not sure if you should make the switch to Java 7? Here are a few reasons to think twice...
Da Vinci Machine
Java 7 introduces new invokedynamic bytecode instruction that will help dynamic languages (like JRuby - Ruby implementation running on top of the JVM) to optimize calls on dynamically changed classes. As dynamic languages often allow to reopen classes and modify the behavior of the class, with Java 7 it shouldn't need to create a new class and replace the previous one, but to preserve the original as possible and incorporate the changes in the new class. invokedynamic then optimizes calls involving these changed classes.
As a bit of a teaser, here’s my numbers running the red/black tree benchmark from above (the numbers are time in seconds). Compared to JRuby on Java 6, JRuby on Java 7 without invokedynamic is around 25% faster, and JRuby with invokedynamic is nearly 3 times faster.
It’s also worth mentioning that invokedynamic isn’t “done”. There’s a new optimizer planned for Java 7u4 and my OpenJDK friends tell me there are many opportunities to increase performance. JRuby on Java 7 will just keep getting faster.
Strings in switch
I like this feature a lot. Until now it was not possible to use Strings in switch statements. This simplifies complex if constructions that involved String objects.
String string = "something";
case "something else":
Fork/Join framework helps developers to utilize multiple processors in cases where the work can be split into smaller parts that can run separately. According to the official documentation, the basic algorithm looks like this:
if (my portion of the work is small enough)
do the work directly
split my work into two pieces
invoke the two pieces and wait for the results
So the developer implements a deciding logic whether the work the worker received is small enough, if it is, then the work is done right there. If not, the worker slices part the that and starts working, the rest being available for the other works when the stop being busy.
Several changes have been done to the I/O subsytem. Java 7 features the new NIO.2 framework that builds on the previous NIO framework. It also adds new features that allow more complex operations on the file system. One of those features is the support of links - both soft and hard ones. This may help developers to leverage more of the core features of Unix systems in their Java code. There is also new framework to provide file change notifications. These can be utilized in cases where the application needs to react on changes made to the filesystem.
This is just a quick sneak peek of features that are new to Java 7 and now available on OpenShift. What can you expect from Java 7 if you are not writing a new application? At least better performance. The whole JDK is much faster in the latest version as you can see for example in the JRuby benchmark mentioned previously.