]> source.dussan.org Git - aspectj.git/commitdiff
testcode for 148545
authoraclement <aclement>
Sun, 25 Jun 2006 18:50:54 +0000 (18:50 +0000)
committeraclement <aclement>
Sun, 25 Jun 2006 18:50:54 +0000 (18:50 +0000)
tests/bugs152/pr148545/MyAnnotation.java [new file with mode: 0644]
tests/bugs152/pr148545/MyAspect.java [new file with mode: 0644]
tests/bugs152/pr148545/MyClass.java [new file with mode: 0644]
tests/bugs152/pr148545/MyEnum.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc152/ajc152.xml

diff --git a/tests/bugs152/pr148545/MyAnnotation.java b/tests/bugs152/pr148545/MyAnnotation.java
new file mode 100644 (file)
index 0000000..3092756
--- /dev/null
@@ -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 (file)
index 0000000..b42f52b
--- /dev/null
@@ -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 (file)
index 0000000..194e9b4
--- /dev/null
@@ -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 (file)
index 0000000..cfbcb38
--- /dev/null
@@ -0,0 +1,3 @@
+public enum MyEnum {
+        ONE, TWO, THREE, FOUR, FIVE
+}
\ No newline at end of file
index aba07f7bc99c4f32806142f2b5f6d5a07a0b56a8..4c916532ae0f14196dc3a59f4bc08e9a6c4d8fca 100644 (file)
        <ajc-test dir="bugs152/pr148537" title="classcast annotation value">
      <compile files="MyClass.java,MyAspect.java" options="-1.5"/>
     </ajc-test>
+    
+       <ajc-test dir="bugs152/pr148545" title="nosuchmethoderror for privileged aspect">
+     <compile files="MyClass.java,MyAspect.java,MyAnnotation.java,MyEnum.java" options="-1.5"/>
+     <run class="MyClass"/>
+    </ajc-test>
 
        <ajc-test dir="bugs152/pr145391" title="itd calling generic method - 2">
      <compile files="GenericType2.java" options="-1.5"/>