aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs152
diff options
context:
space:
mode:
authoraclement <aclement>2006-06-25 18:50:54 +0000
committeraclement <aclement>2006-06-25 18:50:54 +0000
commit75a17318a97a8528c2604ada7ce159b3e46f12a6 (patch)
tree0a7635f5a7fef0de63cef00174937e206a29c480 /tests/bugs152
parent045e82d5cebc9c9674ac71cffa3fefc34eeb042f (diff)
downloadaspectj-75a17318a97a8528c2604ada7ce159b3e46f12a6.tar.gz
aspectj-75a17318a97a8528c2604ada7ce159b3e46f12a6.zip
testcode for 148545
Diffstat (limited to 'tests/bugs152')
-rw-r--r--tests/bugs152/pr148545/MyAnnotation.java7
-rw-r--r--tests/bugs152/pr148545/MyAspect.java21
-rw-r--r--tests/bugs152/pr148545/MyClass.java14
-rw-r--r--tests/bugs152/pr148545/MyEnum.java3
4 files changed, 45 insertions, 0 deletions
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 <T> 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