Interactive Visualization of Java Programs Paul Gestwicki, Bharat Jayaraman Department of Computer Science and Engineering University at Buffalo (SUNY) Buffalo, NY, USA Abstract The design and implementation of a novel visual interac- tive execution environment for Java is described. This sys- tem displays both the run-time object structure as well as the internal details of object and method activations. The representation of the execution state is based upon a novel yet simple representation technique which clarifies the im- portant fact that objects are environments. All major Java features, including inheritance, inner classes, static meth- ods, exceptions, etc., are supported. The GUI components built from Java’s Swing or AWT libraries can be visualized in juxtaposition with the underlying execution state. We also include a reverse-execution mechanism that allows a user to rollback to previous states of an execution. A notable char- acteristic of the visualization system is that it employs the existing Java Virtual Machine, i.e., no new Java interpreter is needed. A novel pre-processor (source-to-source trans- formation) is employed in conjunction with a run-time me- diator written in Java, which carries out the visualization. A prototype of these ideas has been completed to validate the entire approach. 1. Introduction The object-oriented paradigm has been widely adopted by industry and academia alike. There are many inte- grated development environments for object-oriented pro- gramming languages, such as Forte for Java, VisualStu- dio .NET, and VisualWorks Smalltalk. Tools like Ratio- nal Rose allow for visual modeling using the UML, and more recently developed tools such as Rational XDE at- tempt to unify the design process with the development pro- cess. While software development tools have advanced and matured, tools for visualizing the execution state of object- oriented programs are still lagging behind, and the subject remains an active area of research today. The execution state of object-oriented programs dif- fers fundamentally from that of procedural programs be- cause an object is an environment within which method activations take place. One characteristic of the object- oriented methodology is that it encourages the use of many small methods, resulting in considerable context-switching among objects at runtime. Depicting the calling sequence of methods is not sufficient; both object-structure and call- sequence should be depicted simultaneously, and method activations need to be shown in their respective object con- texts. Thus, the visualization for objects cannot be textual (as in a traditional dbx style debugger for C), but must be vi- sual/graphical in nature. For example, classic tools such as the Smalltalk inspector [8] as well as state-of-the-art tools such as IBM’s Visual Age for Java present a clear picture of the sequence of method calls and also allow inspection of the internal details of objects. However, neither the run-time object structure nor the method invocations inside these ob- jects is depicted by these tools, and hence important rela- tionships among objects are omitted. This paper describes a novel approach to visualizing the execution state of object-oriented programs in general and Java in particular. Our approach is incorporated into an in- teractive visual execution tool for Java, which serves as a sophisticated visual debugger and valuable teaching tool. It allows for interactive execution of user programs, giving a graphical display of the execution state in a clear manner. The tool supports normal execution as well as the ability to rollback and visualize previous states in the execution his- tory. Our designs allow for incorporation of sophisticated graph-drawing techniques to produce optimal and aesthetic graphs that depict object structures. Runtime behavior can be shown in flexible ways, clarifying scope as well as pat- terns of methods invocations. A plausible approach to developing such a visualization tool is to re-implement the Java interpreter so that it not only executes Java code but also displays the run-time state in a visual manner. This requires substantial work, since a new compiler must be written to translate Java source code into modified JVM (Java Virtual Machine) instruc- tions, and this modified JVM would need to be imple- mented. The issue of dealing with language libraries must