Skip to main content

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

A type cannot implement two different parameterizations of a generic
type.  So you cannot have you Student implement:

 ParentChildRelationship$ParentHasChildren<Course>

and

 ParentChildRelationship$ParentHasChildren<Faculty>

so ... its working as designed - and I'm quite pleased with the error
message you are getting :)   (it might be less than ideal ... but it
is working as designed...)

You might want to move to a more recent build than M5 as many generics
fixes have gone in since M5.  Also the version of the developers
notebook on the website is a little out of date - you should refer to
the version packaged in each aspectj distribution.

Andy.

On 30/11/05, David J. Pearce <david.pearce@xxxxxxxxxxxxx> wrote:
> 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
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
>


Back to the top