Java Reference
In-Depth Information
▪ JVM performance improvements
▪ JVM garbage collection (GC) improvements
The first few of these are detailed starting at Multicatch .
The Java Virtual Machine has always had InvokeVirtual as a JVM instruction for support
of possibly overridden methods. Java 7 introduces a related new JVM machine instruction
called InvokeDynamic , which is intended for use by language developers to provide better
support for dynamically typed languages such as JRuby, Jython (Java Python), and Clojure,
some of which are discussed in Chapter 24 . As this topic focuses on Java, and because the
changes will only result in better performance, not linguistic change, for these languages, I
don't discuss it here.
Also on the JVM side, the default garbage collection algorithm has changed to “Garbage
First” (G1GC). The G1GC is a server-style garbage collector targeted at MP apps with large
amounts of real memory. Further, it meets a soft real-time goal with high probabil-
ity—meaning better response for most apps. Although this is not the last word in GC, it is
the long-term planned replacement for the widely used Concurrent Mark-and-Sweep Collect-
or (CMS) GC.
Multicatch
You can now list multiple exception types in one catch:
Object newbie = null;
try {
Class.forName(clazzName).newInstance();
} catch (InstantiationException|IllegalAccessException|
ClassNotFoundException e) {
// app-defined handler
handleError("Could not create instance of " + clazzName, e);
}
In previous versions of Java you'd have needed three catch clauses with a lot of copy-and-
paste, error-prone error handling, or, have something like catch (Exception e) , which
might be more than you want to catch.
Search WWH ::




Custom Search