AspectJ, while being a useful language for general-purpose AOP, has so far used structure-shy programming capabilities only in a limited way. AspectJ currently supports one structure-shy construct, called cflow. But more such structure-shy flow constructs need to be added to make AspectJ aspects more robust to the structure of the base program. While the current AspectJ has a flow construct for dynamic call graphs, this work will add a flow construct for class graphs and for object graphs. AspectJ has one of its roots in the Demeter project which has developed several structure-shy programming techniques. Therefore it is useful to fold the structure-shy capabilities of Demeter back into AspectJ. This folding back serves two purposes: 1. To make AspectJ programs more robust. 2. To test the expressiveness of the AOP capabilities of AspectJ. 3. To link two worlds in the same tool: The AspectJ world which focusses on general-purpose AOP and the Demeter world which focusses on expressing traversal-related aspects in a robust way. Traversal-related aspects typically express a collaboration of connected objects and are common in all kinds of applications, including embedded applications. AspectJ and Demeter (and Composition Filters) have been integrated also in {rachid:all3}. AspectJ has passed test 2: It is very easy to fold Demeter back into AspectJ. Three ingredients are necessary: I1. A new declare construct: declare traversal t = "traversal strategy"; This basically introduces a traversal method t() to the source of the traversal strategy. This is a flow construct for object graphs. I2. Two new pointcut designators: traversal(t), where t is a traversal name and a pointcut designator: crossing(e) where e is the name of a field. I3. A new type pattern: types(t) where t is the name of the traversal. This is a flow construct for class graphs. The observation that 3 small additions to AspectJ are sufficient to add much of Demeter to AspectJ implies: 1. The join point models of AspectJ and Demeter are very close. We not that the join point model of Demeter is a special case of the join point model of AspectJ. 2. AspectJ is pretty well designed allowing the expression of the pointcuts and advice needed for Demeter. However, there is a noticeable growth in length. We are currently in the process of adding I1 to AspectJ. I2 is needed to free the programmers from having to deal with mangled method names. This will be a next step. I3 is needed to make it easier to specify sets of types robustly. The approach we take for I1 is as follows: 1. Extract the class graph cg by adding an option to ajc: ajc -classgraph 2. Eliminate the traversal declarations adding an option to ajc: ajc -elimtraversals 3. Write a DemeterJ program that translates the eliminated traversals to AspectJ introductions of the traversal methods. This is the step where the interesting work happens and the AP library will be used. 4. Compile with ajc *.java Implementing I1 already gives significant expressiveness to AspectJ: All visitors can be implemented can be implemented using AspectJ. The complete executable AspectJ example is at: http://www.ccs.neu.edu/home/lieber/com3362/w02/AspectJ/extending-AspectJ/ Here is one file giving a simple visitor simulated in AspectJ. aspect Total { static int total=0; pointcut traversing_Salary(Salary s): target(s) && call(void t (..)); // better in extended AspectJ // traversal(t) && target(s) // t is a traversal pointcut traversing_Salary_admin(Company c, Object ad): this(c) && withincode(* Company.t_admin(..)) && target(ad) && call(* t(..)); // better in extended AspectJ: // traversal(t) && crossing(admin) && this(c) && target(ad) before(Salary s):traversing_Salary(s) { System.out.println(" at node " + s); System.out.println(" adding " + s.getValue()); total+=s.getValue(); System.out.println(" current total " + total); } before(Company c, Object ad) : traversing_Salary_admin(c, ad) { System.out.println(" at edge source: " + c + " target: " + ad); } void around(): call(void Main.main(..)){ proceed(); System.out.println("total="+total); } } References: @INPROCEEDINGS{rachid:all3, AUTHOR = "Awais Rashid", TITLE = "A Hybrid Approach to Separation of Concerns: The Story of SADES", BOOKTITLE = "Proceedings of the 3rd International Conference on Meta-Level Archi tectures and Separation of Concerns, Reflection 2001, Lecture Notes in Computer Science 2192 ", YEAR = "2001", ADDRESS = "Kyoto", PAGES = "231-249", EDITOR = "", PUBLISHER = "Springer Verlag" }