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 
17 import java.lang.reflect.InvocationHandler;
18 import java.lang.reflect.InvocationTargetException;
19 import java.lang.reflect.Method;
20 import java.lang.reflect.Proxy;
21 
22 /*
23  * Try to instantiate a proxy class with interfaces that have conflicting
24  * duplicate methods (primitive types).
25  */
26 public class Clash2 {
main(String[] args)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 
41 interface Interface2A {
thisIsOkay()42     public int thisIsOkay();
43 
thisIsTrouble()44     public int thisIsTrouble();
45 }
46 
47 interface Interface2B {
thisIsOkay()48     public int thisIsOkay();
49 
thisIsTrouble()50     public short thisIsTrouble();
51 }
52 
53 class Clash2InvocationHandler implements InvocationHandler {
54     /* don't really need to do anything -- should never get this far */
invoke(Object proxy, Method method, Object[] args)55     public Object invoke(Object proxy, Method method, Object[] args)
56         throws Throwable {
57 
58         return null;
59     }
60 }
61