diff options
author | aclement <aclement> | 2006-02-21 16:13:44 +0000 |
---|---|---|
committer | aclement <aclement> | 2006-02-21 16:13:44 +0000 |
commit | 3fa1bddb79a5e20a38cb39555e932df46f3d4dfa (patch) | |
tree | 2e20f46bb85f4f9ac9d69d15f9942a7a507739ac /tests/bugs151/pr122742 | |
parent | 89d66dc89110db0f89538a7b78308db61e5539cc (diff) | |
download | aspectj-3fa1bddb79a5e20a38cb39555e932df46f3d4dfa.tar.gz aspectj-3fa1bddb79a5e20a38cb39555e932df46f3d4dfa.zip |
test and fix for 122742 (more @AJ thisJoinPoint problems...)
Diffstat (limited to 'tests/bugs151/pr122742')
-rw-r--r-- | tests/bugs151/pr122742/AfterReturningTest.java | 52 | ||||
-rw-r--r-- | tests/bugs151/pr122742/AfterThrowingTest.java | 50 |
2 files changed, 102 insertions, 0 deletions
diff --git a/tests/bugs151/pr122742/AfterReturningTest.java b/tests/bugs151/pr122742/AfterReturningTest.java new file mode 100644 index 000000000..9ec10a43e --- /dev/null +++ b/tests/bugs151/pr122742/AfterReturningTest.java @@ -0,0 +1,52 @@ +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterReturning; +import org.aspectj.lang.annotation.Aspect; + +@Aspect +public class AfterReturningTest { + + public static void main(String[] args) { + new B1().start(); + } + + // include "JoinPoint" in the argument list + @AfterReturning(pointcut = "execution(public B1 B1.start())", returning = "r") + public void afterJP(JoinPoint jp, B1 r) { + r.stop(); + } + + // include "JoinPoint.StaticPart" in the argument list + @AfterReturning(pointcut = "execution(public B1 B1.start())", returning = "r") + public void afterJPSP(JoinPoint.StaticPart jp, B1 r) { + r.stop(); + } + + // include "JoinPoint.EnclosingStaticPart" in the argument list + @AfterReturning(pointcut = "execution(public B1 B1.start())", returning = "r") + public void afterJPESP(JoinPoint.EnclosingStaticPart jp, B1 r) { + r.stop(); + } + + // include "JoinPoint and JoinPoint.EnclosingStaticPart" in the argument list + @AfterReturning(pointcut = "execution(public B1 B1.start())", returning = "r") + public void afterJPESP2(JoinPoint jp1, JoinPoint.EnclosingStaticPart jp, B1 r) { + r.stop(); + } + + // make sure it still works if "JoinPoint" is second in the argument list + @AfterReturning(pointcut = "execution(public B1 B1.start())", returning = "r") + public void afterJP2(B1 r, JoinPoint jp) { + r.stop(); + } +} + +class B1 { + + public B1 start() { + return new B1(); + } + + public void stop() { + } + +} diff --git a/tests/bugs151/pr122742/AfterThrowingTest.java b/tests/bugs151/pr122742/AfterThrowingTest.java new file mode 100644 index 000000000..449893e37 --- /dev/null +++ b/tests/bugs151/pr122742/AfterThrowingTest.java @@ -0,0 +1,50 @@ +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Aspect; + +@Aspect +public class AfterThrowingTest { + + public static void main(String[] args) { + try { + new B().start(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + // include "JoinPoint" in the argument list + @AfterThrowing(pointcut = "execution(public void B.start())", throwing = "ex") + public void handleExceptionJP(JoinPoint jp, Exception ex) { + } + + // include "JoinPoint.StaticPart" in the argument list + @AfterThrowing(pointcut = "execution(public void B.start())", throwing = "ex") + public void handleExceptionJPSP(JoinPoint.StaticPart jp, Exception ex) { + } + + // include "JoinPoint.EnclosingStaticPart" in the argument list + @AfterThrowing(pointcut = "execution(public void B.start())", throwing = "ex") + public void handleExceptionJPESP(JoinPoint.EnclosingStaticPart jp, Exception ex) { + } + + // include "JoinPoint" and "JoinPoint.EnclosingStaticPart" in the argument list + @AfterThrowing(pointcut = "execution(public void B.start())", throwing = "ex") + public void handleExceptionJPESP(JoinPoint jp1, JoinPoint.EnclosingStaticPart jp, Exception ex) { + } + + // make sure it still works if "JoinPoint" is second on the argument list + @AfterThrowing(pointcut = "execution(public void B.start())", throwing = "ex") + public void handleExceptionJP2(JoinPoint jp, Exception ex) { + } +} + +class B implements I { + public void start() throws Exception { + throw new IllegalArgumentException(); + } +} + +interface I { + public void start() throws Exception; +} |