| Re: [aspectj-users] Field names for generic aspects |
Hi Adrian,
abstract public aspect Aspect1<T> { interface HasTest {} declare parents : T implements HasTest; public int HasTest.test = 0;
public static void set(HasTest x, int v) { x.test = v; } public static int get(HasTest x) { return x.test; } }
>
> public aspect Aspect2 extends Aspect1<Test> { }
> public aspect Aspect3 extends Aspect1<Test> { }
>
public class Test {
public static void main(String args[]) {
Test x = new Test();
Aspect2.set(x,2);
Aspect3.set(x,3);
System.out.println("x.test = " + Aspect2.get(x));
}}
public class Test extends java.lang.Object implements Aspect1$HasTest{
public int ajc$interField$Aspect1$Aspect1$HasTest$test;
public Test();
public static void main(java.lang.String[]);
public int ajc$interFieldGet$Aspect1$Aspect1$HasTest$test();
public void ajc$interFieldSet$Aspect1$Aspect1$HasTest$test(int);
}
public abstract aspect ParentChildRelationship<Parent,Child> {
interface ParentHasChildren<C extends ChildHasParent> { ... } interface ChildHasParent<P extends ParentHasChildren> { ... }
declare parents: Parent implements ParentHasChildren<Child>;
declare parents: Child implements ChildHasParent<Parent>;
private List<C> ParentHasChildren<C>.children;
private P ChildHasParent<P>.parent;
...
> }
Any help on this would be greatly appreciated!
Cheers,
Dave
Given TestAspect<Test>, the behaviour of the declare parents statement is exactly as if you had written
declare parents : Test implements HasTest;
so "T" will not appear anywhere.
On 21/09/05, David Pearce <david.pearce@xxxxxxxxxxxxx> wrote:
Hi All,
I have another quick question about generic aspects. Consider this:
> class Test {} > > aspect TestAspect<T> { > interface HasTest {} > > declare parents : T implements HasTest; > > private int HasTest.x = 0; > }
So, the question is, for TestAspect<Test>, what does the actual name for the x field which is inserted into Test look like? I imagine something like this:
> int ajc$interField$TestAspect$Test$HasTest$x;
Does that seem about right? I guess the crucial point is that Test has been included in this name, since it is the concrete type of T.
Cheers,
Dave
-- Lecturer in Computer Science, School of Mathematics, Statistics and Computer Science, Victoria University of Wellington, PO Box 600, Wellington, New Zealand.
Office: Cotton 231 Telephone: +64 4 463 5833 URL: http://www.mcs.vuw.ac.nz/~djp _______________________________________________ aspectj-users mailing list aspectj-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/aspectj-users
-- Lecturer in Computer Science, School of Mathematics, Statistics and Computer Science, Victoria University of Wellington, PO Box 600, Wellington, New Zealand.
Office: Cotton 231 Telephone: +64 4 463 5833 URL: http://www.mcs.vuw.ac.nz/~djp