author | ohair |
Tue, 28 Dec 2010 15:53:50 -0800 | |
changeset 7668 | d4a77089c587 |
parent 5808 | 3a1f603c5ca7 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
7668 | 2 |
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2 | 22 |
*/ |
23 |
||
24 |
/* @test |
|
25 |
* @bug 4838310 |
|
26 |
* @summary This test verifies that the restrictions on proxy interface |
|
27 |
* methods with the same signature but different return types are |
|
28 |
* correctly enforced. |
|
29 |
* @author Peter Jones |
|
30 |
* |
|
31 |
* @build GetObject GetSerializable GetCloneable GetArray |
|
32 |
* @run main Test |
|
33 |
*/ |
|
34 |
||
35 |
import java.lang.reflect.Proxy; |
|
36 |
import java.security.PrivilegedAction; |
|
37 |
import java.util.Arrays; |
|
38 |
import java.util.Collection; |
|
39 |
import java.util.List; |
|
40 |
||
41 |
public class Test { |
|
42 |
||
43 |
// additional test cases may be added to both of these lists: |
|
44 |
||
5808
3a1f603c5ca7
6961894: TEST_BUG: jdk_lang tests fail in samevm mode
mchung
parents:
5506
diff
changeset
|
45 |
private static final Class<?>[][] GOOD = { |
2 | 46 |
{ Collection.class }, |
47 |
{ Iterable.class, Collection.class }, |
|
48 |
{ Iterable.class, Collection.class, List.class }, |
|
49 |
{ GetSerializable.class, GetCloneable.class, GetArray.class }, |
|
50 |
{ GetObject.class, GetSerializable.class, GetCloneable.class, |
|
51 |
GetArray.class } |
|
52 |
}; |
|
53 |
||
5808
3a1f603c5ca7
6961894: TEST_BUG: jdk_lang tests fail in samevm mode
mchung
parents:
5506
diff
changeset
|
54 |
private static final Class<?>[][] BAD = { |
2 | 55 |
{ Runnable.class, PrivilegedAction.class }, |
56 |
{ GetSerializable.class, GetCloneable.class }, |
|
57 |
{ GetObject.class, GetSerializable.class, GetCloneable.class } |
|
58 |
}; |
|
59 |
||
60 |
public static void main(String[] args) throws Exception { |
|
61 |
System.err.println("\nRegression test for bug 4838310\n"); |
|
62 |
||
5808
3a1f603c5ca7
6961894: TEST_BUG: jdk_lang tests fail in samevm mode
mchung
parents:
5506
diff
changeset
|
63 |
ClassLoader loader = Test.class.getClassLoader(); |
2 | 64 |
|
65 |
System.err.println("Testing GOOD combinations:"); |
|
66 |
||
67 |
for (int i = 0; i < GOOD.length; i++) { |
|
5808
3a1f603c5ca7
6961894: TEST_BUG: jdk_lang tests fail in samevm mode
mchung
parents:
5506
diff
changeset
|
68 |
Class<?>[] interfaces = GOOD[i]; |
2 | 69 |
System.err.println(Arrays.asList(interfaces)); |
70 |
Proxy.getProxyClass(loader, interfaces); |
|
71 |
System.err.println("--- OK."); |
|
72 |
} |
|
73 |
||
74 |
System.err.println("Testing BAD combinations:"); |
|
75 |
||
76 |
for (int i = 0; i < BAD.length; i++) { |
|
5808
3a1f603c5ca7
6961894: TEST_BUG: jdk_lang tests fail in samevm mode
mchung
parents:
5506
diff
changeset
|
77 |
Class<?>[] interfaces = BAD[i]; |
2 | 78 |
System.err.println(Arrays.asList(interfaces)); |
79 |
try { |
|
80 |
Proxy.getProxyClass(loader, interfaces); |
|
81 |
throw new RuntimeException( |
|
82 |
"TEST FAILED: bad combination succeeded"); |
|
83 |
} catch (IllegalArgumentException e) { |
|
84 |
e.printStackTrace(); |
|
85 |
System.err.println("--- OK."); |
|
86 |
} |
|
87 |
} |
|
88 |
||
89 |
System.err.println("TEST PASSED"); |
|
90 |
} |
|
91 |
} |