@@ -3678,9 +3678,10 @@ | |||
<run class="CallTypesI" vm="1.4"/> | |||
</ajc-test> | |||
<!-- around advice not implemented on initializer join points --> | |||
<ajc-test dir="new" pr="490" | |||
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"/> | |||
<run class="StaticInitCE"/> | |||
</ajc-test> |
@@ -145,16 +145,20 @@ aspect A { | |||
} | |||
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)) { | |||
if(test()) && !within(A) && !call(* A.*(..)) && !preinitialization(new(..)) { | |||
if(test()) && !within(A) && !call(* A.*(..)) && !initialization(new(..)) && !preinitialization(new(..)) { | |||
A.log("enter " + thisJoinPoint); | |||
Object ret = proceed(); | |||
A.log("exit " + thisJoinPoint); |
@@ -20,7 +20,7 @@ aspect TestAspect { | |||
/** @testcase PR#666 name binding in around cflow */ | |||
void around(final int n) : // no bug if before advice | |||
cflow(execution(void AroundCall.a(int)) && args(n)) // no bug if no args | |||
&& target(AroundCall) | |||
&& target(AroundCall) && !initialization(new(..)) | |||
{ | |||
Tester.event("around"); | |||
if (n > 100) proceed(n); // some bugs hidden without call to proceed |
@@ -32,7 +32,8 @@ public aspect AroundDoubleAssignmentC { | |||
// instance initializer | |||
Tester.expectEvent("init"); | |||
Tester.expectEvent("proceed-init"); | |||
//XXX see below | |||
//Tester.expectEvent("proceed-init"); | |||
String s = new Init().string; | |||
Tester.check("test".equals(s), | |||
"\"test\".equals(new Init().string)"); | |||
@@ -62,10 +63,11 @@ public aspect AroundDoubleAssignmentC { | |||
} | |||
// 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 { |
@@ -20,7 +20,8 @@ aspect Filteraspect { | |||
//pointcut goCut(): cflow(!within(FilterAspect)); | |||
//pointcut goCut(): cflow(within(FilterAspect)); | |||
//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 | |||
//pointcut goCut(): within(Filteraspect); | |||
Object around(): goCut() { i++; return proceed(); } |
@@ -17,7 +17,7 @@ class Target { | |||
aspect A1 { | |||
pointcut TargetRunFlow () | |||
// 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() { | |||
Tester.event("target A1"); |
@@ -68,6 +68,8 @@ public class IfPCDAdviceMethods { | |||
for (int i = 0; i < cuts.length; i++) { | |||
for (int j = 0; j < kinds.length; j++) { | |||
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]); | |||
} | |||
} | |||
@@ -77,7 +79,8 @@ public class IfPCDAdviceMethods { | |||
// Aspect namedIf delegate should have been called this many times | |||
// (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++) { | |||
TestContext.expectSignal("executedNamedIf:"+i); | |||
} | |||
@@ -196,14 +199,14 @@ aspect Aspect { | |||
void around() : call_pc () { a("around.call_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() : 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(); } | |||
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_callType_pc() { a("around.callType_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(): set_pc () { a("after.set_pc.if(true)"); } | |||
@@ -280,10 +283,11 @@ aspect Aspect2 { | |||
proceed(); | |||
} | |||
/** @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 */ | |||
after() : if(true) && set(int BaseApp.i) { |
@@ -32,7 +32,8 @@ public class PR559 { | |||
} | |||
interface AspectMarker { | |||
pointcut notInAspect() : ! within(AspectMarker+) && !preinitialization(new(..)); | |||
pointcut notInAspect() : ! within(AspectMarker+) && | |||
!preinitialization(new(..)) && !initialization(new(..)); | |||
pointcut allTarget() : execution(* Target.*(..)) ; | |||
pointcut allTargetFlow() : cflow(allTarget()); | |||
pointcut inTarget() : notInAspect() && allTarget(); |