IBM User Guide for Java V7 on Windows > Troubleshooting and support > Using diagnostic tools > Using the Diagnostic Tool Framework for Java
Using the DTFJ interface
To create applications that use DTFJ, you must use the DTFJ interface. Implementations of this interface have been written that work with system dumps from IBM SDK for Java™ versions 1.4.2 and later, and Javadumps from IBM SDK for Java 6 and later.
All DTFJ implementations support the same interface, but the DTFJ implementations supplied in Version 5.0 and later are different to the implementation supplied in Version 1.4.2. The DTFJ implementations have different factory class names that you must use. The DTFJ implementation supplied in Version 1.4.2 does not work with system dumps from Version 5 or later, and the DTFJ implementations supplied in Version 5 and later do not work with system dumps from Version 1.4.2.
Figure 1 illustrates the DTFJ interface. The starting point for working with a dump is to obtain an Image instance by using the ImageFactory class supplied with the concrete implementation of the API.
Working with a system dump
The following example shows how to work with a system dump.
import java.io.File; import java.util.Iterator; import java.io.IOException; import com.ibm.dtfj.image.CorruptData; import com.ibm.dtfj.image.Image; import com.ibm.dtfj.image.ImageFactory; public class DTFJEX1 { public static void main(String[] args) { Image image = null; if (args.length > 0) { File f = new File(args[0]); try { Class factoryClass = Class .forName("com.ibm.dtfj.image.j9.ImageFactory"); ImageFactory factory = (ImageFactory) factoryClass .newInstance(); image = factory.getImage(f); } catch (ClassNotFoundException e) { System.err.println("Could not find DTFJ factory class"); e.printStackTrace(System.err); } catch (IllegalAccessException e) { System.err.println("IllegalAccessException for DTFJ factory class"); e.printStackTrace(System.err); } catch (InstantiationException e) { System.err.println("Could not instantiate DTFJ factory class"); e.printStackTrace(System.err); } catch (IOException e) { System.err.println("Could not find/use required file(s)"); e.printStackTrace(System.err); } } else { System.err.println("No filename specified"); } if (image == null) { return; } Iterator asIt = image.getAddressSpaces(); int count = 0; while (asIt.hasNext()) { Object tempObj = asIt.next(); if (tempObj instanceof CorruptData) { System.err.println("Address Space object is corrupt: " + (CorruptData) tempObj); } else { count++; } } System.out.println("The number of address spaces is: " + count); }}In this example, the only section of code that ties the dump to a particular implementation of DTFJ is the generation of the factory class. Change the factory to use a different implementation.The getImage() methods in ImageFactory expect one file, the dumpfilename.zip file produced by jextract (see Using the dump viewer). If the getImage() methods are called with two files, they are interpreted as the dump itself and the .xml metadata file. If there is a problem with the file specified, an IOException is thrown by getImage() and can be caught. An appropriate message issued. If a missing file is passed to the example shown, the following output is produced:
Could not find/use required file(s) java.io.FileNotFoundException: core_file.xml (The system cannot find the file specified.) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:135) at com.ibm.dtfj.image.j9.ImageFactory.getImage(ImageFactory.java:47) at com.ibm.dtfj.image.j9.ImageFactory.getImage(ImageFactory.java:35) at DTFJEX1.main(DTFJEX1.java:23)In the this case, the DTFJ implementation is expecting a dump file to exist. Different errors are caught if the file existed but was not recognized as a valid dump file.
Working with a Javadump
To work with a Javadump, change the factory class to com.ibm.dtfj.image.javacore.JCImageFactory and pass the Javadump file to the getImage() method.
import java.io.File; import java.util.Iterator; import java.io.IOException; import com.ibm.dtfj.image.CorruptData; import com.ibm.dtfj.image.Image; import com.ibm.dtfj.image.ImageFactory; public class DTFJEX2 { public static void main(String[] args) { Image image=null; if (args.length > 0) { File javacoreFile = new File(args[0]); try { Class factoryClass = Class.forName("com.ibm.dtfj.image.javacore.JCImageFactory"); ImageFactory factory = (ImageFactory) factoryClass.newInstance(); image = factory.getImage(javacoreFile); } catch .....The rest of the example remains the same.
After you have obtained an Image instance, you can begin analyzing the dump. The Image instance is the second instance in the class hierarchy for DTFJ illustrated by the following diagram:
Figure 1. DTFJ interface diagram
![]()
The hierarchy displays some major points of DTFJ. First, there is a separation between the Image (the dump, a sequence of bytes with different contents on different platforms) and the Java internal knowledge.
Some things to note from the diagram:
- The DTFJ interface is separated into two parts: Classes with names that start with Image and classes with names that start with Java.
- Image and Java classes are linked using a ManagedRuntime (which is extended by JavaRuntime).
- An Image object contains one ImageAddressSpace object (or, on z/OS, possibly more).
- An ImageAddressSpace object contains one ImageProcess object (or, on z/OS, possibly more).
- Conceptually, you can apply the Image model to any program running with the ImageProcess. For the purposes of this document discussion is limited to the IBM JVM implementations.
- There is a link from a JavaThread object to its corresponding ImageThread object. Use this link to find out about native code associated with a Java thread, for example JNI functions that have been called from Java.
- If a JavaThread was not running Java code when the dump was taken, the JavaThread object has no JavaStackFrame objects. In these cases, use the link to the corresponding ImageThread object to find out what native code was running in that thread. This situation is typically the case with the JIT compilation thread and Garbage Collection threads.
- The DTFJ interface enables you to obtain information about native memory. Native memory is memory requested from the operating system using library functions such as malloc() and mmap(). When the JRE allocates native memory, the memory is associated with a high-level memory category. For more information about native memory detailed in a javadump, see Native memory (NATIVEMEMINFO).
Parent: Using the Diagnostic Tool Framework for Java
Error 404 - Not Found Error 404 - Not Found
The document you are looking for may have been removed or re-named. Please contact the web site owner for further assistance.