Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] method call and annotated field


There are no immediate plans to include such a feature in the AspectJ 1.5.0 release. However, you should feel free to raise an enhancement request (in bugzilla) with a written up proposal for how you would like this to work and some compelling use cases that justify the addition of a new join point kind to the language. We do listen to user requests and if there is enough interest from the community in the feature then it would be considered for a post 1.5.0 release...

Regards, Adrian.

-- Adrian
Adrian_Colyer@xxxxxxxxxx



Rifflard Mickaël <Mickael.Rifflard@xxxxxxxxxxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx

11/04/2005 07:33

Please respond to
aspectj-users@xxxxxxxxxxx

To
<aspectj-users@xxxxxxxxxxx>
cc
Subject
RE: [aspectj-users] method call and annotated field





Hi Eric,

I had actually put a similar question a few times ago.
The last time, I had finally used another design pattern to remove the limitation.
The problem is that I am again in front of this case, for another need.

I will use your solution to solve my problem immediately but, somebody (Adrian for example)
could say if this kind of join point could be integrated into AspectJ 5 in one of the next versions ?

Thank you very much, and sorry to have put the question again but I think that this functionality is likely
to be very useful, in particular in framework development based on annotations and AspectJ 5.

Regards,

                Mickaël

-----Message d'origine-----
De : aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx]De la part de Eric Bodden
Envoyé : samedi 9 avril 2005 00:00
À : aspectj-users@xxxxxxxxxxx
Objet : RE: [aspectj-users] method call and annotated field



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rifflard Mickaël wrote:
> How to express this : Match a method call when this one is perform
> on an annotated field ?

Hi, Rifflard. Correct me if I am wrong, but did we not discuss the
same question about 6 weeks ago, when you posted the very same code
snippet?

- ----------------------------------------------------------------------
- ----------
From: aspectj-users-admin@xxxxxxxxxxx
[mailto:aspectj-users-admin@xxxxxxxxxxx] On Behalf Of Adrian Colyer
Sent: Donnerstag, 24. Februar 2005 16:53
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Match a method call on a class field
with specific annotation



This is an interesting use case because.... there's no easy way to do
this.

At a call join point, we know about the the *caller*, and the
*callee*, we know the static context in which the call is being made
(within, withincode), and the dynamic context in which the call is
being made (cflow[below]), so whilst we can say:

"any call where the type of the target of the call has an annotation
@ABC..."

we don't have a way to say:

"any call where the target of the call is currently refered to by a
member variable, and that member variable has an annotation of type
@ABC..."

The closest thing you can say is

"any access to a field with annotation @MyAnnotation"  :
get(@MyAnnotation * *)

Using reflection it should be possible, but awkward to get closer
what you want:

pointcut annotatedFieldCall() : call(* *(..)) &&
if(calleeIsAFieldWithMyAnnotation(thisJoinPoint);

private static boolean calleeIsAFieldWithMyAnnotation(JoinPoint tjp)
{

 / / pseudo-code...

  Object obj = tjp.getThis();
  for-all (Field field : obj.getClass().getDeclaredFields()) {
     if (field.hasAnnotation(MyAnnotation.class) return true;
  }


  return false;
}


but it's not pretty.... (and only works for fields defined within the
calling class).

If you *could* write a pointcut to match this, how would you want it
to look?


Eric

- --
Eric Bodden
Chair I2 for Programming Languages and Program Analysis
RWTH Aachen University

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3

iQA/AwUBQlb++cwiFCm7RlWCEQK0FQCeLwPKARAzcpP3jWXjPQPfadEhrMoAoMB5
NFrcc8SAGAiyQxT2Bpl5V2/G
=aJGe
-----END PGP SIGNATURE-----



_______________________________________________
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