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 (primitive types).
25 */
26public class Clash2 {
27    public static void main(String[] args) {
28        InvocationHandler handler = new Clash2InvocationHandler();
29
30        try {
31            Proxy.newProxyInstance(Clash.class.getClassLoader(),
32                new Class<?>[] { Interface2A.class, Interface2B.class },
33                handler);
34            System.out.println("Clash2 did not throw expected exception");
35        } catch (IllegalArgumentException iae) {
36            System.out.println("Clash2 threw expected exception");
37        }
38    }
39}
40
41interface Interface2A {
42    public int thisIsOkay();
43
44    public int thisIsTrouble();
45}
46
47interface Interface2B {
48    public int thisIsOkay();
49
50    public short thisIsTrouble();
51}
52
53class Clash2InvocationHandler implements InvocationHandler {
54    /* don't really need to do anything -- should never get this far */
55    public Object invoke(Object proxy, Method method, Object[] args)
56        throws Throwable {
57
58        return null;
59    }
60}
61