Bug 212353 - FindBugs error in abstract aspect that uses pertypewithin - Superclass uses subclass during initialization.
Summary: FindBugs error in abstract aspect that uses pertypewithin - Superclass uses s...
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.4RC1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-09 17:00 EST by Bhaskar Maddala CLA
Modified: 2013-06-24 11:06 EDT (History)
1 user (show)

See Also:


Attachments
Simple eclipse project zipped to reproduce the error (2.24 KB, application/octet-stream)
2007-12-09 17:02 EST, Bhaskar Maddala CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bhaskar Maddala CLA 2007-12-09 17:00:46 EST
I have an abstract aspect, where I define my point cuts, and 2 derived concrete aspects that use the pointcuts to implement advice. On building in eclipse and running findbugs I get the following bad practice bug

    Superclass uses subclass during initialization.

  I looked at the byte code and I can see that the abstract aspect had references to the concrete aspects. The reason was an overly broad definition of pertypewithin. Below is a toy code sample that results in this findbugs error

package bar;
public abstract aspect AbstractAspect pertypewithin(bar..*) {
    pointcut loginitialization() : staticinitialization(bar..*);
    pointcut loggedMethods() : (within(bar..*)) && execution(* *.*(..));
}

package bar;
public aspect ConcreteAspect extends AbstractAspect {
    after() : loginitialization() {}
    before() : loggedMethods() {}
    after() : loggedMethods() {}
}

The AbstractAspect satisfies the pertypewithin scope and is advised by ConcreteAspect.after():loginitialization

Having a concrete aspect advice a abstract aspect that it inherits seems to be an anti-pattern (at least when using pertypewithin), which is really the reason for FindBugs to be complaining.

Requested Enhancement : Aspectj compiler should report an appropriate warning indicating such a scenario.

Attachment contains a small eclipse project to reproduce the issue.
Comment 1 Bhaskar Maddala CLA 2007-12-09 17:02:03 EST
Created attachment 84818 [details]
Simple eclipse project zipped to reproduce the error
Comment 2 Andrew Clement CLA 2013-06-24 11:06:09 EDT
unsetting the target field which is currently set for something already released