From d78d9ed48963cf302c26daab6af782d9b01ea3ac Mon Sep 17 00:00:00 2001 From: jhugunin Date: Wed, 10 Sep 2003 00:35:18 +0000 Subject: fix and tests for at least 2 bugs: Bugzilla Bug 42740 declare error fails on pointcuts composed from multiple classes Bugzilla Bug 42746 within() pcd is confused for certain declare softs and probably: Bugzilla Bug 42739 Compiler crash in ajc head (post 1.1.1 rc1) --- tests/ajcTests.xml | 15 ++++++++++++ .../declareBinding/SampleExceptionHandling1.java | 21 +++++++++++++++++ tests/bugs/declareSoftWithin/aspects/Softener.aj | 18 +++++++++++++++ tests/bugs/declareSoftWithin/test/NoSoftener.java | 27 ++++++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 tests/bugs/declareBinding/SampleExceptionHandling1.java create mode 100644 tests/bugs/declareSoftWithin/aspects/Softener.aj create mode 100644 tests/bugs/declareSoftWithin/test/NoSoftener.java (limited to 'tests') diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml index fc5537889..a50e6940d 100644 --- a/tests/ajcTests.xml +++ b/tests/ajcTests.xml @@ -6736,4 +6736,19 @@ + + + + + + + + + + + diff --git a/tests/bugs/declareBinding/SampleExceptionHandling1.java b/tests/bugs/declareBinding/SampleExceptionHandling1.java new file mode 100644 index 000000000..4b5e4ae48 --- /dev/null +++ b/tests/bugs/declareBinding/SampleExceptionHandling1.java @@ -0,0 +1,21 @@ +public class SampleExceptionHandling1 { + public void mumble() throws java.io.IOException { } // CE expected +} + + +/** @author Ron Bodkin */ +aspect Library { + public pointcut executionsThrowingChecked() : + execution(* *(..) throws (Exception+ && !RuntimeException)); +} + +/** @author Ron Bodkin */ +aspect SampleExceptionHandling { + public pointcut scope() : within(SampleExceptionHandling1); + + public pointcut executionsThrowingChecked() : + Library.executionsThrowingChecked() && scope(); + + declare error : executionsThrowingChecked(): + "no checked exceptions"; +} \ No newline at end of file diff --git a/tests/bugs/declareSoftWithin/aspects/Softener.aj b/tests/bugs/declareSoftWithin/aspects/Softener.aj new file mode 100644 index 000000000..21eee34b6 --- /dev/null +++ b/tests/bugs/declareSoftWithin/aspects/Softener.aj @@ -0,0 +1,18 @@ +package aspects; + +import test.NoSoftener; + +/** + * @author Ron Bodkin + * @author Jim Hugunin + */ +public aspect Softener extends SoftLib { + public pointcut scope() : within(NoSoftener); +} + +abstract aspect SoftLib { + abstract pointcut scope(); + + public pointcut callsThrowingChecked() : call(* *(..)) && scope(); + declare soft: NoSuchMethodException: callsThrowingChecked(); +} \ No newline at end of file diff --git a/tests/bugs/declareSoftWithin/test/NoSoftener.java b/tests/bugs/declareSoftWithin/test/NoSoftener.java new file mode 100644 index 000000000..5d082c199 --- /dev/null +++ b/tests/bugs/declareSoftWithin/test/NoSoftener.java @@ -0,0 +1,27 @@ +package test; +import java.lang.reflect.Constructor; +import org.aspectj.testing.Tester; + +/** + * @author Ron Bodkin + * @author Jim Hugunin + */ +public class NoSoftener { + public static void main(String[] args) { + Throwable wrapped = null; + try { + new NoSoftener().foo(Integer.class); + } catch (org.aspectj.lang.SoftException se) { + wrapped = se.getWrappedThrowable(); + } + Tester.checkNonNull(wrapped, "exception thrown"); + Tester.check(wrapped instanceof NoSuchMethodException, + "must be NoSuchMethodException"); + + } + + public void foo(Class clazz) { + Class[] keyArgType = {}; + Constructor ctor = clazz.getConstructor(keyArgType); + } +} \ No newline at end of file -- cgit v1.2.3