[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Generic aspect inter-type declaration - possible or limitation of aspectj?
|
that looks like a bug to me.
You may be able to workaround it through the use of an interface:
abstract aspect Foo<T> {
interface Bar<T> {}
declare parents: Course implements Bar<T>;
public List<Z> Bar<Z>.genericHash = new ArrayList<Z>();
public void Bar<Z>.add(Z t) { genericHash.add(t); }
}
2009/8/21 Andreas Holst <aspectj.andreas@xxxxxxxxx>:
> 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
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>