[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] weaver has problems with serializable generics

The weaver throws an IllegalStateException when I have a generic type that implements Serializable. An example would be:

  public class MyList<E> implements List<E>, Serializable
   {
      ...
   }

The problem occurs when the weaver is handling an advice of the form:

@AfterReturning(pointcut="execution(public List com.mitratech.*.get*())", returning="rlist")
public void afterReturningListMethod (List rlist)
{
//do something or nothing
}


The weaver throws the following error:

abort ABORT -- (IllegalStateException) Can't ask to parameterize a member of non-generic type: com.mitratech.MyList kind(raw)
Can't ask to parameterize a member of non-generic type: com.mitratech.MyList kind(raw)
java.lang.IllegalStateException: Can't ask to parameterize a member of non-generic type: com.mitratech.MyList kind(raw)
at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:612)
at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:597)
at org.aspectj.weaver.ReferenceType.getDeclaredFields(ReferenceType.java:377)
at org.aspectj.weaver.bcel.LazyClassGen.hasSerialVersionUIDField(LazyClassGen.java:315)
at org.aspectj.weaver.bcel.LazyClassGen.<init>(LazyClassGen.java:280)
at org.aspectj.weaver.bcel.BcelObjectType.getLazyClassGen(BcelObjectType.java:460)
at org.aspectj.weaver.bcel.BcelWeaver.weave(BcelWeaver.java:1568)
...


I'm wondering if there is a bug here. The reason I say this is that I tried in on the Java source code for generic collections. Sure enough, the weaver had problems with the Java generic ArrayList. Note the problem only occurs when I run it on the source code; the weaver does not have problems with the compiled ArrayList in rt.jar.

I have pinpointed the problem to the presence of the Serializable interface in the implements clause. If I remove Serializable from the declaration of MyList above, as well as from the Java ArrayList class, the weaver is happy.

I tried using Externalizable instead of Serializable, but to no avail. I really need my class to be serialized and I can't think of any workaround. Any help on this matter would be appreciated.

Thanks.

- Peter