From 6ba1097458b56cdf0aa274a46da5dd2af0302d36 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 8 Jun 2005 15:17:20 +0000 Subject: [PATCH] Tests for 98901: annotation copying on public ITDs --- tests/java5/annotations/itds/AtItd4.aj | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/java5/annotations/itds/AtItd4.aj 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); + } + } + +} -- 2.39.5