Community
Participate
Working Groups
Probably related to Bug 72528, i get the above said error while compiling the test code, i think this is caused due to the return type of a method being an Integer[] and the around advice captures it and returns an Object[]. Below is the complete error message: Incompatible return type applying to method-execuition(java.lang.Integer[] de.rohith.PrinterWorld.returnArrayWithCloning()) Incompatible return type applying to method-execuition(java.lang.Integer[] de.rohith.PrinterWorld.returnArrayWithoutCloning()).
Created attachment 14186 [details] Contains test code
Assigning to Andy for consideration whilst working on the related bug.
any verifyerror is serious, this should be fixed in AJ5 M3...
Finally managed to give this bug a closer examination, and realised that this isn't a bug at all - AspectJ is working as designed. The reason is that the returnArrayWithCloning method has a contract that says it will return an Integer[], but your around advice has a contract that says it will return an Object[]. Thus the return type of the advice does not guarantee to meet the contract of the advised method. The following short program demonstrates this: public aspect pr72668 { Number[] getThoseInts() { return new Integer[0]; } declare warning : execution(Object[] *(..)) : "should not match"; @org.aspectj.lang.annotation.SuppressAjWarnings("adviceDidNotMatch") Object[] around() : execution(*[] *(..)) { Object[] ret = proceed(); return (Object[]) ret.clone(); } Integer[] around() : execution(*[] *(..)) { Number[] ret = proceed(); return (Integer[]) ret.clone(); } } The advice returning Object[] does not match at the shadow and gives an incompatible return type error. The advice returning Integer[] does match, because an Integer[] is guaranteed to meet the contract of a method that returns a Number[].