[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?
|
- From: Andy Clement <andrew.clement@xxxxxxxxx>
- Date: Mon, 24 Aug 2009 14:32:00 -0700
- Delivered-to: aspectj-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=mxUkievJHAbk5Ud0Uwy6kTbtrNmWjUWlW5Tyo0x/nGM=; b=VD834Ay/7Gqou+BhvLDVt+dx6pUamoUs5CroVGIRWlIojgZva0EO8E4bMX7Bja8XIu XhInh8QaSg1fnoIVQS9LG3Izz8B/KyMSpyJa8ZOh4v+g0OT050HhHTmq3JzvKud8jvLF Yqs9/ORi2Q9wx7awVwsxmkkbYgujWXnkjFiJU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=qJljZGJj0ztK6v8ykRZSuDBX8N4iXp4yf4+W8RrqcQtOWNveX1bIgu7qHkmnPOaYmF n3ZovD8+4ic9D/bMCtNp4gYUZGRDN5MULK3W7JfECaUX35SMMr/JrwvuNuNpdbfspakm evsKEV+Jh0FhGwqM9alRKI0AkPyhKCOM4AMcw=
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
>