Bug 240011

Summary: Support inline definition of types in "declare parents"
Product: [Tools] AspectJ Reporter: Ramnivas Laddad <ramnivas>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ramnivas Laddad CLA 2008-07-08 11:43:18 EDT
A well-known AspectJ idiom calls for creating an intermediate type (usually an interface), using declare parents to make it a super type of a set of type, and introducing members to it.

aspect EntityManagement {
    private static interface IEntity {
    }

    declare parents: com.myco.domain.* implements IEntity;

    private long IEntity.lastAccessedTime;

    ... advice to IEntity+ ...
}

This idiom may be simplified if the declare parents declaration were to allow something like:

declare parents: <TypePattern> <implements|extends]> <Type> [{ [TypeBody] } ];

This declaration defines the parent type and makes it a super type for the matching types in one statement. Then the aspect will simplify to the following:

aspect EntityManagement {
    declare parents: com.myco.domain.* implements IEntity { };

    private long IEntity.lastAccessedTime;

    ... advice to IEntity+ ...
}

This feature also offers a simpler way to implement the "typedef" feature and may help in reducing the number of parentheses when creating annotation-based pointcuts.