]> source.dussan.org Git - aspectj.git/commitdiff
test for 138798
authoraclement <aclement>
Thu, 27 Apr 2006 07:06:30 +0000 (07:06 +0000)
committeraclement <aclement>
Thu, 27 Apr 2006 07:06:30 +0000 (07:06 +0000)
tests/bugs152/pr138798/ErrorHandling.aj [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc152/Ajc152Tests.java
tests/src/org/aspectj/systemtest/ajc152/ajc152.xml

diff --git a/tests/bugs152/pr138798/ErrorHandling.aj b/tests/bugs152/pr138798/ErrorHandling.aj
new file mode 100644 (file)
index 0000000..0b07335
--- /dev/null
@@ -0,0 +1,41 @@
+import org.aspectj.lang.JoinPoint.StaticPart;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+//@Retention(RetentionPolicy.RUNTIME)
+@interface NormalException {
+    /** The default of Void means ANY throwable */
+    Class[] value() default Void.class; 
+}
+
+public aspect ErrorHandling {
+
+    before(Throwable throwable) : handler(*) && args(throwable) && !@withincode(NormalException) {
+       System.err.println("Caught in "+thisEnclosingJoinPointStaticPart.getSignature().getName());
+    }    
+
+    public static void main(String argz[]) {
+       new Test().checkConnection();
+    }
+}
+
+class Test {
+    @NormalException(Exception.class)
+    protected void checkConnection() {
+        try {
+            foo();
+        } catch (Exception e) {
+               ;//skip warning
+        }
+    }
+    
+    private void foo() {
+       try {
+               throw new RuntimeException();
+       } catch (RuntimeException e) {
+               throw e;
+       }
+    }
+
+}
index 261cc4f8b0dd1dc418210e8921d09195b1f90b99..a89421cdaa83a78a69a9fe93686a13579921b33b 100644 (file)
@@ -32,6 +32,7 @@ public class Ajc152Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void testStackOverflow_pr136258() { runTest("stack overflow");}
   public void testIncorrectOverridesEvaluation13() { runTest("incorrect overrides evaluation - 1.3"); }
   public void testIncorrectOverridesEvaluation15() { runTest("incorrect overrides evaluation - 1.5"); }
+  public void testAtWithinCodeBug_pr138798() { runTest("atWithinCodeBug"); }
 
   // known failures, uncomment when working.
   public void testReferencePCutInDeclareWarning_pr138215() { runTest("Reference pointcut fails inside @DeclareWarning");}
index 0d49de3718fe8aa8c37126fcb692b8a3420ec41f..b9ab6e94714de2a4233ad98c1aa0a90c7fce273b 100644 (file)
       <run class="StatisticsTypeImpl"/>
     </ajc-test>
     
+    <ajc-test dir="bugs152/pr138798" title="atWithinCodeBug">
+      <compile files="ErrorHandling.aj" options="-1.5"/>
+      <run class="ErrorHandling">
+         <stderr>
+           <line text="Caught in foo"/>
+         </stderr>
+      </run>      
+    </ajc-test>
+    
     <ajc-test dir="bugs152/pr138158" title="not at withincode - 1">
       <compile files="Boo.java" options="-1.5 -showWeaveInfo">
         <message kind="weave" text="Join point 'method-call(void Boo.m())' in Type 'Boo' (Boo.java:9) advised by before advice from 'X' (Boo.java:19)"/>