@@ -0,0 +1,21 @@ | |||
public class LazyTjpTest1 { | |||
public void test1 () { } | |||
public void test2 () { } | |||
private static aspect Aspect2 { | |||
// OK, no tjp used in the advice | |||
void around () : execution(public void test1()) { | |||
System.out.println("Aspect2.around() "); | |||
proceed(); | |||
} | |||
// Warning: tjp used in around advice so can't apply lazyTjp | |||
void around () : execution(public void test2()) { | |||
System.out.println("Aspect2.around() " + thisJoinPoint); | |||
proceed(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,30 @@ | |||
public class LazyTjpTest2 { | |||
public void test1 () { } | |||
public void test2 () { } | |||
public void test3 () { } | |||
private static aspect Aspect1 { | |||
private static boolean enabled = true; | |||
// OK, has an if() but doesnt use tjp anyway! | |||
before () : if(enabled) && execution(public void LazyTjpTest2.test1()) { | |||
} | |||
// Not ok, cant apply because no if() used | |||
before () : execution(public void LazyTjpTest2.test2()) { | |||
System.out.println(thisJoinPoint); | |||
} | |||
// OK, doesnt use tjp | |||
before () : execution(public void LazyTjpTest2.test3()) { | |||
} | |||
// OK, uses tjp but also has if() | |||
before () : if(enabled) && execution(public void LazyTjpTest2.test1()) { | |||
System.err.println(thisJoinPoint); | |||
} | |||
} | |||
} |
@@ -0,0 +1,31 @@ | |||
public class LazyTjpTest3 { | |||
public void test1 () { } | |||
public void test2 () { } | |||
public void test3 () { } | |||
public void test4 () { } | |||
private static aspect Aspect1 { | |||
private static boolean enabled = true; | |||
// OK, has an if() but doesnt use tjp anyway! | |||
after () : if(enabled) && execution(public void LazyTjpTest3.test1()) { | |||
} | |||
// Not ok, cant apply because no if() used | |||
after () : execution(public void LazyTjpTest3.test2()) { | |||
System.out.println(thisJoinPoint); | |||
} | |||
// OK, doesnt use tjp | |||
after () : execution(public void LazyTjpTest3.test3()) { | |||
} | |||
// OK, uses tjp but also has if() | |||
after () : if(enabled) && execution(public void LazyTjpTest3.test4()) { | |||
System.err.println(thisJoinPoint); | |||
} | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
public class LazyTjpTest4 { | |||
public void test1 () { } | |||
private static aspect Aspect1 { | |||
private static boolean enabled = true; | |||
after () : if(enabled) && execution(public void LazyTjpTest4.test1()) { | |||
System.out.println(thisJoinPoint); | |||
} | |||
before() : execution(public void LazyTjpTest4.test1()) { | |||
System.out.println(thisJoinPoint); | |||
} | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
// "no XLint warning: thisJoinPoint potentially lazy and nothing stopping it" | |||
public aspect Scenario1 { | |||
public static boolean enabled = true; | |||
pointcut toBeTraced() : execution(* main(..)); | |||
before () : toBeTraced() && if(enabled) { | |||
Object[] args = thisJoinPoint.getArgs(); // tjp made lazily | |||
System.out.println(thisJoinPoint + ", arg's: " + args.length); | |||
} | |||
} | |||
class Test{ | |||
static void main(String [] args){ | |||
} | |||
} |
@@ -0,0 +1,23 @@ | |||
// "XLint warning: thisJoinPoint potentially lazy but stopped by around advice which doesn't use tjp" | |||
public aspect Scenario2 { | |||
public static boolean enabled = true; | |||
pointcut toBeTraced() : execution(* main(..)); | |||
before () : toBeTraced() && if(enabled) { | |||
Object[] args = thisJoinPoint.getArgs(); // tjp not made lazily | |||
System.out.println(thisJoinPoint + ", arg's: " + args.length); | |||
} | |||
Object around() : toBeTraced() && if(enabled) { | |||
return proceed(); | |||
} | |||
} | |||
class Test{ | |||
static void main(String [] args){ | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
// "no XLint warning: thisJoinPoint not lazy (no if PCD) but would have been stopped anyway by around advice" | |||
public aspect Scenario3 { | |||
public static boolean enabled = true; | |||
pointcut toBeTraced() : execution(* main(..)); | |||
Object around() : toBeTraced() { | |||
// Object[] args = thisJoinPoint.getArgs(); | |||
return proceed(); | |||
} | |||
before () : toBeTraced(){ // no if condition so tjp not made lazily | |||
Object[] args = thisJoinPoint.getArgs(); // tjp not made lazily | |||
System.out.println(thisJoinPoint + ", arg's: " + args.length); | |||
} | |||
} | |||
class Test{ | |||
static void main(String [] args){ | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
// "no XLint warning: thisJoinPoint cannot be built lazily" | |||
public aspect Scenario4 { | |||
public static boolean enabled = true; | |||
pointcut toBeTraced() : execution(* main(..)); | |||
before () : toBeTraced() { // no if condition | |||
Object[] args = thisJoinPoint.getArgs(); // tjp not made lazily | |||
System.out.println(thisJoinPoint + ", arg's: " + args.length); | |||
} | |||
} | |||
class Test{ | |||
static void main(String [] args){ | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
//"XLint warning: thisJoinPoint potentially lazy but stopped by around advice which uses tjp" | |||
public aspect Scenario5 { | |||
public static boolean enabled = true; | |||
pointcut toBeTraced() : execution(* main(..)); | |||
before () : toBeTraced() && if(enabled) { | |||
Object[] args = thisJoinPoint.getArgs(); // tjp not made lazily | |||
System.out.println(thisJoinPoint + ", arg's: " + args.length); | |||
} | |||
Object around() : toBeTraced() && if(enabled) { | |||
Object[] args = thisJoinPoint.getArgs(); // tjp used in the around advice | |||
return proceed(); | |||
} | |||
} | |||
class Test{ | |||
static void main(String [] args){ | |||
} | |||
} |