author | mchung |
Wed, 28 Feb 2018 17:11:57 -0800 | |
changeset 49077 | b1c42b3cd19b |
parent 47216 | 71c04702a3d5 |
child 52288 | 2b29df6dfa68 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2004, 2018, 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.management; |
|
27 |
||
28 |
import java.lang.management.ThreadInfo; |
|
29 |
import java.lang.management.MonitorInfo; |
|
30 |
import java.lang.management.LockInfo; |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
31 |
import java.util.Arrays; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
32 |
import java.util.HashMap; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
33 |
import java.util.Map; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
34 |
import java.util.stream.Stream; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
35 |
import javax.management.openmbean.ArrayType; |
2 | 36 |
import javax.management.openmbean.CompositeType; |
37 |
import javax.management.openmbean.CompositeData; |
|
38 |
import javax.management.openmbean.CompositeDataSupport; |
|
39 |
import javax.management.openmbean.OpenDataException; |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
40 |
import javax.management.openmbean.OpenType; |
2 | 41 |
|
42 |
/** |
|
43 |
* A CompositeData for ThreadInfo for the local management support. |
|
44 |
* This class avoids the performance penalty paid to the |
|
45 |
* construction of a CompositeData use in the local case. |
|
46 |
*/ |
|
47 |
public class ThreadInfoCompositeData extends LazyCompositeData { |
|
48 |
private final ThreadInfo threadInfo; |
|
49 |
private final CompositeData cdata; |
|
50 |
||
51 |
private ThreadInfoCompositeData(ThreadInfo ti) { |
|
52 |
this.threadInfo = ti; |
|
53 |
this.cdata = null; |
|
54 |
} |
|
55 |
||
56 |
private ThreadInfoCompositeData(CompositeData cd) { |
|
57 |
this.threadInfo = null; |
|
58 |
this.cdata = cd; |
|
59 |
} |
|
60 |
||
61 |
public ThreadInfo getThreadInfo() { |
|
62 |
return threadInfo; |
|
63 |
} |
|
64 |
||
65 |
public static ThreadInfoCompositeData getInstance(CompositeData cd) { |
|
66 |
validateCompositeData(cd); |
|
67 |
return new ThreadInfoCompositeData(cd); |
|
68 |
} |
|
69 |
||
70 |
public static CompositeData toCompositeData(ThreadInfo ti) { |
|
71 |
ThreadInfoCompositeData ticd = new ThreadInfoCompositeData(ti); |
|
72 |
return ticd.getCompositeData(); |
|
73 |
} |
|
74 |
||
75 |
protected CompositeData getCompositeData() { |
|
76 |
// Convert StackTraceElement[] to CompositeData[] |
|
77 |
StackTraceElement[] stackTrace = threadInfo.getStackTrace(); |
|
78 |
CompositeData[] stackTraceData = |
|
79 |
new CompositeData[stackTrace.length]; |
|
80 |
for (int i = 0; i < stackTrace.length; i++) { |
|
81 |
StackTraceElement ste = stackTrace[i]; |
|
82 |
stackTraceData[i] = StackTraceElementCompositeData.toCompositeData(ste); |
|
83 |
} |
|
84 |
||
85 |
// Convert MonitorInfo[] and LockInfo[] to CompositeData[] |
|
13803
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
86 |
CompositeData lockInfoData = |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
87 |
LockInfoCompositeData.toCompositeData(threadInfo.getLockInfo()); |
2 | 88 |
|
13803
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
89 |
// Convert LockInfo[] and MonitorInfo[] to CompositeData[] |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
90 |
LockInfo[] lockedSyncs = threadInfo.getLockedSynchronizers(); |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
91 |
CompositeData[] lockedSyncsData = |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
92 |
new CompositeData[lockedSyncs.length]; |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
93 |
for (int i = 0; i < lockedSyncs.length; i++) { |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
94 |
LockInfo li = lockedSyncs[i]; |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
95 |
lockedSyncsData[i] = LockInfoCompositeData.toCompositeData(li); |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
96 |
} |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
97 |
|
2 | 98 |
MonitorInfo[] lockedMonitors = threadInfo.getLockedMonitors(); |
99 |
CompositeData[] lockedMonitorsData = |
|
100 |
new CompositeData[lockedMonitors.length]; |
|
101 |
for (int i = 0; i < lockedMonitors.length; i++) { |
|
102 |
MonitorInfo mi = lockedMonitors[i]; |
|
103 |
lockedMonitorsData[i] = MonitorInfoCompositeData.toCompositeData(mi); |
|
104 |
} |
|
105 |
||
106 |
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
107 |
// THREAD_INFO_ATTRIBUTES! |
2 | 108 |
final Object[] threadInfoItemValues = { |
25186
63e1a2ec30f5
8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
prappo
parents:
24685
diff
changeset
|
109 |
threadInfo.getThreadId(), |
2 | 110 |
threadInfo.getThreadName(), |
111 |
threadInfo.getThreadState().name(), |
|
25186
63e1a2ec30f5
8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
prappo
parents:
24685
diff
changeset
|
112 |
threadInfo.getBlockedTime(), |
63e1a2ec30f5
8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
prappo
parents:
24685
diff
changeset
|
113 |
threadInfo.getBlockedCount(), |
63e1a2ec30f5
8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
prappo
parents:
24685
diff
changeset
|
114 |
threadInfo.getWaitedTime(), |
63e1a2ec30f5
8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
prappo
parents:
24685
diff
changeset
|
115 |
threadInfo.getWaitedCount(), |
2 | 116 |
lockInfoData, |
117 |
threadInfo.getLockName(), |
|
25186
63e1a2ec30f5
8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
prappo
parents:
24685
diff
changeset
|
118 |
threadInfo.getLockOwnerId(), |
2 | 119 |
threadInfo.getLockOwnerName(), |
120 |
stackTraceData, |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
121 |
threadInfo.isSuspended(), |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
122 |
threadInfo.isInNative(), |
2 | 123 |
lockedMonitorsData, |
124 |
lockedSyncsData, |
|
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
125 |
threadInfo.isDaemon(), |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
126 |
threadInfo.getPriority(), |
2 | 127 |
}; |
128 |
||
129 |
try { |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
130 |
return new CompositeDataSupport(compositeType(), |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
131 |
THREAD_INFO_ATTRIBTUES, |
2 | 132 |
threadInfoItemValues); |
133 |
} catch (OpenDataException e) { |
|
134 |
// Should never reach here |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
135 |
throw new AssertionError(e); |
2 | 136 |
} |
137 |
} |
|
138 |
||
139 |
// Attribute names |
|
140 |
private static final String THREAD_ID = "threadId"; |
|
141 |
private static final String THREAD_NAME = "threadName"; |
|
142 |
private static final String THREAD_STATE = "threadState"; |
|
143 |
private static final String BLOCKED_TIME = "blockedTime"; |
|
144 |
private static final String BLOCKED_COUNT = "blockedCount"; |
|
145 |
private static final String WAITED_TIME = "waitedTime"; |
|
146 |
private static final String WAITED_COUNT = "waitedCount"; |
|
147 |
private static final String LOCK_INFO = "lockInfo"; |
|
148 |
private static final String LOCK_NAME = "lockName"; |
|
149 |
private static final String LOCK_OWNER_ID = "lockOwnerId"; |
|
150 |
private static final String LOCK_OWNER_NAME = "lockOwnerName"; |
|
151 |
private static final String STACK_TRACE = "stackTrace"; |
|
152 |
private static final String SUSPENDED = "suspended"; |
|
153 |
private static final String IN_NATIVE = "inNative"; |
|
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
154 |
private static final String DAEMON = "daemon"; |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
155 |
private static final String PRIORITY = "priority"; |
2 | 156 |
private static final String LOCKED_MONITORS = "lockedMonitors"; |
157 |
private static final String LOCKED_SYNCS = "lockedSynchronizers"; |
|
158 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
159 |
private static final String[] V5_ATTRIBUTES = { |
2 | 160 |
THREAD_ID, |
161 |
THREAD_NAME, |
|
162 |
THREAD_STATE, |
|
163 |
BLOCKED_TIME, |
|
164 |
BLOCKED_COUNT, |
|
165 |
WAITED_TIME, |
|
166 |
WAITED_COUNT, |
|
167 |
LOCK_NAME, |
|
168 |
LOCK_OWNER_ID, |
|
169 |
LOCK_OWNER_NAME, |
|
170 |
STACK_TRACE, |
|
171 |
SUSPENDED, |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
172 |
IN_NATIVE |
2 | 173 |
}; |
174 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
175 |
private static final String[] V6_ATTRIBUTES = { |
2 | 176 |
LOCK_INFO, |
177 |
LOCKED_MONITORS, |
|
178 |
LOCKED_SYNCS, |
|
179 |
}; |
|
180 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
181 |
private static final String[] V9_ATTRIBUTES = { |
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
182 |
DAEMON, |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
183 |
PRIORITY, |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
184 |
}; |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
185 |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
186 |
private static final String[] THREAD_INFO_ATTRIBTUES = |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
187 |
Stream.of(V5_ATTRIBUTES, V6_ATTRIBUTES, V9_ATTRIBUTES) |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
188 |
.flatMap(Arrays::stream).toArray(String[]::new); |
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
189 |
|
2 | 190 |
public long threadId() { |
191 |
return getLong(cdata, THREAD_ID); |
|
192 |
} |
|
193 |
||
194 |
public String threadName() { |
|
195 |
// The ThreadName item cannot be null so we check that |
|
196 |
// it is present with a non-null value. |
|
197 |
String name = getString(cdata, THREAD_NAME); |
|
198 |
if (name == null) { |
|
199 |
throw new IllegalArgumentException("Invalid composite data: " + |
|
200 |
"Attribute " + THREAD_NAME + " has null value"); |
|
201 |
} |
|
202 |
return name; |
|
203 |
} |
|
204 |
||
205 |
public Thread.State threadState() { |
|
206 |
return Thread.State.valueOf(getString(cdata, THREAD_STATE)); |
|
207 |
} |
|
208 |
||
209 |
public long blockedTime() { |
|
210 |
return getLong(cdata, BLOCKED_TIME); |
|
211 |
} |
|
212 |
||
213 |
public long blockedCount() { |
|
214 |
return getLong(cdata, BLOCKED_COUNT); |
|
215 |
} |
|
216 |
||
217 |
public long waitedTime() { |
|
218 |
return getLong(cdata, WAITED_TIME); |
|
219 |
} |
|
220 |
||
221 |
public long waitedCount() { |
|
222 |
return getLong(cdata, WAITED_COUNT); |
|
223 |
} |
|
224 |
||
225 |
public String lockName() { |
|
226 |
// The LockName and LockOwnerName can legitimately be null, |
|
227 |
// we don't bother to check the value |
|
228 |
return getString(cdata, LOCK_NAME); |
|
229 |
} |
|
230 |
||
231 |
public long lockOwnerId() { |
|
232 |
return getLong(cdata, LOCK_OWNER_ID); |
|
233 |
} |
|
234 |
||
235 |
public String lockOwnerName() { |
|
236 |
return getString(cdata, LOCK_OWNER_NAME); |
|
237 |
} |
|
238 |
||
239 |
public boolean suspended() { |
|
240 |
return getBoolean(cdata, SUSPENDED); |
|
241 |
} |
|
242 |
||
243 |
public boolean inNative() { |
|
244 |
return getBoolean(cdata, IN_NATIVE); |
|
245 |
} |
|
246 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
247 |
/* |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
248 |
* if daemon attribute is not present, default to false. |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
249 |
*/ |
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
250 |
public boolean isDaemon() { |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
251 |
return cdata.containsKey(DAEMON) ? getBoolean(cdata, DAEMON) : false; |
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
252 |
} |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
253 |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
254 |
/* |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
255 |
* if priority attribute is not present, default to norm priority. |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
256 |
*/ |
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
257 |
public int getPriority(){ |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
258 |
return cdata.containsKey(PRIORITY) ? getInt(cdata, PRIORITY) : Thread.NORM_PRIORITY; |
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
259 |
} |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
260 |
|
2 | 261 |
public StackTraceElement[] stackTrace() { |
262 |
CompositeData[] stackTraceData = |
|
263 |
(CompositeData[]) cdata.get(STACK_TRACE); |
|
264 |
||
265 |
// The StackTrace item cannot be null, but if it is we will get |
|
266 |
// a NullPointerException when we ask for its length. |
|
267 |
StackTraceElement[] stackTrace = |
|
268 |
new StackTraceElement[stackTraceData.length]; |
|
269 |
for (int i = 0; i < stackTraceData.length; i++) { |
|
270 |
CompositeData cdi = stackTraceData[i]; |
|
271 |
stackTrace[i] = StackTraceElementCompositeData.from(cdi); |
|
272 |
} |
|
273 |
return stackTrace; |
|
274 |
} |
|
275 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
276 |
/* |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
277 |
* lockInfo is a new attribute added in JDK 6 ThreadInfo |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
278 |
* If cd is a 5.0 version, construct the LockInfo object |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
279 |
* from the lockName value. |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
280 |
*/ |
2 | 281 |
public LockInfo lockInfo() { |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
282 |
if (cdata.containsKey(LOCK_INFO)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
283 |
CompositeData lockInfoData = (CompositeData) cdata.get(LOCK_INFO); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
284 |
return LockInfo.from(lockInfoData); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
285 |
} else { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
286 |
String lockName = lockName(); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
287 |
LockInfo lock = null; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
288 |
if (lockName != null) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
289 |
String result[] = lockName.split("@"); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
290 |
if (result.length == 2) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
291 |
int identityHashCode = Integer.parseInt(result[1], 16); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
292 |
lock = new LockInfo(result[0], identityHashCode); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
293 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
294 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
295 |
return lock; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
296 |
} |
2 | 297 |
} |
298 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
299 |
/** |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
300 |
* Returns an empty array if locked_monitors attribute is not present. |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
301 |
*/ |
2 | 302 |
public MonitorInfo[] lockedMonitors() { |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
303 |
if (!cdata.containsKey(LOCKED_MONITORS)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
304 |
return new MonitorInfo[0]; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
305 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
306 |
|
2 | 307 |
CompositeData[] lockedMonitorsData = |
308 |
(CompositeData[]) cdata.get(LOCKED_MONITORS); |
|
309 |
||
310 |
// The LockedMonitors item cannot be null, but if it is we will get |
|
311 |
// a NullPointerException when we ask for its length. |
|
312 |
MonitorInfo[] monitors = |
|
313 |
new MonitorInfo[lockedMonitorsData.length]; |
|
314 |
for (int i = 0; i < lockedMonitorsData.length; i++) { |
|
315 |
CompositeData cdi = lockedMonitorsData[i]; |
|
316 |
monitors[i] = MonitorInfo.from(cdi); |
|
317 |
} |
|
318 |
return monitors; |
|
319 |
} |
|
320 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
321 |
/** |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
322 |
* Returns an empty array if locked_monitors attribute is not present. |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
323 |
*/ |
2 | 324 |
public LockInfo[] lockedSynchronizers() { |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
325 |
if (!cdata.containsKey(LOCKED_SYNCS)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
326 |
return new LockInfo[0]; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
327 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
328 |
|
2 | 329 |
CompositeData[] lockedSyncsData = |
330 |
(CompositeData[]) cdata.get(LOCKED_SYNCS); |
|
331 |
||
332 |
// The LockedSynchronizers item cannot be null, but if it is we will |
|
333 |
// get a NullPointerException when we ask for its length. |
|
13803
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
334 |
LockInfo[] locks = new LockInfo[lockedSyncsData.length]; |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
335 |
for (int i = 0; i < lockedSyncsData.length; i++) { |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
336 |
CompositeData cdi = lockedSyncsData[i]; |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
337 |
locks[i] = LockInfo.from(cdi); |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
338 |
} |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
339 |
return locks; |
2 | 340 |
} |
341 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
342 |
/** |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
343 |
* Validate if the input CompositeData has the expected |
2 | 344 |
* CompositeType (i.e. contain all attributes with expected |
345 |
* names and types). |
|
346 |
*/ |
|
347 |
public static void validateCompositeData(CompositeData cd) { |
|
348 |
if (cd == null) { |
|
349 |
throw new NullPointerException("Null CompositeData"); |
|
350 |
} |
|
351 |
||
352 |
CompositeType type = cd.getCompositeType(); |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
353 |
int version; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
354 |
if (Arrays.stream(V9_ATTRIBUTES).anyMatch(type::containsKey)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
355 |
version = Runtime.version().feature(); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
356 |
} else if (Arrays.stream(V6_ATTRIBUTES).anyMatch(type::containsKey)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
357 |
version = 6; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
358 |
} else { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
359 |
version = 5; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
360 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
361 |
|
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
362 |
if (!isTypeMatched(ThreadInfoCompositeTypes.ofVersion(version), type)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
363 |
throw new IllegalArgumentException( |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
364 |
"Unexpected composite type for ThreadInfo of version " + version); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
365 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
366 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
367 |
|
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
368 |
public static CompositeType compositeType() { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
369 |
return ThreadInfoCompositeTypes.compositeTypes.get(0); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
370 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
371 |
|
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
372 |
static class ThreadInfoCompositeTypes { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
373 |
static final int CURRENT = Runtime.version().feature(); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
374 |
static final Map<Integer, CompositeType> compositeTypes = initCompositeTypes(); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
375 |
/* |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
376 |
* Returns CompositeType of the given runtime version |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
377 |
*/ |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
378 |
static CompositeType ofVersion(int version) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
379 |
return compositeTypes.get(version); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
380 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
381 |
|
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
382 |
static Map<Integer, CompositeType> initCompositeTypes() { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
383 |
Map<Integer, CompositeType> types = new HashMap<>(); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
384 |
CompositeType ctype = initCompositeType(); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
385 |
types.put(CURRENT, ctype); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
386 |
types.put(5, initV5CompositeType(ctype)); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
387 |
types.put(6, initV6CompositeType(ctype)); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
388 |
return types; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
389 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
390 |
|
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
391 |
static CompositeType initCompositeType() { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
392 |
try { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
393 |
return (CompositeType)MappedMXBeanType.toOpenType(ThreadInfo.class); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
394 |
} catch (OpenDataException e) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
395 |
// Should never reach here |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
396 |
throw new AssertionError(e); |
2 | 397 |
} |
398 |
} |
|
399 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
400 |
static CompositeType initV5CompositeType(CompositeType threadInfoCompositeType) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
401 |
try { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
402 |
OpenType<?>[] v5Types = new OpenType<?>[V5_ATTRIBUTES.length]; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
403 |
for (int i = 0; i < v5Types.length; i++) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
404 |
String name = V5_ATTRIBUTES[i]; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
405 |
v5Types[i] = name.equals(STACK_TRACE) |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
406 |
? new ArrayType<>(1, StackTraceElementCompositeData.v5CompositeType()) |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
407 |
: threadInfoCompositeType.getType(name); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
408 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
409 |
return new CompositeType("ThreadInfo", |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
410 |
"JDK 5 ThreadInfo", |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
411 |
V5_ATTRIBUTES, |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
412 |
V5_ATTRIBUTES, |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
413 |
v5Types); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
414 |
} catch (OpenDataException e) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
415 |
// Should never reach here |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
416 |
throw new AssertionError(e); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
417 |
} |
2 | 418 |
} |
419 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
420 |
static CompositeType initV6CompositeType(CompositeType threadInfoCompositeType) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
421 |
try { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
422 |
String[] v6Names = Stream.of(V5_ATTRIBUTES, V6_ATTRIBUTES) |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
423 |
.flatMap(Arrays::stream).toArray(String[]::new); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
424 |
OpenType<?>[] v6Types = new OpenType<?>[v6Names.length]; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
425 |
for (int i = 0; i < v6Names.length; i++) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
426 |
String name = v6Names[i]; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
427 |
OpenType<?> ot = threadInfoCompositeType.getType(name); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
428 |
if (name.equals(STACK_TRACE)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
429 |
ot = new ArrayType<>(1, StackTraceElementCompositeData.v5CompositeType()); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
430 |
} else if (name.equals(LOCKED_MONITORS)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
431 |
ot = new ArrayType<>(1, MonitorInfoCompositeData.v6CompositeType()); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
432 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
433 |
v6Types[i] = ot; |
2 | 434 |
} |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
435 |
return new CompositeType("ThreadInfo", |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
436 |
"JDK 6 ThreadInfo", |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
437 |
v6Names, |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
438 |
v6Names, |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
439 |
v6Types); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
440 |
} catch (OpenDataException e) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
441 |
// Should never reach here |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
442 |
throw new AssertionError(e); |
2 | 443 |
} |
444 |
} |
|
445 |
} |
|
4173
d01972926813
6895875: Missing serialVersionUID in sun.management classes
mchung
parents:
715
diff
changeset
|
446 |
private static final long serialVersionUID = 2464378539119753175L; |
2 | 447 |
} |