Summary: | Incompatible return type applying to method-execuition... | ||||||
---|---|---|---|---|---|---|---|
Product: | [Tools] AspectJ | Reporter: | Rohith Ajjampur <ajjampur> | ||||
Component: | Compiler | Assignee: | Andrew Clement <aclement> | ||||
Status: | RESOLVED INVALID | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | ||||||
Version: | 1.2 | ||||||
Target Milestone: | 1.5.0 M3 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Rohith Ajjampur
2004-08-26 06:26:16 EDT
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[]. |