AspectJ and Erasure Limitation

January 4th, 2008 by peasleer

As previously mentioned in this blog, I’m taking a programming skills course focusing on Aspect Oriented Programming (AOP) using AspectJ. I am using eclipse with the AspectJ plugin to develop, and recently came across a situation where I wanted to define a pointcut based on an object that uses generics. In attempting to do so, I got the following error in eclipse:

parameterized types not supported for this and target pointcuts (erasure limitation)

While the error puzzled me momentarily, a quick hop over to the AspectJ developer notebook sorted things out. The full description of the solution is there if you want to read, but the quick fix is easy: remove the generic identifier of whatever you are trying to match against.

For example, this is incorrect:

pointcut badPointcut(): target( List<String> );

While this is the fixed version:

pointcut goodPointcut(): target( List );

Now get back to work :)


0 Responses to “AspectJ and Erasure Limitation”

Feed for this Entry Trackback Address
  1. No Comments

Leave a Reply