aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs170/xmldefs/Hello6.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bugs170/xmldefs/Hello6.java')
-rw-r--r--tests/bugs170/xmldefs/Hello6.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/bugs170/xmldefs/Hello6.java b/tests/bugs170/xmldefs/Hello6.java
new file mode 100644
index 000000000..568a5b46e
--- /dev/null
+++ b/tests/bugs170/xmldefs/Hello6.java
@@ -0,0 +1,41 @@
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.*;
+
+public class Hello6 {
+
+ public static int field1;
+
+ public static void main(String[] args) {
+ printAnnos("field1");
+ }
+
+ public static void printAnnos(String fieldname) {
+ try {
+ Field m = Hello6.class.getDeclaredField(fieldname);
+ Annotation[] annos = m.getAnnotations();
+ System.out.println("Annotations on "+fieldname+"? "+(annos!=null && annos.length!=0));
+ if (annos!=null && annos.length>0) {
+ List<Annotation> la = new ArrayList<Annotation>();
+ for (Annotation anno: annos) {
+ la.add(anno);
+ }
+ Collections.<Annotation>sort(la,new AnnoComparator());
+
+ System.out.println("Annotation count is "+annos.length);
+ for (Annotation anno: la) {
+ System.out.println(anno);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ static class AnnoComparator implements Comparator<Annotation> {
+ public int compare(Annotation a, Annotation b) {
+ return a.toString().compareTo(b.toString());
+ }
+ }
+}