<run class="CallTypesI" vm="1.4"/> | <run class="CallTypesI" vm="1.4"/> | ||||
</ajc-test> | </ajc-test> | ||||
<!-- around advice not implemented on initializer join points --> | |||||
<ajc-test dir="new" pr="490" | <ajc-test dir="new" pr="490" | ||||
title="PR#458 Compiler was incorrectly flagging error in advice on initialization and static initialization" | title="PR#458 Compiler was incorrectly flagging error in advice on initialization and static initialization" | ||||
keywords="from-resolved_10x"> | |||||
keywords="from-resolved_10x,knownLimitation"> | |||||
<compile files="StaticInitCE.java"/> | <compile files="StaticInitCE.java"/> | ||||
<run class="StaticInitCE"/> | <run class="StaticInitCE"/> | ||||
</ajc-test> | </ajc-test> |
} | } | ||||
static boolean test() { return true; } | static boolean test() { return true; } | ||||
// one minimal version | |||||
// before(): this(Runnable) && call(* intValue()) { | |||||
// | |||||
// } | |||||
//before(): initialization(C.new(String)) { } | |||||
void around(String s): initialization(C.new(String)) && args(s) && if(s.equals("9")) { | |||||
log("C.new(9)"); | |||||
proceed(s+"1"); | |||||
} | |||||
// void around(String s): initialization(C.new(String)) && args(s) && if(s.equals("9")) { | |||||
// log("C.new(9)"); | |||||
// proceed(s+"1"); | |||||
// } | |||||
Object around(): //initialization(C.new(String)) { | Object around(): //initialization(C.new(String)) { | ||||
if(test()) && !within(A) && !call(* A.*(..)) && !preinitialization(new(..)) { | |||||
if(test()) && !within(A) && !call(* A.*(..)) && !initialization(new(..)) && !preinitialization(new(..)) { | |||||
A.log("enter " + thisJoinPoint); | A.log("enter " + thisJoinPoint); | ||||
Object ret = proceed(); | Object ret = proceed(); | ||||
A.log("exit " + thisJoinPoint); | A.log("exit " + thisJoinPoint); |
/** @testcase PR#666 name binding in around cflow */ | /** @testcase PR#666 name binding in around cflow */ | ||||
void around(final int n) : // no bug if before advice | void around(final int n) : // no bug if before advice | ||||
cflow(execution(void AroundCall.a(int)) && args(n)) // no bug if no args | cflow(execution(void AroundCall.a(int)) && args(n)) // no bug if no args | ||||
&& target(AroundCall) | |||||
&& target(AroundCall) && !initialization(new(..)) | |||||
{ | { | ||||
Tester.event("around"); | Tester.event("around"); | ||||
if (n > 100) proceed(n); // some bugs hidden without call to proceed | if (n > 100) proceed(n); // some bugs hidden without call to proceed |
// instance initializer | // instance initializer | ||||
Tester.expectEvent("init"); | Tester.expectEvent("init"); | ||||
Tester.expectEvent("proceed-init"); | |||||
//XXX see below | |||||
//Tester.expectEvent("proceed-init"); | |||||
String s = new Init().string; | String s = new Init().string; | ||||
Tester.check("test".equals(s), | Tester.check("test".equals(s), | ||||
"\"test\".equals(new Init().string)"); | "\"test\".equals(new Init().string)"); | ||||
} | } | ||||
// instance initializer | // instance initializer | ||||
Object around() : initialization(Init.new(..)) { | |||||
Tester.event("proceed-init"); | |||||
return proceed(); | |||||
} | |||||
//XXX not implemented in 1.1 | |||||
// Object around() : initialization(Init.new(..)) { | |||||
// Tester.event("proceed-init"); | |||||
// return proceed(); | |||||
// } | |||||
} | } | ||||
class FieldInit { | class FieldInit { |
//pointcut goCut(): cflow(!within(FilterAspect)); | //pointcut goCut(): cflow(!within(FilterAspect)); | ||||
//pointcut goCut(): cflow(within(FilterAspect)); | //pointcut goCut(): cflow(within(FilterAspect)); | ||||
//pointcut goCut(): cflow(within(testclass1)); | //pointcut goCut(): cflow(within(testclass1)); | ||||
pointcut goCut(): !within(Filteraspect) && cflow(within(testclass1)) && !preinitialization(new(..)); | |||||
pointcut goCut(): !within(Filteraspect) && cflow(within(testclass1)) | |||||
&& !preinitialization(new(..)) && !initialization(new(..)); | |||||
// works ok | // works ok | ||||
//pointcut goCut(): within(Filteraspect); | //pointcut goCut(): within(Filteraspect); | ||||
Object around(): goCut() { i++; return proceed(); } | Object around(): goCut() { i++; return proceed(); } |
aspect A1 { | aspect A1 { | ||||
pointcut TargetRunFlow () | pointcut TargetRunFlow () | ||||
// ok if no cflow: within(Target) && execution(* *(..)) && !within(A1+); | // ok if no cflow: within(Target) && execution(* *(..)) && !within(A1+); | ||||
: !within(A1+) && !preinitialization(new(..)) //cflow(within(Target) && execution(* *(..))) && !within(A1+) | |||||
: !within(A1+) && !preinitialization(new(..)) && !initialization(new(..))//cflow(within(Target) && execution(* *(..))) && !within(A1+) | |||||
; | ; | ||||
Object around () : TargetRunFlow() { | Object around () : TargetRunFlow() { | ||||
Tester.event("target A1"); | Tester.event("target A1"); |
for (int i = 0; i < cuts.length; i++) { | for (int i = 0; i < cuts.length; i++) { | ||||
for (int j = 0; j < kinds.length; j++) { | for (int j = 0; j < kinds.length; j++) { | ||||
for (int k = 0; k < ifs.length; k++) { | for (int k = 0; k < ifs.length; k++) { | ||||
//XXX no around on initialization yet | |||||
if (kinds[j].equals("around") && cuts[i].equals("initialization_pc")) continue; | |||||
TestContext.expectSignal(kinds[j] + "." + cuts[i] + "." + ifs[k]); | TestContext.expectSignal(kinds[j] + "." + cuts[i] + "." + ifs[k]); | ||||
} | } | ||||
} | } | ||||
// Aspect namedIf delegate should have been called this many times | // Aspect namedIf delegate should have been called this many times | ||||
// (todo: only checks for at-least, not for extra calls) | // (todo: only checks for at-least, not for extra calls) | ||||
final int namedIfCalls = 2*cuts.length * (ifs.length-1); // -1 for anonymous, 2* for two calls | |||||
// -1 for anonymous, 2* for two calls, -1 for around initialization | |||||
final int namedIfCalls = 2*cuts.length * (ifs.length-1) - 1; | |||||
for (int i = 0; i < namedIfCalls; i++) { | for (int i = 0; i < namedIfCalls; i++) { | ||||
TestContext.expectSignal("executedNamedIf:"+i); | TestContext.expectSignal("executedNamedIf:"+i); | ||||
} | } | ||||
void around() : call_pc () { a("around.call_pc.if(true)"); proceed(); } | void around() : call_pc () { a("around.call_pc.if(true)"); proceed(); } | ||||
void around() : callType_pc() { a("around.callType_pc.if(true)"); proceed(); } | void around() : callType_pc() { a("around.callType_pc.if(true)"); proceed(); } | ||||
void around() : execution_pc() { a("around.execution_pc.if(true)"); proceed(); } | void around() : execution_pc() { a("around.execution_pc.if(true)"); proceed(); } | ||||
void around() : initialization_pc() { a("around.initialization_pc.if(true)"); proceed(); } | |||||
//XXXvoid around() : initialization_pc() { a("around.initialization_pc.if(true)"); proceed(); } | |||||
Object around() : named_set_pc () { a("around.set_pc.namedIf()"); return proceed(); } | Object around() : named_set_pc () { a("around.set_pc.namedIf()"); return proceed(); } | ||||
int around() : named_get_pc () { a("around.get_pc.namedIf()"); return proceed(); } | int around() : named_get_pc () { a("around.get_pc.namedIf()"); return proceed(); } | ||||
void around() : named_call_pc () { a("around.call_pc.namedIf()"); proceed(); } | void around() : named_call_pc () { a("around.call_pc.namedIf()"); proceed(); } | ||||
void around() : named_callType_pc() { a("around.callType_pc.namedIf()"); proceed(); } | void around() : named_callType_pc() { a("around.callType_pc.namedIf()"); proceed(); } | ||||
void around() : named_execution_pc() { a("around.execution_pc.namedIf()"); proceed(); } | void around() : named_execution_pc() { a("around.execution_pc.namedIf()"); proceed(); } | ||||
void around() : named_initialization_pc() { a("around.initialization_pc.namedIf()"); proceed(); } | |||||
//XXXvoid around() : named_initialization_pc() { a("around.initialization_pc.namedIf()"); proceed(); } | |||||
// ------------------------------------- after | // ------------------------------------- after | ||||
after(): set_pc () { a("after.set_pc.if(true)"); } | after(): set_pc () { a("after.set_pc.if(true)"); } | ||||
proceed(); | proceed(); | ||||
} | } | ||||
/** @testTarget ifpcd.compile.pcds.unnamed.initialization.around */ | /** @testTarget ifpcd.compile.pcds.unnamed.initialization.around */ | ||||
void around() : if(true) && initialization(BaseApp.new(..)) { | |||||
a("around.initialization_pc.anonymous"); | |||||
proceed(); | |||||
} | |||||
//XXX | |||||
// void around() : if(true) && initialization(BaseApp.new(..)) { | |||||
// a("around.initialization_pc.anonymous"); | |||||
// proceed(); | |||||
// } | |||||
/** @testTarget ifpcd.compile.pcds.unnamed.set.after */ | /** @testTarget ifpcd.compile.pcds.unnamed.set.after */ | ||||
after() : if(true) && set(int BaseApp.i) { | after() : if(true) && set(int BaseApp.i) { |
} | } | ||||
interface AspectMarker { | interface AspectMarker { | ||||
pointcut notInAspect() : ! within(AspectMarker+) && !preinitialization(new(..)); | |||||
pointcut notInAspect() : ! within(AspectMarker+) && | |||||
!preinitialization(new(..)) && !initialization(new(..)); | |||||
pointcut allTarget() : execution(* Target.*(..)) ; | pointcut allTarget() : execution(* Target.*(..)) ; | ||||
pointcut allTargetFlow() : cflow(allTarget()); | pointcut allTargetFlow() : cflow(allTarget()); | ||||
pointcut inTarget() : notInAspect() && allTarget(); | pointcut inTarget() : notInAspect() && allTarget(); |