]> source.dussan.org Git - aspectj.git/commitdiff
test cases for Bugzilla Bug 42743: declare soft limitation
authoracolyer <acolyer>
Mon, 14 Mar 2005 02:17:51 +0000 (02:17 +0000)
committeracolyer <acolyer>
Mon, 14 Mar 2005 02:17:51 +0000 (02:17 +0000)
tests/decs/DeclareSoftRuntimeException.aj [new file with mode: 0644]
tests/decs/VerifyError.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/ajc150.xml

diff --git a/tests/decs/DeclareSoftRuntimeException.aj b/tests/decs/DeclareSoftRuntimeException.aj
new file mode 100644 (file)
index 0000000..379ba64
--- /dev/null
@@ -0,0 +1,41 @@
+public aspect DeclareSoftRuntimeException {
+       
+       declare soft : MyRuntimeException : execution(* *(..));
+       declare soft : MyException : execution(* *(..));
+       declare soft : Exception : execution(void throwMyExceptionButNotReally());
+       
+       public static void main(String[] args) {
+               try {
+                       throwMyRuntimeException();
+               } catch(Exception ex) {
+                       System.out.println(ex.getClass().getName());
+               }
+               try {
+                       throwMyException();
+               } catch(Exception ex) {
+                       System.out.println(ex.getClass().getName());
+               }
+               try {
+                       throwMyExceptionButNotReally();
+               } catch(Exception ex) {
+                       System.out.println(ex.getClass().getName());
+               }
+       }
+       
+       private static void throwMyRuntimeException() {
+               throw new MyRuntimeException();
+       }
+       
+       private static void throwMyException() throws MyException {
+               throw new MyException();
+       }
+       
+       private static void throwMyExceptionButNotReally() throws MyException {
+               throw new MyRuntimeException();
+       }
+       
+}
+
+class MyRuntimeException extends RuntimeException {}
+
+class MyException extends Exception {}
diff --git a/tests/decs/VerifyError.aj b/tests/decs/VerifyError.aj
new file mode 100644 (file)
index 0000000..8357487
--- /dev/null
@@ -0,0 +1,23 @@
+import java.io.IOException;
+import org.aspectj.lang.SoftException;
+
+public class VerifyError {
+
+    static void foo() throws IOException {
+        throw new IOException();
+    }
+
+    public static void main(String[] args) throws Exception{
+               try {
+            foo();
+               } catch (SoftException sEx) {
+                       //
+               }
+    }
+}
+
+
+aspect Soften {
+
+    declare soft : IOException : call(* foo());
+}
\ No newline at end of file
index 82e1aed27d0d5b975fcbdfe025735e3675c3629c..a1aeb6d77fdb59f8a438c3af5ca8a28f45f213c8 100644 (file)
@@ -111,7 +111,7 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void test051_arrayCloningInJava5() {
     runTest("AJC possible bug with static nested classes");
   }
-  
   public void testBadASMforEnums() throws IOException {
        runTest("bad asm for enums");
        
@@ -128,6 +128,14 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void npeOnTypeNotFound() {
          runTest("structure model npe on type not found");
   }
+  public void testNoRuntimeExceptionSoftening() {
+         runTest("declare soft of runtime exception");
+  }
+  
+  public void testRuntimeNoSoftenWithHandler() {
+         runTest("declare soft w. catch block");
+  }
   
   // helper methods.....
   
index 666ad0d334904dfeece4ee6e0f9cca8a6fed0313..2e165f3a8f84c5fc3c2551b1a9594645e6ff58c0 100644 (file)
         <run class="B"/>
     </ajc-test>
     
+    <ajc-test dir="decs" pr="42743" title="declare soft of runtime exception">
+        <compile files="DeclareSoftRuntimeException.aj">
+            <message kind="warning" line="3" text="MyRuntimeException will not be softened as it is already a RuntimeException"/>
+        </compile>
+        <run class="DeclareSoftRuntimeException">
+            <stdout>
+                <line text="MyRuntimeException"/>
+                <line text="org.aspectj.lang.SoftException"/>
+                <line text="MyRuntimeException"/>
+            </stdout>
+        </run>
+    </ajc-test>
+
+    <ajc-test dir="decs" pr="42743" title="declare soft w. catch block">
+        <compile files="VerifyError.aj">
+        </compile>
+        <run class="VerifyError"/>
+    </ajc-test>
+        
     <ajc-test dir="bugs" pr="61568" title="Various kinds of ambiguous bindings">
         <compile files="AmbiguousBindings.aj">
             <message line="17" text="ambiguous binding of parameter(s) foo across '||' in pointcut"></message>