= Debugging AspectJ Programs

_Last updated: 2003-11-26 by wisberg_

== Debugging AspectJ 1.0 Programs

The AspectJ 1.0 compiler produces .class files that have the normal
source file attribute and line information as well as the information
specified by JSR-045 required to debug .class files composed of multiple
source files. This permits the compiler to inline advice code into the
.class files of the target classes; the advice code in the target class
can have source attributes that point back to the aspect file.

Support for JSR-45 varies. At the time of this writing, Sun's VM
supports it, but not some others, which means that the Sun VM must be
used as the runtime VM. Because the VM does all the work of associating
the source line with the code being debugged, debuggers should be able
to operate normally with AspectJ 1.0 source files even if they weren't
written with that in mind, if they use the correct API's to the
debugger. Unfortunately, some debuggers take shortcuts based on the
default case of one file per class in order to avoid having the VM
calculate the file suffix or package prefix. These debuggers do not
support JSR-45 and thus AspectJ.

== Debugging AspectJ 1.1 Programs

The AspectJ 1.1 compiler usually implements advice as call-backs to the
aspect, which means that most AspectJ programs do not require JSR-45
support in order to be debugged. However, it does do a limited amount of
advice inlining; to avoid this, use the `-XnoInline` flag.

Because inlined advice can be more efficient, we plan to support JSR-45
as soon as feasible. This will require upgrading the BCEL library we use
to pass around the correct source attributes.

Sometimes debuggers correctly get the source line information, but fail
when they attempt to parse AspectJ source files expected to contain Java
code. For these it might be possible to step into AspectJ code, but not
to set breakpoints, or to work around the parse errors by using `.aj`
rather than `.java` as a file extension.
