Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Bug related to Annotations on constructors

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).




Back to the top