Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Array access

Thanks Matthew.

Actually, the index is not my priority. Currently, both array get and array
set bytecodes (accessing only one cell) are captured by the get pointcut in
the last advice in your example. However, for my application it is crucial
to find out what kind of access (read or write of an array cell) happened.
Is there a way to do so?




                                                                           
             Matthew Webster                                               
             <matthew_webster@                                             
             uk.ibm.com>                                                To 
             Sent by:                  wes@xxxxxxxxxxxxxx, AspectJ         
             aspectj-dev-bounc         developer discussions               
             es@xxxxxxxxxxx            <aspectj-dev@xxxxxxxxxxx>           
                                                                        cc 
                                                                           
             09/13/2006 06:14                                      Subject 
             AM                        Re: [aspectj-dev] Array access      
                                                                           
                                                                           
             Please respond to                                             
             AspectJ developer                                             
                discussions                                                
             <aspectj-dev@ecli                                             
                 pse.org>                                                  
                                                                           
                                                                           





Christian,

You can advise array constructions (
https://bugs.eclipse.org/bugs/show_bug.cgi?id=77166) and access.
Unfortunately you cannot (yet) determine the index used when access and
array or the identity of the element. In the example below the object
traced is the array itself:

public class Test {

        private static int[] ints;

        public static void main(String[] args) {
                ints = new int[1];
                ints[0] = 999;
                System.out.println("Test.main() ints[0]=" + ints);
        }

}

public aspect Aspect {

        after() returning(Object ret): call(int[].new(..)) {
                System.out.println("Aspect.afterReturning() " +
thisJoinPoint + ", ret=" + ret);
        }

        before (Object arg) : set(int[] *) && args(arg){
                System.out.println("Aspect.before() " + thisJoinPoint + ",
arg=" + arg);
        }

        after () returning(Object ret) : get(int[] *) {
                System.out.println("Aspect.after() " + thisJoinPoint + ",
ret=" + ret);
        }
}





Back to the top