hide random home http://www.javasoft.com/JDK-1.0/debugging/ (PC Press Internet CD, 03/1996)

Java(tm) Language Debugging
Java(tm) Developers Kit

Version 1.0

Java(tm) Language Debugging

To help you learn how to use the Java Debugger (JDB), here are two tutorials:
JDB Tutorial
This introduces you to JDB's help and thread-viewing commands.
Debugging Applets with JDB and the Applet Viewer
This walks you through some common tasks of debugging an applet.
If you're interested in the debugging architecture of the Java(tm) Programming Language, read on.

Overview of the Debugging Architecture

Without a debugger, debugging applets written in the Java(tm) Programming Language means embedding print statements, running the applet, and then analyzing the trace output. Although use of the Java(tm) Programming Language makes this approach less time-consuming than in many other environments, there is still a pressing need for a more interactive approach. This is especially true when trying to debug applets remotely -- "it works on my machine" doesn't play well on the Internet.

A debugger for the Java(tm) Programming Language needs four features:

To fulfill these requirements, the Java Debugger API was developed. This API supports the model of a remote viewer to a running Java Language Runtime, with proxy support for objects under observation. For example, there are classes for RemoteObject, RemoteStackFrame, etc.

This API defines a RemoteDebugger class which serves as a viewer for the Java Language Runtime being debugged. This class's methods perform general operations, such as returning arrays of RemoteClass or RemoteThread. More specific operations are supported through the methods of these classes. To get a class's methods, for example, the RemoteClass method getMethod() would be used. To print one of those methods' names, use its getName() method.

The Java(tm) Debugger: JDB

JDB serves both as a "proof of concept" for the Java Debugger API, and as a useful debugging tool in its own right. The TTY class implements a dbx-like debugger which supports browsing of objects written in the Java Programming Language as well as basic debugging. Tools developers are strongly encouraged to come up with something more user-friendly. <grin>

What About Security?

The debugger communicates with the java interpreter being debugged via a socket-based, proprietary protocol. This protocol is neither public nor extensible by debugging clients, primarily for security reasons.

The Java Language Runtime can only be debugged if started with the "-debug" flag. When started this way, the interpreter prints out a password to be used by the debugger, and begins listening on a dynamically allocated port. The debugger must specify the correct host and password when creating the RemoteDebugger instance.

Only one debugger may be connected to a Java interpreter in debug mode.


Copyright © 1995, Thomas Ball. Last updated August 2, 1995.

Java Developers Kit