[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?
|
- From: Andreas Holst <aspectj.andreas@xxxxxxxxx>
- Date: Sat, 22 Aug 2009 03:10:29 +0200
- 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:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=bBQL4DLcPYXXXf3X2VfDRYtDNcwTyDn1kbSpQI+UTGQ=; b=JdxU2vo6zeVdMvliEnkBM/Qy0D53Xc3El3j6yvvXpYYiGLZ70Nzqik0Pwj3CdhpDWZ eo/NYCN5xm/NDW7cJgGqaGrbCvSWjEIRPreDkC8OW22YBuMGVTMf6H+IdGwXOuQGJVJ6 yCuQw8BKuLxMWpo/D37hwDie8nGaopjk98zOk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=M9MdYXJLsnA9FJyNwHKXeAc8e1ZaiXQyHeXXs6UieR4zttqCIthJV/WcWHS+y+0jqC R+JIv5rGfijR5O9WfEkU78a4NGS/TnuXe2rEAV43awGTDaC9O4ajn2hxvOsK8iTEF3ak LI8BiFUh+zRh9yGYWHJFUXEUbME2E6tpeCsZ0=
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