Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] invokeinterface when there is an ITD default implementation results in NoSuchMethod

Hi,

Really hard to say what should and shouldn't happen here because (as
you know) -XterminateAfterCompilation is not really for end user usage
- it is purely for internal testing and debugging.  I don't have any
AspectJ tests that verify the state of the intermediate classes
(without weaving) when using generic ITDs.

Without generics, is the interface still empty when you javap it?
Actually what is different in either the aspect or the interface with
and without generics.

> I solved it removing the generic type, but don't know if it is a bug or a
> known limitation of applying generics on binary classes / from binary aspect
> library (due to erasure), or something else.

What I can say is that they should behave the same - but I can't tell
you what the behaviour will be in terms of what the intermediate
classes should look like...  erasure will occur but is recovered from
when binary weaving.

cheers,
Andy

On 14 July 2010 07:31, Simone Gianni <simoneg@xxxxxxxxxx> wrote:
> Hi all,
> I noticed the following :
>  * I have an interface, that declares some method signatures
>  * I have an aspect with ITDs that provide a default implementation of those
> methods
>  * then i have some classes that implement that interface
>  * as always, I use -XterminateAfterCompilation, so I see "intermediate"
> classes on disk, but then run LTW to complete the weaving process.
>
> Running javap on the interface, it seems like the interface is empty.
> Running javap on the aspect however, I can see some invokeinterface calling
> the interface methods. I suppose AspectJ will catch those calls and re-route
> them properly to the implemented methods, during the last step of weaving
> (that in my case happens during LTW)
>
> Usually, everything works correctly, but under some circumstances it seems
> like those invokeinterface are executed without having been reweaved,
> leading to NoSuchMethod errors on the interface (which is quite confusing).
>
> The case I found yesterday was about an interface with generics, something
> like :
>
> public interface HasChildren<T> {
>   public List<T> getChildren();
> }
>
> With a default ITD implementation (simplified) :
>
> public aspect HasChildrenImpl {
>
>   private List<T> HasChildren<T>.children = new ArrayList<T>();
>
>   public List<T> HasChildren<T>.getChildren() {
>     return children;
>   }
>
> }
>
> It worked correctly in the project, compiled without any warning and tests
> were ok. When used as an aspect library however, it seems like the weaver
> was not able to catch it anymore, and a call to getChildren resulted in a
> NoSuchMethod on HasChildren.getChildren, that traced back to that
> invokeinterface call. There was no warning or error issued from LTW about
> not matching or having troubles.
>
> I solved it removing the generic type, but don't know if it is a bug or a
> known limitation of applying generics on binary classes / from binary aspect
> library (due to erasure), or something else.
>
> Simone
>
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>
>


Back to the top