2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / testsuite / libjava.lang / InvokeReturn.java
blob9263dbe404d5c50e83c4f9c15d256ebc70f08504
1 import java.lang.reflect.Method;
3 // Test return values of Method.invoke.
4 public class InvokeReturn {
5 public boolean bTrue() {
6 return true;
9 public boolean bFalse() {
10 return false;
13 public char cc() {
14 return 'c';
17 public short s5() {
18 return (short)5;
21 public int i6() {
22 return 6;
25 public long l7() {
26 return (long)7;
29 public float f8() {
30 return (float)8.0;
33 public double d9() {
34 return 9.0;
37 public static void main(String[] args) {
38 try {
39 Object o = new InvokeReturn();
40 Method m;
42 // test boolean result
43 m = o.getClass().getDeclaredMethod("bTrue", new Class[0]);
44 System.out.println(m.invoke(o, new Object[0]));
46 m = o.getClass().getDeclaredMethod("bFalse", new Class[0]);
47 System.out.println(m.invoke(o, new Object[0]));
49 // test char result
50 m = o.getClass().getDeclaredMethod("cc", new Class[0]);
51 System.out.println(m.invoke(o, new Object[0]));
53 // test short result
54 m = o.getClass().getDeclaredMethod("s5", new Class[0]);
55 System.out.println(m.invoke(o, new Object[0]));
57 // test int result
58 m = o.getClass().getDeclaredMethod("i6", new Class[0]);
59 System.out.println(m.invoke(o, new Object[0]));
61 // test long result
62 m = o.getClass().getDeclaredMethod("l7", new Class[0]);
63 System.out.println(m.invoke(o, new Object[0]));
65 // test float result
66 m = o.getClass().getDeclaredMethod("f8", new Class[0]);
67 System.out.println(m.invoke(o, new Object[0]));
69 // test double result
70 m = o.getClass().getDeclaredMethod("d9", new Class[0]);
71 System.out.println(m.invoke(o, new Object[0]));
72 } catch (UnsupportedOperationException e) {
73 // We get this on targets which don't support reflection (no
74 // libffi port yet). We might as well fake PASSes.
75 System.out.println("true\nfalse\nc\n5\n6\n7\n8.0\n9.0");
76 } catch (Throwable t) {
77 t.printStackTrace();