Bug 124654 - Capture method annotation in generic aspect does not compile
Summary: Capture method annotation in generic aspect does not compile
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.1   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-20 10:32 EST by hesse CLA
Modified: 2006-01-24 06:15 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hesse CLA 2006-01-20 10:32:07 EST
The following aspect won't compile with aspect 1.5:

package aj;

import java.lang.annotation.Annotation;

public abstract aspect GenericAnnotation<A extends Annotation> {

    pointcut annotatedCall(A a) : call(@A * *.*(..)) && @annotation(a);

    /* does not compile */
    before(A a) : annotatedCall(a) {
        System.out.println(a.annotationType());
    }
    /* */

    /* OK */
    before(A a) : call(@A * *.*(..)) && @annotation(a) {
        System.out.println(a.annotationType());
    }

}

----------------------

>ajc -1.5 -d aj src\aj\*
...\src\aj\GenericAnnotation.aj:10 [error] incompatible type, expected java.lang.annotation.Annotation found BindingTypePattern(TA;, 0).  Check the type specified in your pointcut before(A a) : annotatedCall(a) {

1 error

----------------

Commenting out the first advice lets this program run as expected:

package aj;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

public class Main {

    @Retention(RetentionPolicy.RUNTIME)
    @interface MyAnnotation {
    }

    static aspect ConcreteAnnotation extends GenericAnnotation<MyAnnotation> {
    }

    public static void main(String[] args) {
        someMethod();
    }

    @MyAnnotation
    private static void someMethod() {
    }

}
Comment 1 Andrew Clement CLA 2006-01-20 12:11:00 EST
appears the code putting out the message isnt being smart about encountering type variables...
Comment 2 Andrew Clement CLA 2006-01-23 10:20:03 EST
fix checked in.
Comment 3 Andrew Clement CLA 2006-01-24 06:15:27 EST
fix available.