1 // Test various reflection methods.
2 
3 import java.lang.annotation.Inherited;
4 import java.lang.reflect.Method;
5 import java.lang.reflect.Field;
6 
7 public class PR29495
8 {
9   public class container<T>
10   {
11     // This class has a synthetic field...
12 
get(T v)13     public T get(T v) { return v; }
14   }
15 
16   public class concrete extends container<String>
17   {
18     // This makes us have a synthetic bridge method.
get(String v)19     public String get(String v) { return "hi" + v; }
20   }
21 
22   // varargs method
va(Object... args)23   public static void va(Object... args)
24   {
25   }
26 
check(boolean x, String m)27   public static void check(boolean x, String m)
28   {
29     if (! x)
30       System.out.println("fail: " + m);
31   }
32 
main(String[] args)33   public static void main(String[] args) throws Throwable
34   {
35     check (Inherited.class.isAnnotation(), "Inherited isAnnotation");
36 
37     Method m = PR29495.class.getDeclaredMethod("va", new Class[] { Object[].class });
38     check (m.isVarArgs(), "va isVarArgs");
39 
40     m = concrete.class.getDeclaredMethod("get", new Class[] { Object.class });
41     check (m.isSynthetic(), "get isSynthetic");
42     check (m.isBridge(), "get isBridge");
43 
44     Field[] fs = container.class.getDeclaredFields();
45     boolean ok = false;
46     for (int i = 0; i < fs.length; ++i)
47       {
48 	if (fs[i].isSynthetic())
49 	  {
50 	    ok = true;
51 	    break;
52 	  }
53       }
54     check (ok, "container has synthetic field");
55   }
56 }
57