AspectJ Browser
GUI tool for compiling programs with ajc and navigating the
crosscutting structure (early-access)
Overview
The AspectJ Browser is a development tool that will allow you to
compile using ajc, navigate your program's static structure, edit
source files, and graphically edit build configuration files.
To use the browser launch it by typing "ajbrowser" (assuming that
you've followed the instructions for setting up ajc). You can either pass in one or more
".lst" build configuration files as command line parameters to the
browser in order to build them and navigate the corresponding
structure, or you can open one or more ".lst" files with "File ->
Open" or with the "Open Build Configuration" button
(
).
Compiling a Build Configuration
To compile click the "Build" button
(
), or click <ctrl>F11. You may also select a
different build configuration here, as in label 1.
Navigating the Program Structure
Select nodes in the program structure by clicking them (as in label 2).
If one node is related to one or more other nodes by an association the
name of the association will appear below that node and will be
displayed in italics. Links to other structure nodes appear in blue
below the association. If there is no corresponding source for the
link it will appear light-blue.
Manipulating Build Configuration
Build configurations can be manipulated adding, removing, and
editing build configuration files using the corresponding toolbar
buttons. The current configuration can be selected in the
configurations listbox. Build configurations are represented by
".lst" files (which are described in the ajc documentation).
Example: Exploring the "Spacewar" sample code
Launch ajbrowser
Choose "File -> Open" or click the "Open Build
Configuration" button
(
) and select the configuration file for debugging
the spacewar example, in
examples/spacewar/debug.lst.
Click the "Build" button (
) to
compile. The left pane should fill with a spacewar declaration
tree. If there is a compiler error, the clickable error message
shows up as in label 4.
Note: If you did not install in the default location, the
compile will fail with a message that you need to install
aspectjrt.jar on your compile classpath. To do that, select "Tools
-> Options" or click the "Options" button
(
). Click the Build Options tab
to view the Build Paths pane. Edit the classpath entry to use your
install location, ok the dialog, and retry the compile.
Different structure views: The structure tree at the
left can display different orderings and granularity for structure:
The package hierarchy view shows the traditional hierarchy
of package, class, and members.
The inheritance view shows the hierarchy from topmost
parent classes through subclasses to members.
The crosscutting view shows the aspect members
and the code they affect.
Additional buttons in the pane can be used to change the
granularity and filter out items.
Whenever you select an item in the tree view, the
source pane scrolls to that item. If you select a leaf item
representing another program element, then the tree
selection will go to the corresponding node. (See below for
how to use two panes to maintain your place.)
When working with aspects, it helps to be able to navigate
between different program elements:
When looking at a method, find the advice that
affects it.
When looking at a pointcut, find the advice that
uses it.
When looking at advice, find what it advises -
e.g., method calls or executions, initializers, etc.
When looking at a type, find any aspects that
declare members or supertypes of the type, or
vice-versa.
You can view the advice on a particular method using the
default, hierarchical view. Navigate to the tree item for
spacewar.Registry.register(SpaceObject)
in the debug.lst config file. Now, in
the lower, file view, you can see and navigate to the advice
using the subtree whose parent is the method
affected by relation.
You can also use crosscutting view to see the
advice using a pointcut or the methods affected by advice.
For example, to see what advice uses a particular pointcut,
navigate to the tree item for the pointcut
spacewar.Debug.allConstructorsCut() in
the debug.lst config file. You can see
and navigate to the advice that uses the pointcut using the
pointcut used by relation.
As an example of seeing the methods affected by advice,
while still in the same view, select the first
before advice in
spacewar.Debug. It has relation
sub-trees for both uses pointcut and
affects constructions. The
affects relations will list different
kinds of join points - constructor or method calls, etc.