Clash3.java revision 89c1feb0a69a7707b271086e749975b3f7acacf7
1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17import java.lang.reflect.InvocationHandler;
18import java.lang.reflect.InvocationTargetException;
19import java.lang.reflect.Method;
20import java.lang.reflect.Proxy;
21
22/*
23 * Try to instantiate a proxy class with interfaces that have conflicting
24 * duplicate methods (type tree with interface).
25 */
26public class Clash3 {
27    public static void main(String[] args) {
28        InvocationHandler handler = new Clash3InvocationHandler();
29
30        try {
31            Proxy.newProxyInstance(Clash.class.getClassLoader(),
32                new Class[] {
33                    Interface3a.class,
34                    Interface3base.class,
35                    Interface3aa.class,
36                    Interface3b.class },
37                handler);
38            System.err.println("Clash3 did not throw expected exception");
39        } catch (IllegalArgumentException iae) {
40            System.out.println("Clash3 threw expected exception");
41        }
42    }
43}
44
45class R3base implements I3 { int mBlah; public void x() {} }
46class R3a extends R3base { int mBlah_a;  }
47class R3aa extends R3a { int mBlah_aa;  }
48class R3b implements I3 { int mBlah_b; public void x() {} }
49
50interface I3 {
51    void x();
52}
53
54interface Interface3base {
55    public R3base thisIsTrouble();
56}
57
58interface Interface3a {
59    public R3a thisIsTrouble();
60}
61interface Interface3aa {
62    public R3aa thisIsTrouble();
63}
64interface Interface3b {
65    public R3b thisIsTrouble();
66}
67
68class Clash3InvocationHandler implements InvocationHandler {
69    /* don't really need to do anything -- should never get this far */
70    public Object invoke(Object proxy, Method method, Object[] args)
71        throws Throwable {
72
73        return null;
74    }
75}
76
77