]> source.dussan.org Git - aspectj.git/commitdiff
added coverage for exceptions thrown from intro methods
authorjhugunin <jhugunin>
Tue, 24 Dec 2002 00:34:05 +0000 (00:34 +0000)
committerjhugunin <jhugunin>
Tue, 24 Dec 2002 00:34:05 +0000 (00:34 +0000)
  these tests were inspired by failures compiling observer example

tests/ajcTests.xml
tests/design/intro/ExceptionsCF.java [new file with mode: 0644]
tests/design/intro/ExceptionsCP.java [new file with mode: 0644]
tests/new/runtime/AllRuntime.java

index 70fe3204172119496cdecdfc4f519706a03fee1a..a4ec74a6752e8d6bb36153db3822b9e422e2cc46 100644 (file)
         </compile>
     </ajc-test>
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
     <ajc-test dir="design/intro"
       title="initial tests for new introduction style" keywords="from-design">
         <compile files="Simple.java"/>
         </compile>
     </ajc-test>
 
+    <ajc-test dir="design/intro"
+      title="declared exceptions are checked correctly on intros (errors)">
+        <compile files="ExceptionsCF.java">
+            <message kind="error" line="8"/>
+            <message kind="error" line="23"/>
+        </compile>
+    </ajc-test>
+
+    <ajc-test dir="design/intro"
+      title="declared exceptions are checked correctly on intros">
+        <compile files="ExceptionsCP.java"/>
+        <run class="ExceptionsCP"/>
+    </ajc-test>
+
     <ajc-test dir="design/reflect"
       title="Joinpoint is not created for foo(String) when before() advice is present."
       keywords="from-design">
diff --git a/tests/design/intro/ExceptionsCF.java b/tests/design/intro/ExceptionsCF.java
new file mode 100644 (file)
index 0000000..4bf8dc6
--- /dev/null
@@ -0,0 +1,24 @@
+import org.aspectj.testing.Tester;
+
+import java.io.IOException;
+
+public class ExceptionsCF {
+    public static void main(String[] args) {
+        C c = new C();
+        c.foo();  // ERR: can't throw IOException here
+    }
+}
+class Root {
+       public void bar() {}
+}
+
+class C extends Root {
+       
+}
+
+
+aspect A {
+       public void C.foo() throws IOException { }
+       
+       public void C.bar() throws IOException {}  // ERR: can't throw more than super
+}
diff --git a/tests/design/intro/ExceptionsCP.java b/tests/design/intro/ExceptionsCP.java
new file mode 100644 (file)
index 0000000..92d0b9b
--- /dev/null
@@ -0,0 +1,25 @@
+import org.aspectj.testing.Tester;
+
+import java.io.IOException;
+
+public class ExceptionsCP {
+    public static void main(String[] args) {
+        C c = new C();
+        try {
+               c.foo();
+        } catch (IOException io) {}
+        c.bar();
+    }
+}
+class Root {
+       public void bar() {}
+}
+
+class C extends Root {
+       
+}
+
+
+aspect A {
+       public void C.foo() throws IOException { }
+}
index cc7face15e04ef0ddc4acb8a9adcd00367f23771..47356aa1f2decdcffb9095b942aeae0a64f36aa0 100644 (file)
@@ -214,7 +214,7 @@ aspect A {
     
     /** unused - enable to throw exception from run() */
     public boolean TargetClass.throwException;
-    public void TargetClass.run() throws Exception {
+    public void TargetClass.run() {
         if (throwException) throwsException();
     }