Skip to main content

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

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

Back to the top