views:

35

answers:

1

Hi!

Are there defined join points in arithmetics that I can catch?

Something like:

int a = 4;
int b = 2;
int c = a + b;

Can I make a pointcut that catches any one of those lines? And what context will I be able to get?

I would like to add a before() to all int/float/double manipulation done in a particular method on a class, is that possible.

I see in the AspectJ docs that there are defined join points for object initialization and method calls. Is declaring an int an object initialization and does the + operator count as a method call?

Thanks!

A: 

No, + does not correspond to a method call of any kind in Java.

You could for instance create your own wrapper-class that encapsulates an integer, or use BigInteger and do a pointcut on the add method.

aioobe
I started making wrappers, when I remembered AspectJ and though that it might be easier. I'm trying to make a program for visualizing small algorithms, so I would like to be able to apply the program to any code without having to modify it.Maybe Java isn't the right language to use, any suggestions? I would like to avoid having to create a new language/compiler.
Jon List