01: /*
02: * MethodInvoker5.java --
03: *
04: * tcljava/tests/signature/MethodInvoker5.java
05: *
06: * Copyright (c) 1998 by Moses DeJong
07: *
08: * See the file "license.terms" for information on usage and redistribution
09: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10: *
11: * RCS: @(#) $Id: MethodInvoker5.java,v 1.2 2002/12/27 14:33:20 mdejong Exp $
12: *
13: */
14:
15: package tests.signature;
16:
17: import java.util.*;
18:
19: public class MethodInvoker5 {
20:
21: public static String call(A obj) {
22: return "A";
23: }
24:
25: public static String call(I obj) {
26: return "I";
27: }
28:
29: public static String call(I2 obj) {
30: return "I2";
31: }
32:
33: public static interface I {
34: }
35:
36: public static interface I2 extends I {
37: }
38:
39: public static interface I3 extends I2 {
40: }
41:
42: private static class A {
43: }
44:
45: private static class B implements I {
46: }
47:
48: private static class C implements I2 {
49: }
50:
51: private static class D implements I3 {
52: }
53:
54: public static I getI() {
55: return new B();
56: }
57:
58: public static I2 getI2() {
59: return new C();
60: }
61:
62: public static I3 getI3() {
63: return new D();
64: }
65:
66: //this test determines if the method lookup system
67: //is correctly handling cases where interfaces
68: //are used. an overloaded function that
69: //could accept and interface that it directly implements
70: //or it could also take a superclass of B
71:
72: public static void main(String[] argv) {
73:
74: I i = getI();
75: I2 i2 = getI2();
76: I3 i3 = getI3();
77:
78: String s;
79:
80: s = call(i); //should return "I"
81: p(s);
82:
83: s = call(i2); //should return "I2"
84: p(s);
85:
86: s = call(i3); //should return "I2"
87: p(s);
88:
89: }
90:
91: public static void p(String arg) {
92: System.out.println(arg);
93: }
94:
95: }
|