XAspects: Extensible Plug-ins for
Aspect-Oriented Programming
Design Specifications - XAspects Compiler : XAJC

Macneil Shonle
Ankit Shah
Version 1.1
12 March 2003

Download Source Code of XAJC Compiler


public class XAJC {
    public static void main(String[] args);

    private static void forkAjc(String[] args) throws Exception;

    private static void terminate();

    private static void filesCopy (File[] source, File dest) throws Exception;
    private static void tmpDirDelete (File dir);

    private static void usage ();
    private static void version ();

    private static void printErrs();
    private static void printWrns();
}

Working of the Compiler

The main method method of XAJC class implements the whole functionality of the compiler. It essentially implements the following steps:

  1. Process command line arguments. If incomplete or erroneous print usage
  2. Pass the names of input files to an instance of SourceExtractor and then invoke methods to process these files and capture data in AspectInfo objects. An array of this AspectInfo objects will be returned.
  3. Instantiate a single instance of CompilationEnvironment
  4. Pass AspectInfo objects to correct plugins or print error message that a plugin wasn't found. Instantiate an object for each plugin only once
  5. Invoke generateExternalInterfaces methods on all plugins. Receive an array of files generated and make a copy of it for use.
    If warnings are generated, print them.
    If errors are generated print them and terminate
  6. Compile all the files received in the previous stage. Make a list of all class files generated and delete the files received in the previous step.
    If compiler errors, then terminate
  7. Invoke generateCode methods on all plugins. Pass the array of classfiles. Receive an array of generated files from each plugin and copy it to temporary directory.
    If warnings are generated, print them. If errors are generated, print them and terminate.
  8. Compile all the files received in the previous stage. In case of compiler error, terminate.
    Else copy all the files to the target directory and then terminate

ForkAjc()

ForkAjc method takes in an array of arguments and invokes the ajc compiler with those arguments to compile all the generated .java files. It throws an Exception in case of a compiler error.

Terminate()

terminate() method calls cleanup method of all plugins, deletes all the temporary files generated throughout the compilation and then exits the virtual machine.

Utility Methods

File Management methods

tempDirDelete() empties the temporary folder and deletes it.
filesCopy copies the bunch of files to the specified directory

Informative methods

usage() spells out usage of the compiler and version() prints the version of the compiler

Error / Warning Handling methods

printErrs() and printWrns() print out all the new errors and warnings on the screen respectively

References

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

AspectJ, <http://www.aspectj.org>.

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