XAspects: Extensible Plug-ins for
Aspect-Oriented Programming
Design Specifications - Traversal Plugin

Macneil Shonle
Ankit Shah
Version 1.1
12 March 2003

Download Source Code of Traversal Plugin

public class Traversal extends AspectPlugin{

    public Traversal ();

    public void init (CompilationEnvironment ce);

    public void receiveBody(AspectInfo aspectInfo, String aspectID, String body);
    public File[] generateExternalInterfaces();
    public File[] generateCode(File[] classFiles);

    public void cleanup();
    private void partialCleanup();

    private void printErrors ();
    private void printErrors2 ();

    private void redirectOutputs () throws FileNotFoundException;
    private void restoreOutputs ();

    private File[] generatedFiles();
    private void copyFiles(File[] source, File dest);

Constructors and Initialization

Since, parameterized constructors cannot be called, init is implemented to initialize the plugin so that it can have a reference to the CompilationEnvironment instance that helps communications during the proces. Since, no additional initialization is necessary, these methods pass on the calls to the corresponding methods of the super classes.

Implementing the receiveBody() method

No special pre-processing is necessary to the incoming code fragment. Hence, it is stored away in a .trv file with the corresponding aspectID as the filename.


Traversal Stubs are generated during this method
To capture all the messages generated by DAJ, output will be redirected to two different disk files and restored after all the processing is completed. These files may later be analyzed for further errors and warnings.
We leverage the stub generation functionality out of DAJ using the methodDAJ.generateStubs(List, File)
printError1() will report any errors generated.

Returning Calls
Invoke method generatedFiles() to return the list of .java Files in the working Directory. Return that list.


The input bytecodes are extremely necessary to generate Traversals. We leverage code from DAJ.generateTraversals(List, File, boolean, File)
printError methods will print any errors generated during compilation and will also analyze the redirected output files to see if some more errors were generated.


Temporary files created for storing redirected outputs are deleted. Then, as per AspectPlugin requirements, call cleanup of superclass.

Helper Methods

Error Processing Methods


Reads text printed to Standard error (available in redirected file) and reports errors accordingly


Reads text printed to Standard output (available in redirected file) and analyzes it to see if any error messages have been written. If there are, then they are reported to the CompilationEnvironment


This method scans the working Directory for all .java files, collects them in an array of File objects are returns the array. It returns null if no .java files are found


This method deletes the temporary files that received the redirected output.


XAspects Project Home Page, <http://www.ccs.neu.edu/research/demeter/xaspects>.

DAJ API, < http://daj.sourceforge.net/api/edu/neu/ccs/demeter/tools/daj/DAJ.html>.

Traversal Syntax, <http://daj.sourceforge.net - Language Reference Section>.

Author: Ankit Shah. Copyright © 2003. All rights reserved.