Runtime Aspect Weaving Through Metaprogramming

Jason Baker and Wilson Hsieh

University of Utah, School of Computing
50 South Central Campus Drive, Room 3190
Salt Lake City, Utah 84112-9205

{jbaker,wilson}@cs.utah.edu
http://www.cs.utah.edu/flux/

Abstract

We describe an extension to the Java language, Handi-Wrap, that supports weaving aspects into code at runtime. Aspects in Handi-Wrap take the form of method wrappers, which allow aspect code to be inserted around method bodies like advice in AspectJ. Handi-Wrap offers several advantages over static aspect languages such as AspectJ. First, aspects can be woven into binary libraries. Second, a wrapper in Handi-Wrap is a first-class Java value, which allows users to exploit Java mechanisms to define and weave wrappers. For example, wrappers can be passed explicit constructor arguments, and wrapper objects can be composed. Finally, methods in all Java classes, including anonymous classes, can be wrapped. A prototype of Handi-Wrap is implemented in a compile-time metaprogramming system for Java, called Maya; we briefly describe how Maya's features support Handi-Wrap.

Appeared in The 1st International Conference on Aspect-Oriented Software Development. A previous version of this paper is available as a tech report.


Jason Baker <jbaker@cs.utah.edu>
Last modified: Mon Jun 24 10:43:58 MDT 2002