Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ajdt-dev] ASM hierarchy model

Hi Alex,

I've just been looking into this with Andy. The -> advice icon is
indeed the default, used when we can't determine the type of advice.

Unfortunately we currently cannot determine whether the method
representing advice is before, after, or around advice. To determine
this requires a source level parse, which we only do for .aj files,
not .java files. Ideally we should instead be able to directly query
the annotations for the IJavaElement representing the method, and get
the advice type from that, but JDT doesn't let us do this - see bug
79112.

The good news is that I can at least make the arrows go the right way
round, by detecting whether it is the source or target of advice, so
you now get the <- arrow coming from the advice, and the -> arrow at
the target end. It's the same deal for binary aspects, so it's not too
bad a limitation. I've just committed that change to AJDT.

Regards,

Matt.

On 13/07/05, Alexandre Vasseur <avasseur@xxxxxxxxx> wrote:
> Andy, this is all fine on the AspectJ side (since it all comes from
> the ASM model which is now fine, and from the munger which is fine as
> well)
> The issue that arises is that the AspectJImages code in AJDT is not
> encountered since the program  element is (for say an @AJ around
> advice) a "SourceMethod" instance, and not an "IAspectJElement"
> (breakpoint in ImageDecorator.decorateImage(..) f.e.)
> 
> This is thus related to the way AJDT transforms the ASM model to its
> own thing (somewhere in AspectJCore perhaps).
> The little icon that still appears on advice thus comes from a
> possibly "happy" side effect...
> 
> Alex
> 
> 
> 
> On 7/11/05, Andrew Clement <CLEMAS@xxxxxxxxxx> wrote:
> >
> >
> >
> >
> > ExtraInformation includes the kind of advice, see (in AJ):
> > AsmRelationshipProvider.adviceMunger() line 203
> >
> > related to that is whether the advised location is advised based on whether
> > some runtime test needs to be run (this decides whether you get the little
> > '?' by the advice arrow).  The runtime test value is specified on the
> > relationship, see same method, line 192...
> >
> > see this related code in AJDT:
> >
> > AspectJImages.getAdviceIcon:
> >
> >
> > if(extraInfo.getExtraAdviceInformation().equals("before")) {
> >                               if(hasDynamicTests) {
> >                                     return
> > AspectJImages.DYNAMIC_BEFORE_ADVICE;
> >                               } else {
> >                                     return AspectJImages.BEFORE_ADVICE;
> >                               }
> >                         } else if
> > (extraInfo.getExtraAdviceInformation().equals("around")) {
> >                               if(hasDynamicTests) {
> >                                     return
> > AspectJImages.DYNAMIC_AROUND_ADVICE;
> >                               } else {
> >                                     return AspectJImages.AROUND_ADVICE;
> >                               }
> >                         } else {
> >                               if(hasDynamicTests) {
> >                                     return
> > AspectJImages.DYNAMIC_AFTER_ADVICE;
> >                               } else {
> >                                     return AspectJImages.AFTER_ADVICE;
> >                               }
> >                         }
> >
> >
> >
> >
> > Andy.
> >
> >
> >
> >
> >
> >              Alexandre Vasseur
> >              <avasseur@gmail.c
> >              om>                                                        To
> >              Sent by:                  AspectJ Development Tools developer
> >              ajdt-dev-bounces@         discussions <ajdt-dev@xxxxxxxxxxx>
> >              eclipse.org                                                cc
> >
> >                                                                    Subject
> >              11/07/2005 15:35          Re: [ajdt-dev] ASM hierarchy model
> >
> >
> >              Please respond to
> >              Alexandre Vasseur
> >              <avasseur@gmail.c
> >                 om>; Please
> >                 respond to
> >                   AspectJ
> >                 Development
> >               Tools developer
> >                 discussions
> >              <ajdt-dev@eclipse
> >                    .org>
> >
> >
> >
> >
> >
> >
> > As experts may have seen, the around advice gets the straight icon
> > instead of the half circle one, or the one in the other direction.
> > I suspect the advice kind to be sort of unresolved, hence this default
> > icon. Mik, do you know where the advice kind (before / around etc) is
> > stored and resolved between the ASM model and AJDT. Is it done by name
> > so far, or is there some magic in the
> > IRpogramELement.ExtraInformation, or is that done in AJDT thru some
> > other way (Matt ?)
> > (see f.e. in AsmElementFormatter.genLabelAndKind)
> >
> > Thanks
> > Alex
> >
> > On 7/5/05, Mik Kersten <beatmik@xxxxxxx> wrote:
> > > Excellent!  That screenshot tells a really nice story about AJDT showing
> > > crosscutting consistently no matter what syntax you choose to declare it
> > in
> > > :)
> > >
> > > Mik
> > >
> > > > -----Original Message-----
> > > > From: ajdt-dev-bounces@xxxxxxxxxxx
> > [mailto:ajdt-dev-bounces@xxxxxxxxxxx]
> > > > On Behalf Of Alexandre Vasseur
> > > > Sent: Tuesday, July 05, 2005 4:52 AM
> > > > To: AspectJ Development Tools developer discussions
> > > > Subject: Re: [ajdt-dev] ASM hierarchy model
> > > >
> > > > Thanks so much Andy and Mik !
> > > >
> > > > I have added the offset info to MethodDeclarationAttribute. The point
> > > > is that I was grabbing this one from the line break information, hence
> > > > loosing the exact offset when reading the @Aj annotation in the
> > > > weaver, while ajdt core was having the correct one when dealing with
> > > > the ASM model.
> > > >
> > > > Here we go :
> > > >
> > http://blogs.codehaus.org/people/avasseur/archives/001128_aspectj_in_ajdt_
> > > > a_world_premiere_.html
> > > >
> > > > Matt, can you tell me when the AspectJ ajde.jar from AspectJ build
> > > > snapshots will be in the AJDT build snapshots (for Eclipse 3.1) ?
> > > >
> > > > Alex
> > > >
> > > >
> > > >
> > > > On 7/4/05, Mik Kersten <beatmik@xxxxxxx> wrote:
> > > > > Seems like right now the simplest and most clear thing to do is to
> > get
> > > > the
> > > > > offsets right for @AJ.  Changing the equivalence matching makes
> > sense,
> > > > but
> > > > > could get confusing to debug down the road, especially since we may
> > want
> > > > to
> > > > > treat those declarations separately at one point (e.g. use
> > Collections
> > > > can
> > > > > get confusing with a lenient equals method).
> > > > >
> > > > > Mik
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: ajdt-dev-bounces@xxxxxxxxxxx [mailto:ajdt-dev-
> > > > bounces@xxxxxxxxxxx]
> > > > > > On Behalf Of Andrew Clement
> > > > > > Sent: Monday, July 04, 2005 7:02 AM
> > > > > > To: AspectJ Development Tools developer discussions
> > > > > > Subject: Re: [ajdt-dev] ASM hierarchy model
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > >From a very quick look at the debug files - the gutter stuff is
> > still
> > > > > > missing because the offsets don't match.
> > > > > >
> > > > > >
> > > > > > In the working case I can see this handle for a piece of advice:
> > > > > >
> > > > > > before(): <anonymous pointcut>  [advice]
> > > > > > SingletonAspectBindingsTest2.aj:112::3677
> > > > > >
> > > > > > and then this relationship:
> > > > > >
> > > > > > Hid:2:(targets=1) SingletonAspectBindingsTest2.aj|112|0|3677
> > (advises)
> > > > > > SingletonAspectBindingsTest2.aj|45|0|1511
> > > > > >
> > > > > > ===
> > > > > >
> > > > > > In the failing case, I see this handle:
> > > > > >
> > > > > > before(JoinPoint.StaticPart): <anonymous pointcut>  [advice]
> > > > > > SingletonAspectBindingsTest.java:113::3742
> > > > > >
> > > > > > and then this relationship:
> > > > > >
> > > > > > Hid:1:(targets=1) SingletonAspectBindingsTest.java|113|0|3777
> > > > (advises)
> > > > > > SingletonAspectBindingsTest.java|45|0|1509
> > > > > >
> > > > > > with different offsets there is no match.  i.e. if I use the handle
> > > > for
> > > > > > the
> > > > > > advice (offset 3742) as an index into the relationships, it will
> > > > return
> > > > > > zero matching entries.
> > > > > >
> > > > > > Whether the fix is to get the offsets right for @AJ or make handle
> > > > > > equivalence testing more lenient, I'm not sure.
> > > > > >
> > > > > > Andy.
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >              Alexandre Vasseur
> > > > > >              <avasseur@gmail.c
> > > > > >              om>
> > > > To
> > > > > >              Sent by:                  AspectJ Development Tools
> > > > developer
> > > > > >              ajdt-dev-bounces@         discussions <ajdt-
> > > > dev@xxxxxxxxxxx>
> > > > > >              eclipse.org
> > > > cc
> > > > > >
> > > > > >
> > > > Subject
> > > > > >              04/07/2005 14:35          Re: [ajdt-dev] ASM hierarchy
> > > > model
> > > > > >
> > > > > >
> > > > > >              Please respond to
> > > > > >              Alexandre Vasseur
> > > > > >              <avasseur@gmail.c
> > > > > >                 om>; Please
> > > > > >                 respond to
> > > > > >                   AspectJ
> > > > > >                 Development
> > > > > >               Tools developer
> > > > > >                 discussions
> > > > > >              <ajdt-dev@eclipse
> > > > > >                    .org>
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Mik, I am not sure to follow.
> > > > > >
> > > > > > I have just commited in AspectJ a bunch of fix that makes the
> > > > > > AsmManager...setReporting happy when it encounters @AJ aspect. I
> > had
> > > > > > no more luck with AJDT though (ie showWeaveInfo is fine but no
> > gutter
> > > > > > or cross reference view appears)
> > > > > >
> > > > > > If you want to dig further what needs to perhaps be done in
> > AspectJ,
> > > > > > you may check the "AtAjSyntaxTests.testSingletonAspectBindings()"
> > that
> > > > > > runs some simple aspect written in both style (ie 2 run) and dump
> > the
> > > > > > Asm model if you uncomment some lines.
> > > > > > I am also attaching the dump file if in any case you can spot
> > > > something
> > > > > > obvious.
> > > > > > debug-aj.txt is the one for code style, debug.txt is the one for
> > > > > > annotation style.
> > > > > >
> > > > > > Alex
> > > > > >
> > > > > >
> > > > > >
> > > > > > On 6/29/05, Mik Kersten <beatmik@xxxxxxx> wrote:
> > > > > > > Good question.  It definitely feels wrong for them to have the
> > plain
> > > > > > Java
> > > > > > > kind, because the programmer and tools should treat them as
> > advice.
> > > > But
> > > > > > > there will be cases where the fact that they're annotated as
> > advice
> > > > > > needs
> > > > > > to
> > > > > > > be differentiated.  Also, it is feasible that down the road we
> > could
> > > > > > want
> > > > > > > the annotation to be a separate program element.  I'm curious to
> > see
> > > > how
> > > > > > the
> > > > > > > JDT's IJavaModel ends up handling annotations and am not aware of
> > > > any
> > > > > > > mechanism for going from a declaration to an annotation.  Matt,
> > do
> > > > you
> > > > > > know?
> > > > > > >
> > > > > > > For now I suggest adding an isAnnotated() method to
> > IProgramElement
> > > > to
> > > > > > > indicate whether or not this advice/pointcut/etc. is specified as
> > an
> > > > > > > annotation or as code.  Then simply setting the kind to be the
> > AOP
> > > > kind
> > > > > > not
> > > > > > > the OOP kind.  Not that you may be tempted to put this method and
> > > > field
> > > > > > on
> > > > > > > the IProgramElement.Kind calss, which would be fine, but that
> > > > typesafe
> > > > > > enum
> > > > > > > pattern should be switched to a Java 5 enum at some point.  If
> > you
> > > > > > agree,
> > > > > > > and would like me to make the change just let me know.
> > > > > > >
> > > > > > > Mik
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: ajdt-dev-bounces@xxxxxxxxxxx
> > > > > > [mailto:ajdt-dev-bounces@xxxxxxxxxxx]
> > > > > > > > On Behalf Of Alexandre Vasseur
> > > > > > > > Sent: Thursday, June 23, 2005 7:59 AM
> > > > > > > > To: AspectJ Development Tools developer discussions
> > > > > > > > Subject: [ajdt-dev] ASM hierarchy model
> > > > > > > >
> > > > > > > > A question for Mik I guess.
> > > > > > > >
> > > > > > > > For IDE support to work correctly, should the Hierarchy and
> > > > > > > > Relationship model output by the weaver have correct "kind" for
> > > > > > > > @AspectJ style member ie be flagged as
> > > > IProgramElement.Kind.Advice,
> > > > > > > > Aspect, Pointcut etc. ?
> > > > > > > >
> > > > > > > > f.e. with
> > > > > > > >
> > > > > > > >       SingletonAspectBindingsTest  [class]
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java:30::1063
> > > > > > > >         TestAspect  [aspect]
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java:74::2495
> > > > > > > >           s  [field]
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java:76::2530
> > > > > > > >           ...  [initializer]
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java:78::2555
> > > > > > > >           TestAspect()  [constructor]
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java:82::2604
> > > > > > > >           aaround(ProceedingJoinPoint)  [method]
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java:90::2901
> > > > > > > >           around2(ProceedingJoinPoint, Object)  [method]
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java:101::3273
> > > > > > > >           before(JoinPoint.StaticPart)  [advice]
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java:113::3742
> > > > > > > > ....
> > > > > > > > === RELATIONSHIPS REPORT ========= After a batch build
> > > > > > > > Hid:1:(targets=1)
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java|49|0|1568
> > > > > > > > (advised by)
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java|128|0|4563
> > > > > > > > Hid:2:(targets=1)
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java|90|0|2935
> > > > > > > > (advises)
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java|45|0|1509
> > > > > > > > Hid:3:(targets=1)
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java|101|0|3317
> > > > > > > > (advises)
> > > > > > > >
> > > > > >
> > > >
> > C:\Temp\ajcSandbox\ajcTest36518.tmp\ataspectj\SingletonAspectBindingsTest.
> > > > > > > > java|45|0|1509
> > > > > > > > ...
> > > > > > > > === Properties of the model and relationships map =====
> > > > > > > > method=13
> > > > > > > > import reference=19
> > > > > > > > aspect=1
> > > > > > > > constructor=1
> > > > > > > > class=2
> > > > > > > > advice=2
> > > > > > > > ...
> > > > > > > > we can see that TestAspect.java is flagged to be an aspect.
> > > > > > > > Same for the method before, flagged to be an advice.
> > > > > > > > But since I am in the middle of doing some changes, you can see
> > > > that
> > > > > > > > aaround(..) are flagged as methods.
> > > > > > > >
> > > > > > > > Is AJDT supposed to work only from the advised-by / advises
> > info
> > > > or
> > > > > > > > does this things matters ? (this because it means changing some
> > in
> > > > the
> > > > > > > > ajdt.core to check if there are the @Aspect, @Before and so on
> > > > > > > > annotations).
> > > > > > > > (BTW with that, AJDT does not show up the markers and the cross
> > > > > > > > cutting structure better, despite the advised by is correct in
> > the
> > > > > > > > problem view (when turned on).
> > > > > > > >
> > > > > > > > Alex
> > > > > > > > _______________________________________________
> > > > > > > > ajdt-dev mailing list
> > > > > > > > ajdt-dev@xxxxxxxxxxx
> > > > > > > > https://dev.eclipse.org/mailman/listinfo/ajdt-dev
> > > > > > >
> > > > > > > _______________________________________________
> > > > > > > ajdt-dev mailing list
> > > > > > > ajdt-dev@xxxxxxxxxxx
> > > > > > > https://dev.eclipse.org/mailman/listinfo/ajdt-dev
> > > > > > >
> > > > > > (See attached file: debug.txt)(See attached file: debug-aj.txt)
> > > > > > _______________________________________________
> > > > > > ajdt-dev mailing list
> > > > > > ajdt-dev@xxxxxxxxxxx
> > > > > > https://dev.eclipse.org/mailman/listinfo/ajdt-dev
> > > > >
> > > > > _______________________________________________
> > > > > ajdt-dev mailing list
> > > > > ajdt-dev@xxxxxxxxxxx
> > > > > https://dev.eclipse.org/mailman/listinfo/ajdt-dev
> > > > >
> > > > _______________________________________________
> > > > ajdt-dev mailing list
> > > > ajdt-dev@xxxxxxxxxxx
> > > > https://dev.eclipse.org/mailman/listinfo/ajdt-dev
> > >
> > > _______________________________________________
> > > ajdt-dev mailing list
> > > ajdt-dev@xxxxxxxxxxx
> > > https://dev.eclipse.org/mailman/listinfo/ajdt-dev
> > >
> > _______________________________________________
> > ajdt-dev mailing list
> > ajdt-dev@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/ajdt-dev
> >
> >
> > _______________________________________________
> > ajdt-dev mailing list
> > ajdt-dev@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/ajdt-dev
> >
> _______________________________________________
> ajdt-dev mailing list
> ajdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/ajdt-dev
>


Back to the top