Browse Source

testcode for 148545

tags/V1_5_2rc1
aclement 18 years ago
parent
commit
75a17318a9

+ 7
- 0
tests/bugs152/pr148545/MyAnnotation.java View File

@@ -0,0 +1,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
MyEnum[] value();
}

+ 21
- 0
tests/bugs152/pr148545/MyAspect.java View File

@@ -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;
}
}

+ 14
- 0
tests/bugs152/pr148545/MyClass.java View File

@@ -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();
}
}

+ 3
- 0
tests/bugs152/pr148545/MyEnum.java View File

@@ -0,0 +1,3 @@
public enum MyEnum {
ONE, TWO, THREE, FOUR, FIVE
}

+ 5
- 0
tests/src/org/aspectj/systemtest/ajc152/ajc152.xml View File

@@ -112,6 +112,11 @@
<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"/>

Loading…
Cancel
Save