Browse Source

lazytjp default - test code

tags/V1_5_0RC1
aclement 18 years ago
parent
commit
260ff1798e

+ 21
- 0
tests/bugs/lazyTjpXLintWarning/LazyTjpTest1.java View File

@@ -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();
}
}
}

+ 30
- 0
tests/bugs/lazyTjpXLintWarning/LazyTjpTest2.java View File

@@ -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);
}
}

}

+ 31
- 0
tests/bugs/lazyTjpXLintWarning/LazyTjpTest3.java View File

@@ -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);
}
}

}

+ 18
- 0
tests/bugs/lazyTjpXLintWarning/LazyTjpTest4.java View File

@@ -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);
}
}

}

+ 19
- 0
tests/bugs/lazyTjpXLintWarning/Scenario1.aj View File

@@ -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){
}
}

+ 23
- 0
tests/bugs/lazyTjpXLintWarning/Scenario2.aj View File

@@ -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){
}
}

+ 24
- 0
tests/bugs/lazyTjpXLintWarning/Scenario3.aj View File

@@ -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){
}
}

+ 19
- 0
tests/bugs/lazyTjpXLintWarning/Scenario4.aj View File

@@ -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){
}
}

+ 24
- 0
tests/bugs/lazyTjpXLintWarning/Scenario5.aj View File

@@ -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){
}
}

Loading…
Cancel
Save