Summary
Mandy Chung leads the design and implementation of the java.lang.management API, and is responsible for many monitoring- and management-related features in Java SE 6. In a recent blog post, she lists fourteen new features that make Java SE 6 the most manageable Java release yet.
Advertisement
Management and monitoring are not features developers think of first when enumerating new capabilities of Java SE 6. The latest Java release contains monitoring and debugging-related tools, however, that have the potential to directly impact developer productivity: Many of the new tools make it easy for developers to peak under the JVM's hood and observe their application's behavior in action.
Mandy Chung has been behind the java.lang.management API, and is responsible for implementing other monitoring-related tools in Java SE 6 as well. In a recent blog post, Java SE 6 Monitoring, Management, Diagnosability, she lists fourteen new or enhanced APIs and utilities:
Dynamic Attach Capability lets you attach a monitoring tool to an already running JVM. This can be handy to diagnose problems in a running Web server, for instance, without having to shut that server process down.
Heap Dump and Analysis Once you connect to the monitoring interface of a running JVM, you still need to gather sufficient information to solve the problems you were looking to fix. Many problems are memory-related, and Java SE 6 makes memory analysis much easier: You can obtain a heap dump with the jmap tool and then analyze that dump with the jhat utility.
OutOfMemoryError Diagnosability A JVM running out of memory is often hard to diagnose, because by the time this error occurs, an application usually behaves erratically. According to Chung:
JDK 6 provides a better support to diagnose OutOfMemoryError. This error now includes a stack trace where the allocation failed. Another useful improvement is the -XX:+HeapDumpOnOutOfMemoryError option which tells the HotSpot VM to generate a heap dump when an allocation from the java heap or the permanent generation cannot be satisfied. In addition, a new -XX:OnOutOfMemoryError= option is added for you to specify a command that the HotSpot VM will invoke when the OutOfMemoryError is thrown.
The last option, for instance, can send an email to, or page, the system administrator—or telephone the developers in the middle of the night.
DTrace on Solaris is a Solaris 10 tool that allows dynamic tracing of an application. Java SE 6 integrates with Solaris' DTrace tool, giving developers the ability to trace stack-by-stack an application's execution.
jconsole, a GUI utility already available in JDK 5, can now be attached to an already running JVM.
jhat is a a heap analysis tool, that, according to Chung,
Provides built-in queries to examine classes, instances, root set, heap histogram and objects pending for finalization. It also supports a built-in query language, OQL, to query the heap which is particular useful when searching on large number of objects.
jmap is a small utility to get heap histogram and heap snapshot from the JVM.
jstack is a tool that, according to Chung,
Can print Java stack traces and also detect deadlocks on all platforms. You can also use the new jstack -l option to print the list of owned java.util.concurrent locks.
jinfo produces Java configuration information for a Java process, a core file, or a remote debug server. This tool was enhanced with a -flag option to get and set a JVM option.
In her blog post, Chung also lists various improvements to existing management and monitoring APIs:
Java Management Extensions (JMX):
The important features of the JMX API in JDK 6 are MXBeans and Descriptors. MXBeans enable bundling of related values in a MBean without requiring special client configurations to handle to bundle. Descriptors provide you a convenient way to attach additional metadata to your MBeans.
java.lang.management:
The java.lang.management API has been enhanced for monitors and java.util.concurrent locks monitoring. You can find the list of locks owned by a thread and also report which stack frame locked a monitor. It also provides a new method to obtain the system load average. In addition, a new HotSpotDiagnosticMXBean API provides the programmatic interface to obtain a heap dump and set a VM option.
java.lang.instrument
The java.lang.instrument API has been enhanced to provide support for dynamic transformation of loaded classes, multiple agents and appending to class loader search.
JVM Tool Interface
JVM TI as been enhanced to provide multiple agents support, better dynamic instrumentation, enhanced heap walking API, resource exhaustion notification, support for early return and monitor stack depth.
Java Platform Debugger Architecture (JPDA)
JPDA has been enhanced to support heap walking functionality, force early return, view method arguments when not compiled with -g, process attach connector, monitor stack depth, and breakpoint on monitor locks/release.
Do you think these tools will directly impact your development work, or do you consider them mainly useful for tool vendors and system administrators?