1 import java.lang.reflect.*;
2 
3 interface one
4 {
n(int N)5   int n(int N);
6 }
7 
8 interface two
9 {
nn(int N)10   int nn(int N);
11 }
12 
13 interface three
14 {
nnn(int N)15   int nnn(int N);
16 }
17 
18 class arse implements one, two
19 {
n(int N)20   public int n(int N) { return N; }
nn(int N)21   public int nn(int N) { return N*2; }
22 }
23 
24 class arsey implements two, one, three
25 {
n(int N)26   public int n(int N) { return N*4; }
nn(int N)27   public int nn(int N) { return N*8; }
nnn(int N)28   public int nnn(int N) { return N*16; }
29 }
30 
31 public class InvokeInterface extends arse
32 {
f()33   int f ()
34   {
35 	return flunk.nn(1);
36   }
37   static two flunk = new arse();
38   static three flunkey = new arsey();
main(String[] s)39   public static void main(String[] s) throws Throwable
40   {
41 	Class[] argtypes = {Integer.TYPE};
42 	Method m = two.class.getMethod("nn", argtypes);
43 	Object[] args = {new Integer(1)};
44 	System.out.println(flunk.nn(1));
45 	System.out.println(m.invoke(new arse(), args));
46 	m = arse.class.getMethod("nn", argtypes);
47 	System.out.println(m.invoke(new arse(), args));
48 	m = two.class.getMethod("nn", argtypes);
49 	System.out.println(m.invoke(new arsey(), args));
50 	m = three.class.getMethod("nnn", argtypes);
51 	System.out.println(m.invoke(new arsey(), args));
52 	m = arsey.class.getMethod("nnn", argtypes);
53 	System.out.println(m.invoke(new arsey(), args));
54   }
55 }
56