[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] capturing methods without a call to another method
|
Hello all,
I am trying to implement a policy of cloning an array before retuning a refence
to it in a method across an API, here is my test code with an aspect:
public aspect HelloWorldAspect {
pointcut hello(): !within(HelloWorldAspect);
pointcut method(): execution(*[] *(..));
pointcut cloning(): call(* java.lang.Object.clone());
before(): cflow(method()) && cloning() && hello() {
print("Before : ", thisEnclosingJoinPointStaticPart);
}
after(): cflow(method())&& cloning() && hello() {
print("After : ", thisEnclosingJoinPointStaticPart);
}
}
public class World {
private Integer[] intArray = new Integer[2];
public Integer[] returnArrayWithCloning() {
for (int i = 0; i < intArray.length; i++) {
intArray[i] = new Integer(i++);
}
return (Integer[])intArray.clone();
}
public Integer[] returnArrayWithoutCloning() {
return intArray;
}
}
With the above pointcuts and advices i get all the calls to the method
World.returnArrayWithCloning(), that is quiet clear, but i would like to get a
list of all the methods that return an array without calling its clone() method.
Please suggest me how to get this result.
Regards,
Rohith.