Share
| Social Web | |
|---|---|
Java 7 Arrives
By Brennan Spies - Posted on August 5th, 2011
Tagged:
5 years since its last release, a new Java release finally gets out of the gates. Though less ambitious than the initial plans for the new release, it is shipping now--and, as a wise man once said, shipping is a feature. Oracle clearly recognized this after taking over at the helm of Java, and paired down the feature list in order to get some of the momentum that Java had lost in the waning years of Sun. Java 7 is hence being billed as an evolutionary release (that's code for "no lambdas yet"); nevertheless it is a much bigger step forward than Java 6 was, and a push that the platform really needed. So, without further ado, I'll cut to the chase and give a run-down of what the new features are and an assessment of their general usefulness. 1) The fork/join framework, also known as JSR-166y. Fork/join is well-optimized set of concurrency classes designed for fine-grained parallel computation. Fork/join is useful when you have computation tasks that are easily separable to run in parallel; a good example would be the class of algorithms which use a "divide and conquer" strategy such as quicksort. The framework also introduces the Phaser class, a more flexible version of a Missing in action from the original library developed by Doug Lea is ParallelArray and friends, namely because without lambda expressions (coming in Java 8) a ridiculous number of classes are needed to make it work. Presumably a slimmer version will be included with Java 8. 2) The invokedynamic bytecode instruction. Though most Java programmers won't even know it's there, this new instruction is a powerful extension to the JVM, and will be the great enabler for dynamic languages such as JRuby or Jython. Java doesn't miss all the fun, though: lambda expressions in Java 8 may well be compiled down to 3) Project Coin. Project Coin contains lots of small but highly useful changes, including:
4) NIO.2 (JSR-203). Among its key features is a much-needed overhaul of Java's file system API. The centerpiece of this new API is the Path class, which supercedes the older java.io.File implementation. Among
FileSystem local = FileSystems.getDefault();
Path p1 = local.getPath("/path/to/file");
Path p2 = local.getPath("/path/to/another/file");
Path rel = p2.relativize(p1); // rel is "../file"
//Thread for polling the filesystem for changes
public class Watcher implements Runnable {
public void run() {
FileSystem local = FileSystems.getDefault();
WatchService watchService = local.newWatchService();
Path watched = local.getPath("path/to/dir");
WatchKey regKey = watched.register(watchService,
ENTRY_MODIFY, ENTRY_CREATE, ENTRY_DELETE);
// poll in infinite loop
while(true) {
WatchKey key = watchService.take();
for (WatchEvent<?> event: key.pollEvents()) {
//...process events
}
}
}
}
Other nice additions include:
...oh yes, you can now also simply copy a file by telling the OS to, rather than reading and writing the data yourself (what took so long on this one?). 5) Elliptic Curve Cryptography. For years RSA was the only game in town for asymmetric public key cryptography. Now we have ECC as well, as a native provider for it was added to Java 7. 6) Stream Control Transport Protocol (SCTP). SCTP, a standard created by the IETF, is a reliable message-oriented protocol (similar to its less reliable cousin, UDP). SCTP has the following key features:
A comparison of SCTP with other transport-layer protocols is here. SCTP in Java 7, however, is not yet a part of Java's public API (it's in the There's lot of other small improvements in Java 7 that I haven't covered here. For a full list of new features, refer to the appropriate documentation. A Word of Caution Java 7 shipped with a loop optimization bug that many consider to be show-stopping bugs (apparently Oracle did not, as they were found 5 days prior to the release). The bugs are in one of the Hotspot's experimental loop optimizations, which was disabled in Java 6 (enabled using Still to come in Java 8...
| |
Delicious
Digg
StumbleUpon
Propeller
Reddit
Magnoliacom
Newsvine
Furl
Facebook
Google
Yahoo
Technorati
Icerocket
Recent comments
1 year 17 weeks ago
1 year 18 weeks ago
1 year 18 weeks ago
1 year 22 weeks ago
1 year 22 weeks ago
1 year 22 weeks ago
1 year 23 weeks ago
1 year 23 weeks ago
1 year 26 weeks ago
1 year 39 weeks ago