Community
Participate
Working Groups
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13 (.NET CLR 3.5.30729) Build Identifier: The following code produces a 'incompatible return type error', though - in my opinion - it should not: package asp; aspect Intercept { ConstructorIntercept around(String s) : call(ConstructorIntercept+.new (String)) && args(s) { return proceed(s + ", World"); } } public class ConstructorIntercept { private String s; public String toString() { return this.s; } ConstructorIntercept(String s) { this.s = s; } public static void main(String []av) { System.out.println(new ConstructorIntercept("Hello") { }); } } Reproducible: Always Steps to Reproduce: 1. Save above code in asp/ConstructorIntercept.java 2. Run /opt/aspectj1.6/bin/ajc -classpath /opt/aspectj1.6/lib/aspectjrt.jar:. asp/ConstructorIntercept.java 3. See the error I believe this is an error because, curiously, the following program compiles and runs: package asp; aspect Intercept { Object around(String s) : call(ConstructorIntercept+.new (String)) && args(s) { return proceed(s + ", World"); } } public class ConstructorIntercept { private String s; public String toString() { return this.s; } ConstructorIntercept(String s) { this.s = s; } public static void main(String []av) { System.out.println(new ConstructorIntercept("Hello") { }); } } The only difference is the return type of the 'around' advice - Object vs. ConstructorIntercept. If returning Object is okay, why not ConstructorIntercept?