aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs152
diff options
context:
space:
mode:
authoraclement <aclement>2006-05-31 10:09:27 +0000
committeraclement <aclement>2006-05-31 10:09:27 +0000
commit12afa8740ebca74541738b6c73034a035018e0b4 (patch)
tree6d8b7de9023404d2f6cff08304e321d2de4dcf50 /tests/bugs152
parent4fd9d65ae4b54b1dc0c2e04bac018c714a05f15f (diff)
downloadaspectj-12afa8740ebca74541738b6c73034a035018e0b4.tar.gz
aspectj-12afa8740ebca74541738b6c73034a035018e0b4.zip
testcode for 129282
Diffstat (limited to 'tests/bugs152')
-rw-r--r--tests/bugs152/pr129282/AdviceExecution.aj27
-rw-r--r--tests/bugs152/pr129282/ConstructorCall.aj23
-rw-r--r--tests/bugs152/pr129282/ConstructorExecution.aj19
-rw-r--r--tests/bugs152/pr129282/ExceptionHandler.aj39
-rw-r--r--tests/bugs152/pr129282/Initialization.aj30
-rw-r--r--tests/bugs152/pr129282/InnerMethodCall.aj52
-rw-r--r--tests/bugs152/pr129282/InnerMethodCall2.aj40
-rw-r--r--tests/bugs152/pr129282/MethodCall.aj38
-rw-r--r--tests/bugs152/pr129282/MethodCallInDiffClass.aj28
-rw-r--r--tests/bugs152/pr129282/MethodExecution.aj33
10 files changed, 329 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{
+ }
+
+}