2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 import java.lang.reflect.InvocationHandler;
18 import java.lang.reflect.InvocationTargetException;
19 import java.lang.reflect.Method;
20 import java.lang.reflect.Proxy;
23 * Try to instantiate a proxy class with interfaces that have conflicting
24 * duplicate methods (primitive types).
27 public static void main(String[] args) {
28 InvocationHandler handler = new Clash2InvocationHandler();
31 Proxy.newProxyInstance(Clash.class.getClassLoader(),
32 new Class[] { Interface2A.class, Interface2B.class },
34 System.err.println("Clash2 did not throw expected exception");
35 } catch (IllegalArgumentException iae) {
36 System.out.println("Clash2 threw expected exception");
41 interface Interface2A {
42 public int thisIsOkay();
44 public int thisIsTrouble();
47 interface Interface2B {
48 public int thisIsOkay();
50 public short thisIsTrouble();
53 class 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)