Bug 158126 - Bug related to annotations on constructors
Summary: Bug related to annotations on constructors
Status: RESOLVED WORKSFORME
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-21 06:40 EDT by Paulo Zenida CLA
Modified: 2006-09-21 11:00 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 Paulo Zenida CLA 2006-09-21 06:40:30 EDT
Hello all,

I have found something that I believe it is a bug related to 
annotations on constructors. The code is the following:

public class A {

        @MyAnnotation
        public A() {
                new B();
        }

        @MyAnnotation
        public A(int i) {
                new B(i);
        }

        public static void main(String[] args) {
                new A();
                new A(1);
        }
}

public class B {

        @MyAnnotation
        public B() {

        }

        @MyAnnotation
        public B(int i) {

        }
}

@Target(ElementType.CONSTRUCTOR)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {

}

public aspect MyAspect {

        before() :
                call(@MyAnnotation *.new(..)) {
                System.out.println(thisJoinPoint);
        }
}

The result:

call(pt.iscte.ci.test.A())
call(pt.iscte.ci.test.A(int))

Why aren't the calls to B() and B(int) matched and shown in the output? 
If I change the pointcut to call(*.new(..)), the output is the expected:

call(pt.iscte.ci.test.A())
call(pt.iscte.ci.test.B())
call(pt.iscte.ci.test.A(int))
call(pt.iscte.ci.test.B(int))

This is a bug, right?

Best regards,

Paulo Zenida
Comment 1 Matt Chapman CLA 2006-09-21 06:42:55 EDT
Passing over to compiler
Comment 2 Andrew Clement CLA 2006-09-21 09:01:13 EDT
As soon as I added this test code to the compiler, I realised it would have been impacted by a fix I made last week.  So this code already works with the latest AspectJ dev build - and an AJDT build including it will be released shortly.

I've added the test case anyway, as it is a nice one to have.
Comment 3 Helen Beeken CLA 2006-09-21 11:00:58 EDT
The latest 1.4 and 1.5 AJDT dev builds now contain this fix.