Chapter 5. Modifying structure with static crosscutting
This chapter covers
- Using member introduction
- Supplementing annotations
- Modifying type hierarchies
- Responding to compile-time errors and warnings
- Softening exceptions
Altering the dynamic behavior of the system in a crosscutting manner dominates the use of AOP. But often you’ll also need to alter the static structure of the system in a crosscutting manner. Whereas dynamic crosscutting modifies the behavior of the program, static crosscutting modifies the static structure of the types—the classes, interfaces, and other aspects—and their weave-time behavior. There are three broad classifications of static crosscutting:
- Inter-type declaration (ITD)— One type (an aspect) makes declarations for another type (an interface, a class, or even an aspect). It consists of support for member introduction, type-hierarchy modification, and annotation supplementation.
- Weave-time error and warning declarations— This form of static crosscutting detects the presence of a join point and issues errors and warnings during the weaving process.
- Exception softening— This approach lets you deal with checked exceptions in a crosscutting manner.
In this chapter, we’ll examine all these constructs and present several examples. As in the previous chapters, we’ll discuss the traditional syntax here and visit the @AspectJ syntax in chapter 7 (part of which is supported in Spring as well). Let’s start with AspectJ’s support for introducing members.