Ramnivas Laddad wrote:
>
> It is not currently possible with AspectJ.
>
> One problem with such potential pointcut is difficulty in supporting
> correct
> semantics. For example, consider what should happen in the following
> cases:
>
> 1. item.values.add("foo"); // should this be advised?
> 2. Collection<String> values = item.values;
> ...
> values.add("foo"); // should this be advised?
> 3. Collection<String> values = item.values;
> operationThatAddsString(values);
>
> ...
> public void operationThatAddsString(Collection<String> values) {
> values.add("foo"); // should this be advised?
> }
>
> The problem with 2 and 3 is that it is nearly impossible for the compiler
> to
> figure out that the target object is been a @Weak field in some object.
> Then
> supporting just one doesn't seem right as it won't survive even simple
> refactoring as done in 2. Things become more complex if an object is set
> as
> a field of two different objects with different annotations or no
> annotation
> in one case.
>
> -Ramnivas
>
> On Sat, Aug 2, 2008 at 10:17 PM, zeroorone <
zeroorone@xxxxxxxxx> wrote:
>
>>
>> I've searched around and looked through the documentation but can't seem
>> to
>> find a way to create a pointcut for the following situation.
>>
>> Is there a way to match any calls when the target of a function call is a
>> field/member annotated with a particular annotation? I know this is very
>> simple if the type of the field is annotated, as I would just add an
>> @target
>> pointcut. I have tried to play around with the cflow poincuts, but the
>> function call I'd like to advise is not within the cflow of the field
>> access, but after.
>>
>> Here is the situation expressed in code:
>>
>> public class TestItem {
>> @Weak public Collection<String> values;
>> ...
>> }
>>
>>
>> TestItem item = new TestItem(...)
>> item.values.add("foo"); // want to advise this function call add
>>
>>
>> // my poor attempts thus far
>> 1. after() : call(* *.*(..)) && @annotation(Weak)
>> 2. after() : call(* *.*(..)) && @target(Weak) // the type isn't
>> annotated, the field is
>> 3. after() : cflowbelow(get(@Weak Object+ *.*)) && call(* *.*(..)) //
>> the function call is not in the control flow of the field access
>>
>>
>> Is this behavior supported by aspectj in any way? Have I overlooked a
>> solution? It seems like another pointcut may be added, like @field(X),
>> which
>> matches join points where the target is a field/member annotated with X.
>>
>> Thanks in advance,
>> Mike
>> --
>> View this message in context:
>>
http://www.nabble.com/Pointcut-based-on-field-annotation-tp18795275p18795275.html
>> Sent from the AspectJ - users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> 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
>
>