--- /dev/null
+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;
+ }
+ }
+
+}
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");}
<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)"/>