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 (tree of types).
25 */
26public class Clash4 {
27    public static void main(String[] args) {
28        InvocationHandler handler = new Clash4InvocationHandler();
29
30        try {
31            Proxy.newProxyInstance(Clash.class.getClassLoader(),
32                new Class[] {
33                    Interface4a.class,
34                    Interface4aa.class,
35                    Interface4base.class,
36                    Interface4b.class,
37                    Interface4bb.class },
38                handler);
39            System.err.println("Clash4 did not throw expected exception");
40        } catch (IllegalArgumentException iae) {
41            System.out.println("Clash4 threw expected exception");
42            //System.out.println(iae);
43        }
44    }
45}
46
47class R4base { int mBlah;  }
48class R4a extends R4base { int mBlah_a;  }
49class R4aa extends R4a { int mBlah_aa;  }
50class R4b extends R4base { int mBlah_b;  }
51class R4bb extends R4b { int mBlah_bb;  }
52
53interface Interface4base {
54    public R4base thisIsTrouble();
55}
56
57interface Interface4a {
58    public R4a thisIsTrouble();
59}
60interface Interface4aa {
61    public R4aa thisIsTrouble();
62}
63interface Interface4b {
64    public R4b thisIsTrouble();
65}
66interface Interface4bb {
67    public R4bb thisIsTrouble();
68}
69
70class Clash4InvocationHandler implements InvocationHandler {
71    /* don't really need to do anything -- should never get this far */
72    public Object invoke(Object proxy, Method method, Object[] args)
73        throws Throwable {
74
75        return null;
76    }
77}
78