Java Debugger/en

Aus expecco Wiki (Version 2.x)
(Weitergeleitet von Java Debugger)
Wechseln zu: Navigation, Suche

Introduction

The Java Debugger plugin provides basic Java debugging facility. It allows for debugging of Groovy blocks and any other Java code run in remote JVM directly within expecco.

The plugin provides a way to place breakpoints into a Java or Groovy code. When breakpoint hits (particular location in the code is reached), the program is stopped and a visual debugger appear. The debugger then can be used to inspect the state of the execution and/or single-step through the code.

Debugger

JDebugger plugin: debugger window

The overall layout of Java debugger window is similar to debuggers for Smalltalk and JavaScript blocks. It consists of 5 panes:

1 Execution Stack - organized top-to-bottom, i.e., the currently executing method is the first entry in the list.

2 Source Code View - shows the source code of the currently selected method (in execution stack pane). Source for particular method may or may not be available. For details refer to section Managing Sources

3 this object inspector - an embedded inspector of this objects, i.e., on the receiver of the method.

4 Method parameters and locals inspector - an embedded inspector showing all method parameters and local variables which are visible at current scope.

5 Thread List - list showing all threads in the remote JVM. The Execution Stack pane shows execution stack of selected thread.

Following debugging operations are available:

  • Continue - resumes execution until remote JVM terminates or another breakpoint is reached.
  • Abort - aborts execution of currently executing expecco Groovy block. If the selected thread does not execute a Groovy block abortion

is not allowed.

  • Next - aka Step-over. Single-step to next line in currently selected method. Does not enter into called methods.
  • Next - aka Step-into. Single-step to next line in currently selected method or into a called method.
  • Out - aka Step-out. Run until currently selected method returns and stop's at the method's caller.

Breakpoints

Java Debugger plugin supports two kinds of breakpoints:

  1. Line Breakpoints - a traditional breakpoint set on particular line in particular method.
  2. Exception Breakpoints - a breakpoint that suspends execution when an exception of specified type is thrown.

Line Breakpoints

A line breakpoint could be placed to a Groovy block or to any other Java code. When a line breakpoint is hit whole JVM is suspended, i.e., all running Java threads are suspended.

To put a breakpoint in a Groovy block, just click in Groovy block editor left to the line number. The line breakpoint is indicated by a little red circle icon. To remove a breakpoint, just click on the breakpoint icon again.

To put a breakpoint in any other Java code, open a Java browser window, navigate to desired class and method and click left the line number.

Exception Breakpoints

An exception breakpoint hits when an exception of given type (or it's subtype) is thrown, i.e., at the point just before Java throw statement is executed. This is useful when an exception is thrown and possibly caught and re-thrown again to find out the original cause and debug there.

Exception breakpoints could be configured to trigger in two cases:

  • For caught exceptions - the breakpoint will hit (program will be suspended) if an exception is thrown and would be caught by some handler deeper in the execution stack. Note, that any finally or synchronized block creates

an implicit exception handler for type java.lang.Throwable.

  • For uncaught exception - the breakpoin will hit only if an exception is thrown but it is not handled by any handler, i.e., it is unhandled.

Warning: The JVM cannot always reliably tell whether a given exception is actually caught or uncaught. For details, refer to JDI documentation

Object Inspector

JDebugger plugin: Java object inspector

TBW...


Managing Sources

Java Debugger plugin uses Java Browser/en fro accessing source code. The source code for particular class / method is looked up in Java Browser's default workspace. This means that if the default workspace does not contain a source code for the class, Java debugger will not show source code. However, it is still possible to inspect parameters and other local variables and even single-step.

If the sources does not match the sources which the Java code has been compiled from, Java debugger may show invalid source code or line numbers may not match. There is no way to validate the sources matches the code loaded in remote JVM.

For more information about default workspace and how to add classes and sources to it, please refer Java Browser plugin documentation


Limitations

The current version of JDebugger has some limitations:

  • A line breakpoint cannot be placed to a nested classes, i.e., to inner classes and to anonymous classes. Note, that UI event handlers, such as button click handlers, are usually implemented using anonymous classes.
  • A breakpoint cannot be placed on a class which is loaded more than once in remote JVM.

These limitations will be addressed in a future versions.



Copyright © 2014-2016 eXept Software AG