author | lfoltan |
Tue, 20 Feb 2018 07:46:40 -0500 | |
changeset 49026 | 844bf1deff1a |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
4156 | 1 |
/* |
30376
2ccf2cf7ea48
8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. |
4156 | 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. |
|
4156 | 22 |
*/ |
23 |
||
1512
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
24 |
/* |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
25 |
* @test |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
26 |
* @bug 6713777 |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
27 |
* @summary Test that exception messages include all relevant information |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
28 |
* @author Eamonn McManus |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
29 |
*/ |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
30 |
|
33499
d4f084ec39eb
8139727: Define ConstructorParameters annotation type for MXBeans
jbachorik
parents:
33316
diff
changeset
|
31 |
import javax.management.ConstructorParameters; |
1512
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
32 |
import java.io.File; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
33 |
import java.lang.reflect.InvocationTargetException; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
34 |
import java.lang.reflect.Method; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
35 |
import java.lang.reflect.Type; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
36 |
import java.util.ArrayList; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
37 |
import java.util.HashMap; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
38 |
import java.util.List; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
39 |
import javax.management.JMX; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
40 |
import javax.management.MBeanServer; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
41 |
import javax.management.MBeanServerFactory; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
42 |
import javax.management.NotCompliantMBeanException; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
43 |
import javax.management.ObjectName; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
44 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
45 |
public class ExceptionDiagnosisTest { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
46 |
private static volatile String failure; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
47 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
48 |
// ------ Illegal MXBeans ------ |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
49 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
50 |
// Test that all of BdelloidMXBean, Rotifer, and File appear in the |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
51 |
// exception messages. File is not an allowed type because of recursive |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
52 |
// getters like "File getParentFile()". |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
53 |
public static interface BdelloidMXBean { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
54 |
public Rotifer getRotifer(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
55 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
56 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
57 |
public static class Bdelloid implements BdelloidMXBean { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
58 |
public Rotifer getRotifer() { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
59 |
return null; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
60 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
61 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
62 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
63 |
public static class Rotifer { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
64 |
public File getFile() { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
65 |
return null; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
66 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
67 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
68 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
69 |
// Test that all of IndirectHashMapMXBean, HashMapContainer, and |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
70 |
// HashMap<String,String> appear in the exception messages. |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
71 |
// HashMap<String,String> is not an allowed type because only the |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
72 |
// java.util interface such as Map are allowed with generic parameters, |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
73 |
// not their concrete implementations like HashMap. |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
74 |
public static interface IndirectHashMapMXBean { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
75 |
public HashMapContainer getContainer(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
76 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
77 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
78 |
public static class IndirectHashMap implements IndirectHashMapMXBean { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
79 |
public HashMapContainer getContainer() { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
80 |
return null; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
81 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
82 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
83 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
84 |
public static class HashMapContainer { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
85 |
public HashMap<String, String> getHashMap() {return null;} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
86 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
87 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
88 |
// ------ MXBeans that are legal but where proxies are not ------ |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
89 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
90 |
// Test that all of BlimMXBean, BlimContainer, Blim, and Blam appear |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
91 |
// in the exception messages for a proxy for this MXBean. Blam is |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
92 |
// legal in MXBeans but is not reconstructible so you cannot make |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
93 |
// a proxy for BlimMXBean. |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
94 |
public static interface BlimMXBean { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
95 |
public BlimContainer getBlimContainer(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
96 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
97 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
98 |
public static class BlimImpl implements BlimMXBean { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
99 |
public BlimContainer getBlimContainer() { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
100 |
return null; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
101 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
102 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
103 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
104 |
public static class BlimContainer { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
105 |
public Blim getBlim() {return null;} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
106 |
public void setBlim(Blim blim) {} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
107 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
108 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
109 |
public static class Blim { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
110 |
public Blam getBlam() {return null;} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
111 |
public void setBlam(Blam blam) {} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
112 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
113 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
114 |
public static class Blam { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
115 |
public Blam(int x) {} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
116 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
117 |
public int getX() {return 0;} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
118 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
119 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
120 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
121 |
// ------ Property name differing only in case ------ |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
122 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
123 |
public static interface CaseProbMXBean { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
124 |
public CaseProb getCaseProb(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
125 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
126 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
127 |
public static class CaseProbImpl implements CaseProbMXBean { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
128 |
public CaseProb getCaseProb() {return null;} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
129 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
130 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
131 |
public static class CaseProb { |
33499
d4f084ec39eb
8139727: Define ConstructorParameters annotation type for MXBeans
jbachorik
parents:
33316
diff
changeset
|
132 |
@ConstructorParameters({"urlPath"}) |
1512
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
133 |
public CaseProb(String urlPath) {} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
134 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
135 |
public String getURLPath() {return null;} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
136 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
137 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
138 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
139 |
public static void main(String[] args) throws Exception { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
140 |
testMXBeans(new Bdelloid(), BdelloidMXBean.class, Rotifer.class, File.class); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
141 |
testMXBeans(new IndirectHashMap(), |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
142 |
IndirectHashMapMXBean.class, HashMapContainer.class, |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
143 |
HashMapContainer.class.getMethod("getHashMap").getGenericReturnType()); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
144 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
145 |
testProxies(new BlimImpl(), BlimMXBean.class, BlimMXBean.class, |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
146 |
BlimContainer.class, Blim.class, Blam.class); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
147 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
148 |
testCaseProb(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
149 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
150 |
if (failure == null) |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
151 |
System.out.println("TEST PASSED"); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
152 |
else |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
153 |
throw new Exception("TEST FAILED: " + failure); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
154 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
155 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
156 |
private static void testMXBeans(Object mbean, Type... expectedTypes) |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
157 |
throws Exception { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
158 |
try { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
159 |
MBeanServer mbs = MBeanServerFactory.newMBeanServer(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
160 |
ObjectName name = new ObjectName("a:b=c"); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
161 |
mbs.registerMBean(mbean, name); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
162 |
fail("No exception from registerMBean for " + mbean); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
163 |
} catch (NotCompliantMBeanException e) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
164 |
checkExceptionChain("MBean " + mbean, e, expectedTypes); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
165 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
166 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
167 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
168 |
private static <T> void testProxies( |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
169 |
Object mbean, Class<T> mxbeanClass, Type... expectedTypes) |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
170 |
throws Exception { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
171 |
MBeanServer mbs = MBeanServerFactory.newMBeanServer(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
172 |
ObjectName name = new ObjectName("a:b=c"); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
173 |
mbs.registerMBean(mbean, name); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
174 |
T proxy = JMX.newMXBeanProxy(mbs, name, mxbeanClass); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
175 |
List<Method> methods = new ArrayList<Method>(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
176 |
for (Method m : mxbeanClass.getMethods()) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
177 |
if (m.getDeclaringClass() == mxbeanClass) |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
178 |
methods.add(m); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
179 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
180 |
if (methods.size() != 1) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
181 |
fail("TEST BUG: expected to find exactly one method in " + |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
182 |
mxbeanClass.getName() + ": " + methods); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
183 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
184 |
Method getter = methods.get(0); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
185 |
try { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
186 |
try { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
187 |
getter.invoke(proxy); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
188 |
fail("No exception from proxy method " + getter.getName() + |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
189 |
" in " + mxbeanClass.getName()); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
190 |
} catch (InvocationTargetException e) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
191 |
Throwable cause = e.getCause(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
192 |
if (cause instanceof Exception) |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
193 |
throw (Exception) cause; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
194 |
else |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
195 |
throw (Error) cause; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
196 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
197 |
} catch (IllegalArgumentException e) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
198 |
checkExceptionChain( |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
199 |
"Proxy for " + mxbeanClass.getName(), e, expectedTypes); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
200 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
201 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
202 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
203 |
private static void testCaseProb() throws Exception { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
204 |
MBeanServer mbs = MBeanServerFactory.newMBeanServer(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
205 |
ObjectName name = new ObjectName("a:b=c"); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
206 |
mbs.registerMBean(new CaseProbImpl(), name); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
207 |
CaseProbMXBean proxy = JMX.newMXBeanProxy(mbs, name, CaseProbMXBean.class); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
208 |
try { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
209 |
CaseProb prob = proxy.getCaseProb(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
210 |
fail("No exception from proxy method getCaseProb"); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
211 |
} catch (IllegalArgumentException e) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
212 |
String messageChain = messageChain(e); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
213 |
if (messageChain.contains("URLPath")) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
214 |
System.out.println("Message chain contains URLPath as required: " |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
215 |
+ messageChain); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
216 |
} else { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
217 |
fail("Exception chain for CaseProb does not mention property" + |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
218 |
" URLPath differing only in case"); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
219 |
System.out.println("Full stack trace:"); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
220 |
e.printStackTrace(System.out); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
221 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
222 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
223 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
224 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
225 |
private static void checkExceptionChain( |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
226 |
String what, Throwable e, Type[] expectedTypes) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
227 |
System.out.println("Exceptions in chain for " + what + ":"); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
228 |
for (Throwable t = e; t != null; t = t.getCause()) |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
229 |
System.out.println(".." + t); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
230 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
231 |
String messageChain = messageChain(e); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
232 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
233 |
// Now check that each of the classes is mentioned in those messages |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
234 |
for (Type type : expectedTypes) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
235 |
String name = (type instanceof Class) ? |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
236 |
((Class<?>) type).getName() : type.toString(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
237 |
if (!messageChain.contains(name)) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
238 |
fail("Exception chain for " + what + " does not mention " + |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
239 |
name); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
240 |
System.out.println("Full stack trace:"); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
241 |
e.printStackTrace(System.out); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
242 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
243 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
244 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
245 |
System.out.println(); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
246 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
247 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
248 |
private static String messageChain(Throwable t) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
249 |
String msg = "//"; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
250 |
for ( ; t != null; t = t.getCause()) |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
251 |
msg += " " + t.getMessage() + " //"; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
252 |
return msg; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
253 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
254 |
|
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
255 |
private static void fail(String why) { |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
256 |
failure = why; |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
257 |
System.out.println("FAIL: " + why); |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
258 |
} |
0f8eb7ad4ef5
6763051: MXBean: Incorrect type names for parametrized dealing with arrays (openType)
emcmanus
parents:
diff
changeset
|
259 |
} |