From 75a17318a97a8528c2604ada7ce159b3e46f12a6 Mon Sep 17 00:00:00 2001 From: aclement Date: Sun, 25 Jun 2006 18:50:54 +0000 Subject: testcode for 148545 --- tests/bugs152/pr148545/MyAnnotation.java | 7 +++++++ tests/bugs152/pr148545/MyAspect.java | 21 +++++++++++++++++++++ tests/bugs152/pr148545/MyClass.java | 14 ++++++++++++++ tests/bugs152/pr148545/MyEnum.java | 3 +++ tests/src/org/aspectj/systemtest/ajc152/ajc152.xml | 5 +++++ 5 files changed, 50 insertions(+) create mode 100644 tests/bugs152/pr148545/MyAnnotation.java create mode 100644 tests/bugs152/pr148545/MyAspect.java create mode 100644 tests/bugs152/pr148545/MyClass.java create mode 100644 tests/bugs152/pr148545/MyEnum.java diff --git a/tests/bugs152/pr148545/MyAnnotation.java b/tests/bugs152/pr148545/MyAnnotation.java new file mode 100644 index 000000000..309275641 --- /dev/null +++ b/tests/bugs152/pr148545/MyAnnotation.java @@ -0,0 +1,7 @@ +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface MyAnnotation { + MyEnum[] value(); +} \ No newline at end of file diff --git a/tests/bugs152/pr148545/MyAspect.java b/tests/bugs152/pr148545/MyAspect.java new file mode 100644 index 000000000..b42f52b25 --- /dev/null +++ b/tests/bugs152/pr148545/MyAspect.java @@ -0,0 +1,21 @@ +import java.util.Arrays; + +privileged public aspect MyAspect { + + Object around(MyClass o, MyAnnotation a) : + execution(@MyAnnotation * *(..)) && + target(o) && + @annotation(a) { + if (!isOneOf(o.getValue(), a.value())) + throw new IllegalStateException( + o.getValue() + + " is not one of " + + Arrays.toString(a.value())); + return proceed(o, a); + } + + private static final boolean isOneOf(T obj, T[] arr) { + for (T el : arr) if (obj == el) return true; + return false; + } +} \ No newline at end of file diff --git a/tests/bugs152/pr148545/MyClass.java b/tests/bugs152/pr148545/MyClass.java new file mode 100644 index 000000000..194e9b4b8 --- /dev/null +++ b/tests/bugs152/pr148545/MyClass.java @@ -0,0 +1,14 @@ +public class MyClass { + + public MyEnum getValue() { + return MyEnum.ONE; + } + + @MyAnnotation({ MyEnum.ONE, MyEnum.TWO }) + public void test() { + } + + public static void main(String[] args) { + new MyClass().test(); + } +} \ No newline at end of file diff --git a/tests/bugs152/pr148545/MyEnum.java b/tests/bugs152/pr148545/MyEnum.java new file mode 100644 index 000000000..cfbcb38b1 --- /dev/null +++ b/tests/bugs152/pr148545/MyEnum.java @@ -0,0 +1,3 @@ +public enum MyEnum { + ONE, TWO, THREE, FOUR, FIVE +} \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml index aba07f7bc..4c916532a 100644 --- a/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml +++ b/tests/src/org/aspectj/systemtest/ajc152/ajc152.xml @@ -112,6 +112,11 @@ + + + + + -- cgit v1.2.3