diff options
author | aclement <aclement> | 2005-06-08 15:17:20 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-06-08 15:17:20 +0000 |
commit | 6ba1097458b56cdf0aa274a46da5dd2af0302d36 (patch) | |
tree | fbb18eedb7be9b0b8fc42b0d83759f14372491f3 | |
parent | 58e58e1e2c53d4b4e3bca0e26ec5e7eddf984d50 (diff) | |
download | aspectj-6ba1097458b56cdf0aa274a46da5dd2af0302d36.tar.gz aspectj-6ba1097458b56cdf0aa274a46da5dd2af0302d36.zip |
Tests for 98901: annotation copying on public ITDs
-rw-r--r-- | tests/java5/annotations/itds/AtItd4.aj | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/java5/annotations/itds/AtItd4.aj b/tests/java5/annotations/itds/AtItd4.aj new file mode 100644 index 000000000..5484406e0 --- /dev/null +++ b/tests/java5/annotations/itds/AtItd4.aj @@ -0,0 +1,46 @@ +import java.lang.annotation.*; +import java.lang.reflect.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface Ann { + String id() default "hello"; + int anInt() default 5; + long aLong() default 6; + String[] strings() default {"c","d"}; + SimpleEnum enumval() default SimpleEnum.B; +} + +enum SimpleEnum { A,B,C } + +aspect X { + @Ann(id="goodbye",anInt=4,enumval=SimpleEnum.A,strings={"a","b"}) public void AtItd4.m() {} + //@Ann(enumval=SimpleEnum.A) public void AtItd4.m() {} +} + +public class AtItd4 { + public static void main(String []argv) { + try { + Method m = AtItd4.class.getDeclaredMethod("m",null); + System.err.println("Method is "+m); + Annotation[] as = m.getDeclaredAnnotations(); + System.err.println("Number of annotations "+ + (as==null?"0":new Integer(as.length).toString())); + Annotation aa = m.getAnnotation(Ann.class); + System.err.println("Ann.class retrieved is: "+aa); + + String exp = + "@Ann(strings=[a, b], enumval=A, aLong=6, id=goodbye, anInt=4)"; + + if (!aa.toString().equals(exp)) + throw new RuntimeException("Incorrect output, expected:"+exp+ + " but got "+aa.toString()); + + if (as.length==0) + throw new RuntimeException("Couldn't find annotation on member!"); + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + +} |