diff options
author | aclement <aclement> | 2006-05-31 10:09:27 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-05-31 10:09:27 +0000 |
commit | 12afa8740ebca74541738b6c73034a035018e0b4 (patch) | |
tree | 6d8b7de9023404d2f6cff08304e321d2de4dcf50 | |
parent | 4fd9d65ae4b54b1dc0c2e04bac018c714a05f15f (diff) | |
download | aspectj-12afa8740ebca74541738b6c73034a035018e0b4.tar.gz aspectj-12afa8740ebca74541738b6c73034a035018e0b4.zip |
testcode for 129282
-rw-r--r-- | tests/bugs152/pr129282/AdviceExecution.aj | 27 | ||||
-rw-r--r-- | tests/bugs152/pr129282/ConstructorCall.aj | 23 | ||||
-rw-r--r-- | tests/bugs152/pr129282/ConstructorExecution.aj | 19 | ||||
-rw-r--r-- | tests/bugs152/pr129282/ExceptionHandler.aj | 39 | ||||
-rw-r--r-- | tests/bugs152/pr129282/Initialization.aj | 30 | ||||
-rw-r--r-- | tests/bugs152/pr129282/InnerMethodCall.aj | 52 | ||||
-rw-r--r-- | tests/bugs152/pr129282/InnerMethodCall2.aj | 40 | ||||
-rw-r--r-- | tests/bugs152/pr129282/MethodCall.aj | 38 | ||||
-rw-r--r-- | tests/bugs152/pr129282/MethodCallInDiffClass.aj | 28 | ||||
-rw-r--r-- | tests/bugs152/pr129282/MethodExecution.aj | 33 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc152/ajc152.xml | 49 |
11 files changed, 378 insertions, 0 deletions
diff --git a/tests/bugs152/pr129282/AdviceExecution.aj b/tests/bugs152/pr129282/AdviceExecution.aj new file mode 100644 index 000000000..9171f2f73 --- /dev/null +++ b/tests/bugs152/pr129282/AdviceExecution.aj @@ -0,0 +1,27 @@ +import java.io.FileNotFoundException; + +import org.aspectj.lang.annotation.AdviceName; + +public aspect AdviceExecution { + + // don't want the 'declared exception not actually + // thrown' warning against this piece of advice + @AdviceName("Test") + before() throws FileNotFoundException : execution(* C.method1(..)) { + } + + before(AdviceName name) throws FileNotFoundException : adviceexecution() + && @annotation(name) + && if(name.value().indexOf("Test") != -1) { + throw new FileNotFoundException(); + } + +} + +class C { + + // don't want the 'declared exception not actually + // thrown' warning + public void method1() throws FileNotFoundException { + } +} diff --git a/tests/bugs152/pr129282/ConstructorCall.aj b/tests/bugs152/pr129282/ConstructorCall.aj new file mode 100644 index 000000000..6bae49966 --- /dev/null +++ b/tests/bugs152/pr129282/ConstructorCall.aj @@ -0,0 +1,23 @@ +import java.io.FileNotFoundException; + +public aspect ConstructorCall { + + pointcut p() : call(public C1.new()); + + before() throws FileNotFoundException : p() { + throw new FileNotFoundException(); + } + +} + +class C1 { + + // shouldn't get the warning against the constructor + public C1() throws FileNotFoundException { + } + + public void m1() throws FileNotFoundException { + new C1(); + } + +} diff --git a/tests/bugs152/pr129282/ConstructorExecution.aj b/tests/bugs152/pr129282/ConstructorExecution.aj new file mode 100644 index 000000000..816f223ec --- /dev/null +++ b/tests/bugs152/pr129282/ConstructorExecution.aj @@ -0,0 +1,19 @@ +import java.io.FileNotFoundException; + +public aspect ConstructorExecution { + + pointcut p1() : execution(public C1.new()); + + before() throws FileNotFoundException : p1() { + throw new FileNotFoundException(); + } + +} + +class C1 { + + // shouldn't get the warning on this constructor + public C1() throws FileNotFoundException { + } + +} diff --git a/tests/bugs152/pr129282/ExceptionHandler.aj b/tests/bugs152/pr129282/ExceptionHandler.aj new file mode 100644 index 000000000..3ff3f47e2 --- /dev/null +++ b/tests/bugs152/pr129282/ExceptionHandler.aj @@ -0,0 +1,39 @@ +// with the exception handler, the advice isn't actually throwing the +// exception for the method - therefore, expect warnings when the methods +// don't throw the exception themselves. +public aspect ExceptionHandler { + + pointcut p() : handler(*); + + before() throws MyException : p() { + throw new MyException(); + } + + +} + +class C { + + public void method1() { + try { + new C().throwingMethod(); + new C().throwingMethod2(); + } catch (MyException e) { + e.printStackTrace(); + } + } + + // dont want 'declared exception not actually thrown' + // warning for this method because it's throwing it + public void throwingMethod() throws MyException { + throw new MyException(); + } + + // do want 'declared exception not actually thrown' + // warning because it doesn't throw it + public void throwingMethod2() throws MyException { + } +} + +class MyException extends Exception { +} diff --git a/tests/bugs152/pr129282/Initialization.aj b/tests/bugs152/pr129282/Initialization.aj new file mode 100644 index 000000000..c3c360b00 --- /dev/null +++ b/tests/bugs152/pr129282/Initialization.aj @@ -0,0 +1,30 @@ +import java.io.FileNotFoundException; + +public aspect Initialization { + + pointcut preInit() : preinitialization(C.new(String)); + + before() throws FileNotFoundException : preInit() { + throw new FileNotFoundException(); + } + + pointcut init() : initialization(C.new()); + + before() throws FileNotFoundException : init() { + throw new FileNotFoundException(); + } +} + +class C { + + // shouldn't get a warning against this constructor + // since the throwing is handled by the advice + public C() throws FileNotFoundException { + } + + // shouldn't get a warning against this constructor + // since the throwing is handled by the advice + public C(String s) throws FileNotFoundException { + } + +} diff --git a/tests/bugs152/pr129282/InnerMethodCall.aj b/tests/bugs152/pr129282/InnerMethodCall.aj new file mode 100644 index 000000000..ed1f54c3d --- /dev/null +++ b/tests/bugs152/pr129282/InnerMethodCall.aj @@ -0,0 +1,52 @@ +import java.io.FileNotFoundException; + +public aspect InnerMethodCall { + + pointcut p() : call(public * C1.m2()); + + before() throws FileNotFoundException : p() { + throw new FileNotFoundException(); + } + + pointcut p2() : call(public * C1.m4()); + + before() : p2() { + } + +} + +class C1 { + + public void m1() { + new C2() { + public void m6() throws FileNotFoundException { + new C1().m2(); + } + }; + } + + // don't want the 'declared exception not actually + // thrown' warning because the advice is affecting + // this method + public void m2() throws FileNotFoundException { + } + + public void m3() { + new C2() { + public void m6() throws FileNotFoundException { + new C1().m4(); + } + }; + } + + // do want the 'declared exception not actually + // thrown' warning + public void m4() throws FileNotFoundException { + } + + +} + +abstract class C2 { + public abstract void m6() throws FileNotFoundException; +} diff --git a/tests/bugs152/pr129282/InnerMethodCall2.aj b/tests/bugs152/pr129282/InnerMethodCall2.aj new file mode 100644 index 000000000..202bf8806 --- /dev/null +++ b/tests/bugs152/pr129282/InnerMethodCall2.aj @@ -0,0 +1,40 @@ +import java.io.FileNotFoundException; + +aspect InnerMethodCall2 { + + pointcut p() : call(* C1.c1Method()); + + before() throws FileNotFoundException : p() { + throw new FileNotFoundException(); + } + +} + +class MainClass { + + public void amethod() { + new C() { + public void mymethod() throws FileNotFoundException { + new C() { + public void mymethod() throws FileNotFoundException { + new C1().c1Method(); + } + }; + } + }; + } + +} + +class C1 { + + // don't want the 'declared exception not actually thrown' + // exception because the advice is effectively throwing it + public void c1Method() throws FileNotFoundException { + } + +} + +abstract class C { + public abstract void mymethod() throws FileNotFoundException; +} diff --git a/tests/bugs152/pr129282/MethodCall.aj b/tests/bugs152/pr129282/MethodCall.aj new file mode 100644 index 000000000..b05c899a1 --- /dev/null +++ b/tests/bugs152/pr129282/MethodCall.aj @@ -0,0 +1,38 @@ +import java.io.FileNotFoundException; + +public aspect MethodCall { + + pointcut p() : call(public * C1.m2()); + + before() throws FileNotFoundException : p() { + throw new FileNotFoundException(); + } + + pointcut p2() : call(public * C1.m4()); + + before() : p2() { + } + +} + +class C1 { + + public void m1() throws FileNotFoundException { + new C1().m2(); + } + + // don't want the 'declared exception not actually + // thrown' warning because the advice is affecting + // this method + public void m2() throws FileNotFoundException { + } + + public void m3() throws FileNotFoundException { + new C1().m4(); + } + + // do want the 'declared exception not actually + // thrown' warning + public void m4() throws FileNotFoundException { + } +} diff --git a/tests/bugs152/pr129282/MethodCallInDiffClass.aj b/tests/bugs152/pr129282/MethodCallInDiffClass.aj new file mode 100644 index 000000000..f63e551d5 --- /dev/null +++ b/tests/bugs152/pr129282/MethodCallInDiffClass.aj @@ -0,0 +1,28 @@ +import java.io.FileNotFoundException; + +public aspect MethodCallInDiffClass { + + pointcut p() : call(public * B1.m2()); + + before() throws FileNotFoundException : p() { + throw new FileNotFoundException(); + } + +} + +class B { + + public void m1() throws FileNotFoundException { + new B1().m2(); + } + +} + +class B1 { + + // don't want the 'declared exception not acutally + // thrown' warning since the advice is throwing it + public void m2() throws FileNotFoundException { + } + +} diff --git a/tests/bugs152/pr129282/MethodExecution.aj b/tests/bugs152/pr129282/MethodExecution.aj new file mode 100644 index 000000000..45224f7a3 --- /dev/null +++ b/tests/bugs152/pr129282/MethodExecution.aj @@ -0,0 +1,33 @@ +import java.sql.SQLException; + +public aspect MethodExecution { + + pointcut pc() : execution(public * C.shouldntThrow(..)); + + Object around() throws SQLException :pc(){ + throw new SQLException(); + } + + pointcut pc2() : execution(public * C.needsToThrow(..)); + + // C.needsToThrow still needs to throw the exception because + // this advice isn't doing anything with exceptions + before() : pc2() { + } + +} + +class C { + + // don't want the "declared exception is not actually + // thrown" message because around advice is affecting + // this method + public void shouldntThrow() throws SQLException { + } + + // do want the "declared exception is not actually + // thrown" message to appear for this method + public void needsToThrow() throws SQLException{ + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml index 557d8182c..b8ff2b586 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml +++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml @@ -319,6 +319,55 @@ </compile> </ajc-test> + + <ajc-test dir="bugs152/pr129282" title="no unnecessary declaration of thrown exception warning - 1"> + <compile files="MethodExecution.aj" options="-warn:+unusedThrown"> + <message kind="warning" line="30" text="The declared exception SQLException is not actually thrown by the method needsToThrow() from type C"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs152/pr129282" title="no unnecessary declaration of thrown exception warning - 2"> + <compile files="MethodCall.aj" options="-warn:+unusedThrown"> + <message kind="warning" line="36" text="The declared exception FileNotFoundException is not actually thrown by the method m4() from type C1"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs152/pr129282" title="no unnecessary declaration of thrown exception warning - 3"> + <compile files="InnerMethodCall.aj" options="-warn:+unusedThrown"> + <message kind="warning" line="44" text="The declared exception FileNotFoundException is not actually thrown by the method m4() from type C1"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs152/pr129282" title="no unnecessary declaration of thrown exception warning - 4"> + <compile files="AdviceExecution.aj" options="-1.5 -warn:+unusedThrown"/> + </ajc-test> + + <ajc-test dir="bugs152/pr129282" title="no unnecessary declaration of thrown exception warning - 5"> + <compile files="ExceptionHandler.aj" options="-warn:+unusedThrown"> + <message kind="warning" line="34" text="The declared exception MyException is not actually thrown by the method throwingMethod2() from type C"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs152/pr129282" title="no unnecessary declaration of thrown exception warning - 6"> + <compile files="Initialization.aj" options="-warn:+unusedThrown"/> + </ajc-test> + + <ajc-test dir="bugs152/pr129282" title="no unnecessary declaration of thrown exception warning - 7"> + <compile files="ConstructorCall.aj" options="-warn:+unusedThrown"/> + </ajc-test> + + <ajc-test dir="bugs152/pr129282" title="no unnecessary declaration of thrown exception warning - 8"> + <compile files="ConstructorExecution.aj" options="-warn:+unusedThrown"/> + </ajc-test> + + <ajc-test dir="bugs152/pr129282" title="no unnecessary declaration of thrown exception warning - 9"> + <compile files="MethodCallInDiffClass.aj" options="-warn:+unusedThrown"/> + </ajc-test> + + <ajc-test dir="bugs152/pr129282" title="no unnecessary declaration of thrown exception warning - 10"> + <compile files="InnerMethodCall2.aj" options="-warn:+unusedThrown"/> + </ajc-test> + <ajc-test dir="bugs152/pr138215" pr="138215" title="Reference pointcut fails inside @DeclareWarning"> <compile files="pr138215.aj" options="-1.5"> <message kind="warning" line="17" text="no foos please"/> |