Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] weaving of generic types fail when parameterize

I am creating an extension to the List interface using generics, and am getting an error from AspectJ saying "Can't ask to parameterize a member of non-generic type". Here are the particulars:

Versions: 1.5.2a, 1.5.3
OS: Windows XP

I have a simple advice that examines a returned List:

@AfterReturning(pointcut="execution(public List com.mycompany.*.get*())",returning="lval")
  public void afterReturningListMethod (List lval)
  {
      // do something
  }

I have an extension to List as follows:

  public interface MyList<E> extends List<E>
  {
  }

I then create an implementation of MyList as follows:

  public class MyListImpl<E> implements MyList<E>
  {
      // simple List implementation methods
      ...
  }

As a step during the weaving, AspectJ verifies that all required implementations of List exist for all the join points. The code presented so far actually works with no problems. But when I make one simple change, the weaving fails. All I do is add one method to the interface:

  public interface MyList<E> extends List<E>
  {
      public void doSomething();
  }

The implementation class adds a trivial method implementation:

  public class MyListImpl<E> implements MyList<E>
  {
      public void doSomething() {/*do nothing*/}

      // simple List implementation methods
      ...
  }

AspectJ now produces an error. Here is an extract from the log:

info weaver operating in reweavable mode. Need to verify any required types exist.
  abort trouble in:
public class com.mycompany.MyListImpl extends java.lang.Object implements com.mycompany.MyList:
  ...
-- (IllegalStateException) Can't ask to parameterize a member of non-generic type: com.mycompany.MyList kind(raw) Can't ask to parameterize a member of non-generic type: com.mycompany.MyList kind(raw) java.lang.IllegalStateException: Can't ask to parameterize a member of non-generic type: com.mycompany.MyList kind(raw) at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:612)
      ...

Any ideas on what I'm doing wrong? I tried making the interface an abstract class instead but that made no difference. Any possible workarounds?

Thanks.

- Peter



Back to the top