Bug 240011 - Support inline definition of types in "declare parents"
Summary: Support inline definition of types in "declare parents"
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-08 11:43 EDT by Ramnivas Laddad CLA
Modified: 2008-07-08 11:43 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.