Aspect Jay

AspectJ is a JavaLanguage implementation of AspectOrientedProgramming (AOP), written by the folks at Xerox.

It is both a language specification and a toolset.

The language is very similar to Java, except it introduces a few new key concepts: Aspects, Pointcuts, and Advice.

The toolset includes a compiler (ajc), a javadoc-like doc generator (ajdoc), and a basic IDE.

The current version of AspectJ (1.6x) is compatible with all Java2 jvms (ajc generates java byte code).

See for more info. The documentation is really well written.

AspectJ is quickly gaining acceptance in the Java community, there are already AspectJ plug-ins for all the major IDEs.

-- KenLiu

AspectJ appears to be a nice implementation of some concepts originally invented in LispLanguage. The MixIn concept in lisp is often used to implement the CrossCuttingConcerns described for Aspect J. In fact, in the early 90's I created something in Lisp Flavors that is identical to the 'introduction' capability describe for AspectJ. The notion "advising a function" (like in AspectJ) was built into lisp earlier than 1988 (when I started with Lisp). It is an interesting to observe how "new things" are so often a reinvention of techniques that have been around a long time. (or as I put to a friend: they've figured out how to coax the "modern" language Java to do things invented 15+ years ago) --StanleyKnutson

It's true that AspectJ brings some of benefits of a dynamic language like LISP to a staticly-typed language like Java, without losing the guarantees provided by compile-time type safety and data hiding.

AspectJ aims to modularize code that would otherwise have to be spread throughout program modules because it affects many parts in a structure determined by other (more dominant) design concerns. AspectJ reduces the complexity and cost of implementing such concern, because better modularity means that when something evolves, only that module changes.

Pointcuts pick out points in the runtime execution of a program at which you want to join behavior, using advice. To help advice do its work, you can augment classes with new supertypes and members (keeping them hidden from others, if you like). And if you declare things about the program's static structure, the compiler will issue messages on point (e.g., that a certain client class shouldn't be creating a system type directly, but instead calling the application factory). An aspect is just a class plus all these, which is instantiated by the system as needed to run advice. If programmers use these new tools well, they can write code that's better than anything possible in Java alone.

In December 2002, the AspectJ project moved from being a research project at Xerox PARC to being developed in open-source fashion together with IBM's Eclipse IDE ( (largely because AspectJ 1.1 is built on the incremental Eclipse compiler). While the compiler will continue to be available standalone (without Eclipse) on the command-line and in plugins for other IDE's, the AJDT plugin for Eclipse ( will likely be the first to provide what developers expect from modern IDE's (code assistance, refactoring support, etc.) and from an AOP integration (crosscutting structure views).

The 1.1 release makes AspectJ much more usable than the 1.0 release. The incremental compiler supports quick development iterations and can weave aspects into classes from other compilers. It now supports binary aspects, and all aspects can be applied during compilation or using bytecode weaving (e.g., when loading classes), so developers can deliver binary aspects for use by users who don't build their systems or know anything about the AspectJ language.

-- WesIsberg

AspectJay is an example of how you need a PreCompiler when you want to do MetaProgramming when the language doesn't support it. -- HaskoHeinecke

AspectJay 1.0 is an example of *using* a PreCompiler to do MetaProgramming in order to extend the language. It is not needed per se, v 1.1 will remove any need. -- KenHorn?

AspectJay is not PreCompiler at all. Rather, its modern mechanics are probably better described as PostCompiler?.

Anyone who has used AspectJ for UnitTesting please comment. -- VhIndukumar

Try Presentation
CategoryProgrammingLanguage CategoryAspectOrientation

View edit of November 20, 2014 or FindPage with title or text search