jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 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 (type tree with interface). |
| 25 | */ |
| 26 | public class Clash3 { |
| 27 | public static void main(String[] args) { |
| 28 | InvocationHandler handler = new Clash3InvocationHandler(); |
| 29 | |
| 30 | try { |
| 31 | Proxy.newProxyInstance(Clash.class.getClassLoader(), |
Andreas Gampe | 166aaee | 2016-07-18 08:27:23 -0700 | [diff] [blame] | 32 | new Class<?>[] { |
jeffhao | 5d1ac92 | 2011-09-29 17:41:15 -0700 | [diff] [blame] | 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 | |
| 45 | class R3base implements I3 { int mBlah; public void x() {} } |
| 46 | class R3a extends R3base { int mBlah_a; } |
| 47 | class R3aa extends R3a { int mBlah_aa; } |
| 48 | class R3b implements I3 { int mBlah_b; public void x() {} } |
| 49 | |
| 50 | interface I3 { |
| 51 | void x(); |
| 52 | } |
| 53 | |
| 54 | interface Interface3base { |
| 55 | public R3base thisIsTrouble(); |
| 56 | } |
| 57 | |
| 58 | interface Interface3a { |
| 59 | public R3a thisIsTrouble(); |
| 60 | } |
| 61 | interface Interface3aa { |
| 62 | public R3aa thisIsTrouble(); |
| 63 | } |
| 64 | interface Interface3b { |
| 65 | public R3b thisIsTrouble(); |
| 66 | } |
| 67 | |
| 68 | class 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 | } |