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

----------------------------------------------------------------
Mensagem enviada usando o IMP (Internet Messaging Program).


_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to