Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] AspectJ reflect API


> I hit the same problems with reflection and
> pointcut declarations but I'm stumped at the moment about how to access
> that information (other than potentially 'implying' it using the ASM -
> but this seems too woolly for a unit testing tool);


As a work around, you *might* consider using some of the weaver APIs that read in ".class" files and pick apart the (class file) attributes that contain pointcut information etc.. (see the class AjAttribute in the weaver module). This solution requires reading and parsing the ".class" file for a type at runtime, but that might be ok in a unit testing tool (but would be too much for the final aspectjrt solution I suspect). Again, if you could fit that implementation under the intended final APIs that would be a great starter....

Regards, Adrian.

-- Adrian
Adrian_Colyer@xxxxxxxxxx



Russell Miles <russellmiles@xxxxxxx>
Sent by: aspectj-dev-bounces@xxxxxxxxxxx

18/04/2005 21:33

Please respond to
AspectJ developer discussions <aspectj-dev@xxxxxxxxxxx>

To
AspectJ developer discussions <aspectj-dev@xxxxxxxxxxx>
cc
Subject
Re: [aspectj-dev] AspectJ reflect API





Hi Adrian,

Great stuff! Have you taken a look at how aUnit makes advice blocks
available via reflection? Might help out with the advice block bits,
but if you have comments on how I can improve what I have then that
would be great too. I hit the same problems with reflection and
pointcut declarations but I'm stumped at the moment about how to access
that information (other than potentially 'implying' it using the ASM -
but this seems too woolly for a unit testing tool); annotations seem
like a good candidate though.

If the official AspectJ reflection API gets filled in then I'll
immediately move aUnit over to using that instead of its own ad hoc
implementation - that was always the intention anyway :)

Cheers,

Russ

On 18 Apr 2005, at 20:59, Adrian Colyer wrote:

>
> I just committed into the tree the outline of a solution that I
> started work on last month (this is a *long* way from finished). Take
> a look at the aspectj5rt module in CVS where you'll find the
> org.aspectj.lang.reflect package and
> org.aspectj.internal.lang.reflect. The basic notion is to introduce a
> new interface, AjType, which is to AspectJ's reflection interfaces
> what Class is to Java's (Class is final so we couldn't extend that).
> I've filled in the shape of the AjType interface based to on the
> precedence set by java.lang.Class in Java 5.  (Note that even classes
> get AjType equivalents in this world, since classes can have
> pointcuts...). The interfaces for ITDs, advice, pointcuts etc.
> (analogous to Method, Field,...) are not filled in yet. The size of
> the AjType interface should indicate the amount of effort that needs
> to go into testing this! The intended anchor into the AspectJ type
> world is via AjTypeSystem.getAjType(Class forClass). So you'd write
> something like this:
>
> AjType aspectType = AjTypeSystem.getAjType(MyAspect.class);
> Pointcut[] pointcuts = aspectType.getDeclaredPointcuts();
> etc.
>
> Patches that start to flesh out the interfaces with the stuff you
> need, and especially patches that contribute test cases would be very
> welcome. We need to figure out how to make more of the aspect members
> runtime visible so that the API can be implemented (pointcuts for
> example are not currently - unless you use @AspectJ style and we
> decide to make the Pointcut annotation runtime visible...). A lot of
> that work will have to happen in ajdt.core and probably needs some
> committer time to get started - which realistically means M4 timeframe
> I suspect. Fitting your current implementation behind the interfaces
> and checking that they meet your needs would be a good way to get
> started in the meantime...
>
> Cheers, A.
>
> -- Adrian
>  Adrian_Colyer@xxxxxxxxxx
>
>
> Russell Miles <russellmiles@xxxxxxx>
> Sent by: aspectj-dev-bounces@xxxxxxxxxxx
>
> 14/04/2005 16:21
> Please respond to
>  AspectJ developer discussions <aspectj-dev@xxxxxxxxxxx>
>
> To
> AspectJ developer discussions <aspectj-dev@xxxxxxxxxxx>
> cc
> Subject
> Re: [aspectj-dev] AspectJ reflect API
>
>
>
>
>
> Hi Mac,
>
>  You might find that the reflection extensions that I've built into
> aUnit's framework (org.aspectj.aunit.framework.reflect.Aspect and
> org.aspectj.aunit.framework.reflect.Advice) might give you some of
> what you need. What it doesn't already have I'd be happy to work on
> with you as pointcut information would be really useful to aUnit - the
> problem with providing runtime reflective information on pointcuts is
> that (as far as I can find) that information is not retained after
> compile and weave.
>
>  aUnit's source is available from www.aunit.org, follow the
> SourceForge project link at the top of the page (I'm in the process
> now of adding direct links from the homepage)
>
>  Cheers,
>
>  Russ
>
>  On Thursday, April 14, 2005, at 03:18PM, Mac <mac@xxxxxxxx> wrote:
>
>  >Hi,
>  >
>  >I'am currently working on aspectJ5 Unit Testing framework. I need an
> AspectJ
>  >reflect API or something like :
>  >                 org.aspectj.lang.reflect.Aspect with getAdvice()
> and getPointcut()  methods
>  >and all the inherited Class features.
>  >
>  >Are you planning to provide it ? I f not, any opinions are welcome.
>  >
>  >Thanks
>  >
>  >MAC
>  >_______________________________________________
>  >aspectj-dev mailing list
>  >aspectj-dev@xxxxxxxxxxx
>  >https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>  >
>  >
>  _______________________________________________
>  aspectj-dev mailing list
>  aspectj-dev@xxxxxxxxxxx
>  https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-dev


Back to the top