Community
Participate
Working Groups
Hi I found following strange error: When implementing an own interface in a class, every call to the class' constructors are mapped only to a no-args constructor of the interface, while logging all initializations with initialization(*.new (..)) with an after returning advice! Without the after returning advice or with after() returning : trace() && !initialization(*.new (..)) also the class constructor will be invoked (so the normal way). Example: public interface Ifc{} public class test1 implements Ifc { public test1() { super(); System.out.println("test1"); } } public class Test { public static void main(String[] args) { test1 t=new test1(); System.out.println("xz"); } } public aspect Logging { pointcut trace() : (execution(* * (..)) || initialization(*.new (..))) && !cflow(this(Logging)) && !(cflow(this(TracingConfiguration))); private String arguments(Object[] args) { String ret = new String(); if (args.length == 0) { ret = " without parameters "; return ret; } ret = " with parameters: "; for (int i = 0; i < args.length; i++) { ret += args[i].toString() + " "; } return ret; } before() : trace() { String method = thisJoinPoint.getSignature().toLongString(); System.out.println( "before " + method + arguments(thisJoinPoint.getArgs())); } after() returning(Object ret) : trace() /* && !initialization(*.new (..)) */{ String method = thisJoinPoint.getSignature().toLongString(); if (ret != null) { System.out.println( "after " + method + arguments(thisJoinPoint.getArgs()) + "returns " + ret.toString()); } else { System.out.println( "after " + method + arguments(thisJoinPoint.getArgs()) + "without return value"); } } }
Sorry, I forgot to mention the AspectJ version: Eclipse AJDE plug-in v1.0.6
This is a known and unfortunate bug in AspectJ-1.0.6. It has been fixed in the AspectJ-1.1rc1 release. We don't have the resources to do any more work on the 1.0.x branch, so I doubt that this bug will be fixed there. I recommend upgrading the 1.1rc1.