Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] More Generic Aspects

Hi all,

I have a question regarding the status of Generic Aspects in AspectJ
1.5M5 and an interesting compiler message I have encountered. A cut
down version of the "ParentChildRelationship" from the AspectJ 5
Developers Notebook is as the following:

> 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;
> }

Now, I extend this with the following two aspects:

> public aspect Attends
> extends ParentChildRelationship<Student,Course> {}

> public aspect Teaches
> extends ParentChildRelationship<Student,Faculty> {}

The details of the Student, Course and Faculty classes are not important
here --- they are just simple classes.

Now, compiling this lot gives the following:

> ajc  -1.5 Attends.aj ParentChildRelationship.aj Teaches.aj
> Course.java Faculty.java Student.java C:\Documents and
> Settings\djp\My
> Documents\projects\RelationsForJava\test\pcr_test\ParentChildRelationship.aj:7
> [error] Cannot declare parent
> ParentChildRelationship$ParentHasChildren<Course> onto type Student
> since it already has
> ParentChildRelationship$ParentHasChildren<Faculty> in its hierarchy declare parents: Parent implements ParentHasChildren<Child>; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ see also:
> C:\Documents and Settings\djp\My
> Documents\projects\RelationsForJava\test\pcr_test\Student.java:1::0
>
> 1 error make: *** [all] Error 1

If Teaches.aj is left out, then everything compiles OK. It seems we cannot instantiate both the Teaches and Attends aspects at
the same time, since they are both trying to add the interface
ParentHasChildren.

So, my question: is this the expected behaviour of ajc or a bug?
I have looked through all the bug lists and haven't found anything on
this.  I have attached the complete example as a tarball.


Any help with this would be appreciated!

Cheers,

David Pearce


--
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

Attachment: pcr_test.tgz
Description: application/compressed


Back to the top