Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] declare parents with super/sub classes


Jennifer,

So your requirement is that a large set of classess, that are related to each other in an inheritance hierarchy, must _define_ one or more methods. You have tried to ITD these methods onto an empty interface and use declare parents to add the interface to the set of classes but only the first super-type gets the method. However, you get the desired results if you use multiple aspects.

I suspect the "problem" lies with declare parents: once the supertype has the interface all the sub-types automatically get it along with the ITD. You are trying to use AspectJ as a code generator which it isn't really; it just happens to generate code to achieve its goals. Unfortunately many existing coding patterns require programmers to implement methods with particular signatures (customizing serialization is one example) and they are often not well suited to AspectJ.

BTW _if_ your attempts had succeeded all the target classes would have ended up exactly the same method implementation. Is this what you wanted?

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx

http://w3.hursley.ibm.com/~websterm/

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:        aspectj-users-bounces@xxxxxxxxxxx

To:        aspectj-users@xxxxxxxxxxx
cc:        
Subject:        Re: [aspectj-users] declare parents with super/sub classes


No, I'm not using Java 5. I'm actually using what Java 1.3 since the
version of the system I'm using is 2 years old.

I previously had two aspects that I wove in a row, the first with the
supertype, the last with the subtype, which worked. But of course it's
not overly elegant to have however many of these compiled in a row (it
didn't work to include them in the same invocation of ajc) where the
aspect implements the same functionality so I was hoping there was a
better way but considering the use of the interface, I think that
there probably isn't :-)

Jennifer


On 4/11/06, Ron Bodkin <rbodkin@xxxxxxxxxxxxxx> wrote:
> Are you using Java 5 by any chance? If you are and you are using an aspect
> to match the types that implement the interface, you might be able to use
> declare annotation to do what you want instead. However, it sounds like the
> JVM you are using is using interfaces like an annotation, where it doesn't
> "inherit" the effect of implementing one but requires the type to explicitly
> implement to get the desired effect.
>
> -----Original Message-----
> From: aspectj-users-bounces@xxxxxxxxxxx
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Jennifer Baldwin
> Sent: Tuesday, April 11, 2006 1:51 PM
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] declare parents with super/sub classes
>
> P.S. And I know you're thinking, why on earth does she want to do the
> subclasses AND the superclasses? I'm wondering the same but the
> distributed JVM doesn't run if I don't. I've emailed the original
> developers to ask them what exactly is going on that it needs to be
> this way but I won't get an answer for about another 8 hours with the
> time zone difference :-)
>
> Jen
>
>
> On 4/11/06, Ron Bodkin <rbodkin@xxxxxxxxxxxxxx> wrote:
> > Hi Jennifer,
> >
> > What happens if you use this idiom to make subclasses of SomeType
> implement
> > marker? I've used this before in cases where I didn't control SomeType but
> > wanted all subtypes to implement a marker...
> >
> > declare parents: (SomeType+ && !SomeType) implements Marker;
> >
> > -----Original Message-----
> > From: aspectj-users-bounces@xxxxxxxxxxx
> > [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Jennifer Baldwin
> > Sent: Tuesday, April 11, 2006 1:02 PM
> > To: aspectj-users@xxxxxxxxxxx
> > Subject: [aspectj-users] declare parents with super/sub classes
> >
> > Hi,
> >
> > I want to use declare parents to implement an empty interface for both
> > a subclass AND a super class. AJC will only do it for the superclass
> > in everything I've tried. I know that this makes sense since the
> > subclass will inherit the implementation. But for the example I'm
> > working on, which is implementing of distribution on a JVM, I need it
> > to be able to do this. Does anybody have any ideas on how to force it
> > to work?
> >
> > Thanks,
> > Jennifer
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top