|
< Back
Release Notes v0.8.0What's new?PointcutsCaesar class names now can be used in poincuts. In the previous version of CaesarJ only names of Java classes could be used in poincuts. The names of Caesar classes (classes, declared withcclass ) couldn't be directly used in poincuts and had to be translated by developer to underlying Java class names. Since version 0.8.0 this translation is done automatically by the compiler.
This change is relevant to get , set and within pointcuts in general, as well as to execution and call poincuts specifically for constructors and static method calls. For example, following code will be woven correctly now:
public cclass ClassA { public int f; public ClassA() { f = 0; } public void m() { f = 5; } public void n() { m(); } public static void x() { } } public cclass Test { public void test() { ClassA a = new ClassA(); a.m(); int f = a.f; a.n(); ClassA.x(); } } public deployed cclass AspectA { /* constructor call */ after() : call(ClassA.new()) { System.out.println("constructor call"); } /* constructor execution */ after() : execution(ClassA.new()) { System.out.println("constructor execution"); } /* field access */ after() : get(* ClassA.*) { System.out.println("field access"); } after() : set(* ClassA.*) { System.out.println("field change"); } /* calls within a class */ after() : call(* *.*(..)) && within(ClassA) { System.out.println("calls within ClassA"); } /* static calls */ after() : call(static * ClassA.*(..)) { System.out.println("static call"); } }Execution of Test.test() will produce following output:
field change constructor execution constructor call field change field access field change calls within ClassA static callNote: There some semantic differences w.r.t. AspectJ poincut language:
class ClsA { public void run() {} class InA { public void run() {} } } class ClsB extends ClsA { /* class InA { public void run() {} } */ } In AspectJ, a pointcut within(ClsA) matches code inside ClsA , ClsA.InA and ClsB.InA . Note that ClsB.InA is commented. That means when ClsB.InA is called, the code used comes from ClsA and matches. If we uncomment this new code, then ClsB.InA is inside ClsB and it does NOT match. A pointcut within(ClsA+) will match everything (ClsA , ClsA.InA , ClsB , ClsB.InA ), despite of the comments.
In Caesar, the semantics are almost the same. The only difference is that nested classes are considered virtual classes and are copied to subtypes. So, the pointcut within(ClsA+) works exactly the same. But within(ClsA) will never match subtypes, even if they do not declare it (in our example, it would not match ClsB.InA , even if commented).
Removed Limitations
Important Bug Fixes
CJDT Plugin for Eclipse
Known limitations
|