Enumerated Types in AspectJ 5
Prev | Chapter 7. Enumerated Types | Next

## Enumerated Types in AspectJ 5

AspectJ 5 supports the declaration of enumerated types just as Java 5 does. Because of the special restrictions Java 5 places around enumerated types, AspectJ makes the following additional restrictions:

- You cannot use declare parents to change the super type of an enum.
- You cannot use declare parents to declare java.lang.Enum as the parent of any type.
- You cannot make inter-type constructor declarations on an enum.
- You cannot extend the set of values in an enum via any ITD-like construct.
- You cannot make inter-type method or field declarations on an enum.
- You cannot use declare parents to make an enum type implement an interface.

In theory, the last of these two items could be supported. However, AspectJ 5 follows the simple rule that an enum type cannot be the target of an inter-type declaration or declare parents statement. This position may be relaxed in a future version of AspectJ.

If an enum is named explicitly as the target of a declare parents statement, a compilation error will result. If an enumerated type is matched by a non-explicit type pattern used in a declare parents statement it will be ignored (and an XLint warning issued).

Prev | Up | Next
Chapter 7. Enumerated Types | Home | Chapter 8. The pertypewithin Aspect Instantiation Model