Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Pointcut on an array field-setter

Hello,

 

I’am trying to make an aspect that works on every field set operation on an integer array. This is the test case I used.

 

 

 

public aspect SetAndGetAspect {

            pointcut setPC() : set(int[] *.*);

            pointcut getPC() : get(int[] *.*);

           

            before(): setPC(){

                       

                        System.out.println("Reached set pointcut " + thisJoinPoint);

            }

           

            before() : getPC(){

                        System.out.println("Reached get pointcut " + thisJoinPoint);

            }

 

}

 

 

This is the test program

 

ublic class testje {

           

            int[] a = new int[5];

            int b;

 

            public static void main(String[] args) {

                        testje inst = new testje();

                       

                        inst.a[1] = 1;

                        inst.a[2] = 2;

                        inst.a[3] = 3;

                        inst.a[4] = 4;

                       

                        inst.b = inst.a[1];

                        inst.b = inst.a[2];

                        inst.b = inst.a[3];

                        inst.b = inst.a[4];

            }

}

This is the output:

 

Reached set pointcut set(int[] testje.a)

Reached get pointcut get(int[] testje.a)

Reached get pointcut get(int[] testje.a)

Reached get pointcut get(int[] testje.a)

Reached get pointcut get(int[] testje.a)

Reached get pointcut get(int[] testje.a)

Reached get pointcut get(int[] testje.a)

Reached get pointcut get(int[] testje.a)

Reached get pointcut get(int[] testje.a)

 

 

Why doesn’t the pointcut setPC trigger on all the array assignments?

 

Thanks in advance,

 

Bert Hajee

 

hajee@xxxxxxxxxxx

 


Back to the top