[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Generic aspect inter-type declaration - possible or limitation of aspectj?
|
Hi everybody (...hi doctor Nick :)
Im trying to make an aspect which will introduce some members into a class.
I have the classes Person and Course.
public
class Course {}
public class Person {}
My idea is to introduce a HashSet of type Person into the class Course.
I can succesfully achieve this with the following aspect:
public aspect BoundAspect {
public HashSet<Person> Course.genericHash = new HashSet<Person>();
public void Course.newMethod(Person per)
{genericHash.add(per);}
}
Now. I want to make this a tiny bit more general. Instead of only
being able to introduce a HashSet of type Person as well as a method
that works on type Person, I want a solution that can be
parameterized. I have tried the follwoing - notice that the aspect
must now be abstract, hence I have added the aspect ConcreteAspect
which extends AbstractGenericAspect
public abstract aspect AbstracGenericAspect<TO> {
public HashSet<TO> Course.genericHash = new HashSet<TO>();
public void Course.newMethod(TO to)
{genericHash.add(to);} // here I receive the error: The method
add(TO) in the type HashSet<TO> is not applicable for the arguments
(TO)
public
aspect ConcreteAspect extends AbstracGenericAspect<Person> {}
!! Notice the error: /The method add(TO) in the type HashSet<TO> is
not applicable for the arguments (TO)/. This does not make sense to
me. Am I doing something wrong or is this a limitation of AspectJ?
Have a nice weekend / Andreas