GNU header update.
[cacao.git] / tests / kaffe / ReflectInterfaces.java
1 /*
2  * The Art of Reflecting Interfaces.
3  */
4 import java.lang.reflect.Method;
5
6 public class ReflectInterfaces
7 {
8         interface If1
9         {
10                 public void if1Method();
11                 void if1MethodNP();
12         }
13
14         interface If2 extends If1
15         {
16                 public void if2Method();
17                 void if2MethodNP();
18         }
19
20         public static void main(String av[])
21         {
22                 Class c = If2.class;
23                 Class sc = c.getSuperclass();
24                 System.out.println((sc == null?"null":sc.getName()));
25                 System.out.println("all methods");
26                 Method [] m = c.getMethods();
27                 for (int i = 0; i < m.length; i++)
28                         System.out.println(m[i].toString());
29                 System.out.println("declared methods");
30                 m = c.getDeclaredMethods();
31                 for (int i = 0; i < m.length; i++)
32                         System.out.println(m[i].toString());
33         }
34 }
35
36 // Sort Output
37
38 /* Expected Output:
39 all methods
40 declared methods
41 null
42 public abstract void ReflectInterfaces$If1.if1Method()
43 public abstract void ReflectInterfaces$If1.if1MethodNP()
44 public abstract void ReflectInterfaces$If2.if2Method()
45 public abstract void ReflectInterfaces$If2.if2Method()
46 public abstract void ReflectInterfaces$If2.if2MethodNP()
47 public abstract void ReflectInterfaces$If2.if2MethodNP()
48 */