Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Capturing data at a pointcut

Hi Andrew,


On Wed, Apr 22, 2009 at 11:55 AM, Andrew Eisenberg <andrew@xxxxxxxxxxxx> wrote:
> Hi,
>
> A little confused about what you mean by #1.  What is the fully
> qualified name of a local variable?  Or are you only looking to do
> this for fields?  If so, how are you planning on distinguishing them?
>

Thanks for the response. Sorry about the ambiguity. I need a fully
qualified qualified name if it's a field and the name if it's a local
variable. I am doing some dynamic analysis to figure out which fields
of type java.util.collection in an object are shared by multiple
threads. For a successful analysis, I have to also take aliases into
account. For this I am capturing the object pointed by each of these
fields and consider all fields that point to same object as aliases.
Even though this technique is not general it works for me.

> It is not hard to get the type of the field/variable:
> thisJoinPointStaticPart.getSignature().getDeclaringType()
>
> But getting its name and the class that declares it is harder.  This
> is just not information that AspectJ stores.  One of the reasons that
> this is not stored is because aliasing can make this information
> meaningless.  For example:
>
> class C1 {
>   Set s = new HashSet();
>
>   private void doNothing() {
>      Set t = s;
>      t.add(null);
>      s.add(null);
>   }
> }
>
> Here objects t and s are the same, but have different names.  What
> would you want to do here?  Do you really want to know where the
> variable was declared or do you want to know what the variable points
> to?

I want to know the name of the variable/field and what it points
to(it's value). If there are aliasing effects(s and t), that's ok. I
can work around that. Also, since one can work around this limitation,
I think AspectJ should expose this information. This makes AspectJ a
good tool using which one can implement dynamic program analysis. Btw,
is anyone aware of any publicly available dynamic program analysis
tools built on top of AspectJ.

You said that getting the name of the local variable/field and the
class is much harder. Which thankfully means it's not impossible. How
can I get that information?

Thanks,
-S-

>
> On Wed, Apr 22, 2009 at 12:31 AM, 100ji <itz100ji@xxxxxxxxx> wrote:
>> Hi all,
>>
>> I am implementing some dynamic programming analysis using AspectJ. For
>> example, consider the program:
>>
>> Set<Object> s = new HashSet<Object>();
>> s.add(o1);
>> s.remove(o1);
>>
>> In this program at each add and remove method call, I need the
>> following information:
>>
>> 1) a string showing the type of s and a fully qualified name of the
>> field with the name of the field. "java.util.Set com.x.y.z.a.b.c.s".
>> 2) a reference to object o1.
>> 3) a reference to set s.
>> 4) The lineno and the file name at which the call is taking place.
>>
>> I can get (2), (3) and (4) using the argument, target and
>> thisJoinPoint.getStaticpart.getLineNo() respectively. How can I get
>> (1) the name of the field s and it's type from a point cut?
>>
>> Thanks,
>> -S-
>> _______________________________________________
>> 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