author | lucy |
Thu, 23 May 2019 18:50:48 +0200 | |
changeset 55024 | 948385f851f2 |
parent 52288 | 2b29df6dfa68 |
child 58766 | 54ffb15c4839 |
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(); |
|
52288
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
78 |
CompositeData[] stackTraceData = new CompositeData[stackTrace.length]; |
2 | 79 |
for (int i = 0; i < stackTrace.length; i++) { |
80 |
StackTraceElement ste = stackTrace[i]; |
|
81 |
stackTraceData[i] = StackTraceElementCompositeData.toCompositeData(ste); |
|
82 |
} |
|
83 |
||
84 |
// Convert MonitorInfo[] and LockInfo[] to CompositeData[] |
|
13803
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
85 |
CompositeData lockInfoData = |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
86 |
LockInfoCompositeData.toCompositeData(threadInfo.getLockInfo()); |
2 | 87 |
|
13803
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
88 |
// Convert LockInfo[] and MonitorInfo[] to CompositeData[] |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
89 |
LockInfo[] lockedSyncs = threadInfo.getLockedSynchronizers(); |
52288
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
90 |
CompositeData[] lockedSyncsData = new CompositeData[lockedSyncs.length]; |
13803
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
91 |
for (int i = 0; i < lockedSyncs.length; i++) { |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
92 |
LockInfo li = lockedSyncs[i]; |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
93 |
lockedSyncsData[i] = LockInfoCompositeData.toCompositeData(li); |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
94 |
} |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
95 |
|
2 | 96 |
MonitorInfo[] lockedMonitors = threadInfo.getLockedMonitors(); |
52288
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
97 |
CompositeData[] lockedMonitorsData = new CompositeData[lockedMonitors.length]; |
2 | 98 |
for (int i = 0; i < lockedMonitors.length; i++) { |
99 |
MonitorInfo mi = lockedMonitors[i]; |
|
100 |
lockedMonitorsData[i] = MonitorInfoCompositeData.toCompositeData(mi); |
|
101 |
} |
|
102 |
||
52288
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
103 |
// values may be null; can't use Map.of |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
104 |
Map<String,Object> items = new HashMap<>(); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
105 |
items.put(THREAD_ID, threadInfo.getThreadId()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
106 |
items.put(THREAD_NAME, threadInfo.getThreadName()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
107 |
items.put(THREAD_STATE, threadInfo.getThreadState().name()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
108 |
items.put(BLOCKED_TIME, threadInfo.getBlockedTime()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
109 |
items.put(BLOCKED_COUNT, threadInfo.getBlockedCount()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
110 |
items.put(WAITED_TIME, threadInfo.getWaitedTime()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
111 |
items.put(WAITED_COUNT, threadInfo.getWaitedCount()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
112 |
items.put(LOCK_INFO, lockInfoData); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
113 |
items.put(LOCK_NAME, threadInfo.getLockName()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
114 |
items.put(LOCK_OWNER_ID, threadInfo.getLockOwnerId()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
115 |
items.put(LOCK_OWNER_NAME, threadInfo.getLockOwnerName()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
116 |
items.put(STACK_TRACE, stackTraceData); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
117 |
items.put(SUSPENDED, threadInfo.isSuspended()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
118 |
items.put(IN_NATIVE, threadInfo.isInNative()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
119 |
items.put(LOCKED_MONITORS, lockedMonitorsData); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
120 |
items.put(LOCKED_SYNCS, lockedSyncsData); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
121 |
items.put(DAEMON, threadInfo.isDaemon()); |
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
122 |
items.put(PRIORITY, threadInfo.getPriority()); |
2 | 123 |
|
124 |
try { |
|
52288
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
125 |
return new CompositeDataSupport(ThreadInfoCompositeTypes.ofVersion(RUNTIME_VERSION), items); |
2 | 126 |
} catch (OpenDataException e) { |
127 |
// Should never reach here |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
128 |
throw new AssertionError(e); |
2 | 129 |
} |
130 |
} |
|
131 |
||
132 |
// Attribute names |
|
133 |
private static final String THREAD_ID = "threadId"; |
|
134 |
private static final String THREAD_NAME = "threadName"; |
|
135 |
private static final String THREAD_STATE = "threadState"; |
|
136 |
private static final String BLOCKED_TIME = "blockedTime"; |
|
137 |
private static final String BLOCKED_COUNT = "blockedCount"; |
|
138 |
private static final String WAITED_TIME = "waitedTime"; |
|
139 |
private static final String WAITED_COUNT = "waitedCount"; |
|
140 |
private static final String LOCK_INFO = "lockInfo"; |
|
141 |
private static final String LOCK_NAME = "lockName"; |
|
142 |
private static final String LOCK_OWNER_ID = "lockOwnerId"; |
|
143 |
private static final String LOCK_OWNER_NAME = "lockOwnerName"; |
|
144 |
private static final String STACK_TRACE = "stackTrace"; |
|
145 |
private static final String SUSPENDED = "suspended"; |
|
146 |
private static final String IN_NATIVE = "inNative"; |
|
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
147 |
private static final String DAEMON = "daemon"; |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
148 |
private static final String PRIORITY = "priority"; |
2 | 149 |
private static final String LOCKED_MONITORS = "lockedMonitors"; |
150 |
private static final String LOCKED_SYNCS = "lockedSynchronizers"; |
|
151 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
152 |
private static final String[] V5_ATTRIBUTES = { |
2 | 153 |
THREAD_ID, |
154 |
THREAD_NAME, |
|
155 |
THREAD_STATE, |
|
156 |
BLOCKED_TIME, |
|
157 |
BLOCKED_COUNT, |
|
158 |
WAITED_TIME, |
|
159 |
WAITED_COUNT, |
|
160 |
LOCK_NAME, |
|
161 |
LOCK_OWNER_ID, |
|
162 |
LOCK_OWNER_NAME, |
|
163 |
STACK_TRACE, |
|
164 |
SUSPENDED, |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
165 |
IN_NATIVE |
2 | 166 |
}; |
167 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
168 |
private static final String[] V6_ATTRIBUTES = { |
2 | 169 |
LOCK_INFO, |
170 |
LOCKED_MONITORS, |
|
171 |
LOCKED_SYNCS, |
|
172 |
}; |
|
173 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
174 |
private static final String[] V9_ATTRIBUTES = { |
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
175 |
DAEMON, |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
176 |
PRIORITY, |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
177 |
}; |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
178 |
|
2 | 179 |
public long threadId() { |
180 |
return getLong(cdata, THREAD_ID); |
|
181 |
} |
|
182 |
||
183 |
public String threadName() { |
|
184 |
// The ThreadName item cannot be null so we check that |
|
185 |
// it is present with a non-null value. |
|
186 |
String name = getString(cdata, THREAD_NAME); |
|
187 |
if (name == null) { |
|
188 |
throw new IllegalArgumentException("Invalid composite data: " + |
|
189 |
"Attribute " + THREAD_NAME + " has null value"); |
|
190 |
} |
|
191 |
return name; |
|
192 |
} |
|
193 |
||
194 |
public Thread.State threadState() { |
|
195 |
return Thread.State.valueOf(getString(cdata, THREAD_STATE)); |
|
196 |
} |
|
197 |
||
198 |
public long blockedTime() { |
|
199 |
return getLong(cdata, BLOCKED_TIME); |
|
200 |
} |
|
201 |
||
202 |
public long blockedCount() { |
|
203 |
return getLong(cdata, BLOCKED_COUNT); |
|
204 |
} |
|
205 |
||
206 |
public long waitedTime() { |
|
207 |
return getLong(cdata, WAITED_TIME); |
|
208 |
} |
|
209 |
||
210 |
public long waitedCount() { |
|
211 |
return getLong(cdata, WAITED_COUNT); |
|
212 |
} |
|
213 |
||
214 |
public String lockName() { |
|
215 |
// The LockName and LockOwnerName can legitimately be null, |
|
216 |
// we don't bother to check the value |
|
217 |
return getString(cdata, LOCK_NAME); |
|
218 |
} |
|
219 |
||
220 |
public long lockOwnerId() { |
|
221 |
return getLong(cdata, LOCK_OWNER_ID); |
|
222 |
} |
|
223 |
||
224 |
public String lockOwnerName() { |
|
225 |
return getString(cdata, LOCK_OWNER_NAME); |
|
226 |
} |
|
227 |
||
228 |
public boolean suspended() { |
|
229 |
return getBoolean(cdata, SUSPENDED); |
|
230 |
} |
|
231 |
||
232 |
public boolean inNative() { |
|
233 |
return getBoolean(cdata, IN_NATIVE); |
|
234 |
} |
|
235 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
236 |
/* |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
237 |
* 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
|
238 |
*/ |
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
239 |
public boolean isDaemon() { |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
240 |
return cdata.containsKey(DAEMON) ? getBoolean(cdata, DAEMON) : false; |
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
241 |
} |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
242 |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
243 |
/* |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
244 |
* 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
|
245 |
*/ |
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
246 |
public int getPriority(){ |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
247 |
return cdata.containsKey(PRIORITY) ? getInt(cdata, PRIORITY) : Thread.NORM_PRIORITY; |
29101
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
248 |
} |
55f7a91aaa32
6588467: Add isDaemon() and getPriority() to ThreadInfo
jmanson
parents:
25859
diff
changeset
|
249 |
|
2 | 250 |
public StackTraceElement[] stackTrace() { |
251 |
CompositeData[] stackTraceData = |
|
252 |
(CompositeData[]) cdata.get(STACK_TRACE); |
|
253 |
||
254 |
// The StackTrace item cannot be null, but if it is we will get |
|
255 |
// a NullPointerException when we ask for its length. |
|
256 |
StackTraceElement[] stackTrace = |
|
257 |
new StackTraceElement[stackTraceData.length]; |
|
258 |
for (int i = 0; i < stackTraceData.length; i++) { |
|
259 |
CompositeData cdi = stackTraceData[i]; |
|
260 |
stackTrace[i] = StackTraceElementCompositeData.from(cdi); |
|
261 |
} |
|
262 |
return stackTrace; |
|
263 |
} |
|
264 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
265 |
/* |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
266 |
* 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
|
267 |
* 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
|
268 |
* from the lockName value. |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
269 |
*/ |
2 | 270 |
public LockInfo lockInfo() { |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
271 |
if (cdata.containsKey(LOCK_INFO)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
272 |
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
|
273 |
return LockInfo.from(lockInfoData); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
274 |
} else { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
275 |
String lockName = lockName(); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
276 |
LockInfo lock = null; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
277 |
if (lockName != null) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
278 |
String result[] = lockName.split("@"); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
279 |
if (result.length == 2) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
280 |
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
|
281 |
lock = new LockInfo(result[0], identityHashCode); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
282 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
283 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
284 |
return lock; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
285 |
} |
2 | 286 |
} |
287 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
288 |
/** |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
289 |
* 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
|
290 |
*/ |
2 | 291 |
public MonitorInfo[] lockedMonitors() { |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
292 |
if (!cdata.containsKey(LOCKED_MONITORS)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
293 |
return new MonitorInfo[0]; |
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 |
|
2 | 296 |
CompositeData[] lockedMonitorsData = |
297 |
(CompositeData[]) cdata.get(LOCKED_MONITORS); |
|
298 |
||
299 |
// The LockedMonitors item cannot be null, but if it is we will get |
|
300 |
// a NullPointerException when we ask for its length. |
|
301 |
MonitorInfo[] monitors = |
|
302 |
new MonitorInfo[lockedMonitorsData.length]; |
|
303 |
for (int i = 0; i < lockedMonitorsData.length; i++) { |
|
304 |
CompositeData cdi = lockedMonitorsData[i]; |
|
305 |
monitors[i] = MonitorInfo.from(cdi); |
|
306 |
} |
|
307 |
return monitors; |
|
308 |
} |
|
309 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
310 |
/** |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
311 |
* 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
|
312 |
*/ |
2 | 313 |
public LockInfo[] lockedSynchronizers() { |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
314 |
if (!cdata.containsKey(LOCKED_SYNCS)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
315 |
return new LockInfo[0]; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
316 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
317 |
|
2 | 318 |
CompositeData[] lockedSyncsData = |
319 |
(CompositeData[]) cdata.get(LOCKED_SYNCS); |
|
320 |
||
321 |
// The LockedSynchronizers item cannot be null, but if it is we will |
|
322 |
// 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
|
323 |
LockInfo[] locks = new LockInfo[lockedSyncsData.length]; |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
324 |
for (int i = 0; i < lockedSyncsData.length; i++) { |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
325 |
CompositeData cdi = lockedSyncsData[i]; |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
326 |
locks[i] = LockInfo.from(cdi); |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
327 |
} |
889df16bef60
7193302: Remove ConstructorProperties annotation from java.lang.management.LockInfo
mchung
parents:
11530
diff
changeset
|
328 |
return locks; |
2 | 329 |
} |
330 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
331 |
/** |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
332 |
* Validate if the input CompositeData has the expected |
2 | 333 |
* CompositeType (i.e. contain all attributes with expected |
334 |
* names and types). |
|
335 |
*/ |
|
336 |
public static void validateCompositeData(CompositeData cd) { |
|
337 |
if (cd == null) { |
|
338 |
throw new NullPointerException("Null CompositeData"); |
|
339 |
} |
|
340 |
||
341 |
CompositeType type = cd.getCompositeType(); |
|
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
342 |
int version; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
343 |
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
|
344 |
version = Runtime.version().feature(); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
345 |
} 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
|
346 |
version = 6; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
347 |
} else { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
348 |
version = 5; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
349 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
350 |
|
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
351 |
if (!isTypeMatched(ThreadInfoCompositeTypes.ofVersion(version), type)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
352 |
throw new IllegalArgumentException( |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
353 |
"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
|
354 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
355 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
356 |
|
52288
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
357 |
static final int RUNTIME_VERSION = Runtime.version().feature(); |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
358 |
static class ThreadInfoCompositeTypes { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
359 |
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
|
360 |
/* |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
361 |
* 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
|
362 |
*/ |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
363 |
static CompositeType ofVersion(int version) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
364 |
return compositeTypes.get(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 |
static Map<Integer, CompositeType> initCompositeTypes() { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
368 |
Map<Integer, CompositeType> types = new HashMap<>(); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
369 |
CompositeType ctype = initCompositeType(); |
52288
2b29df6dfa68
8212795: ThreadInfoCompositeData.toCompositeData fails to map ThreadInfo to CompositeData
mchung
parents:
49077
diff
changeset
|
370 |
types.put(RUNTIME_VERSION, ctype); |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
371 |
types.put(5, initV5CompositeType(ctype)); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
372 |
types.put(6, initV6CompositeType(ctype)); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
373 |
return types; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
374 |
} |
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 |
static CompositeType initCompositeType() { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
377 |
try { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
378 |
return (CompositeType)MappedMXBeanType.toOpenType(ThreadInfo.class); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
379 |
} catch (OpenDataException e) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
380 |
// Should never reach here |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
381 |
throw new AssertionError(e); |
2 | 382 |
} |
383 |
} |
|
384 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
385 |
static CompositeType initV5CompositeType(CompositeType threadInfoCompositeType) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
386 |
try { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
387 |
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
|
388 |
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
|
389 |
String name = V5_ATTRIBUTES[i]; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
390 |
v5Types[i] = name.equals(STACK_TRACE) |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
391 |
? new ArrayType<>(1, StackTraceElementCompositeData.v5CompositeType()) |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
392 |
: threadInfoCompositeType.getType(name); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
393 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
394 |
return new CompositeType("ThreadInfo", |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
395 |
"JDK 5 ThreadInfo", |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
396 |
V5_ATTRIBUTES, |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
397 |
V5_ATTRIBUTES, |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
398 |
v5Types); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
399 |
} catch (OpenDataException e) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
400 |
// Should never reach here |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
401 |
throw new AssertionError(e); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
402 |
} |
2 | 403 |
} |
404 |
||
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
405 |
static CompositeType initV6CompositeType(CompositeType threadInfoCompositeType) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
406 |
try { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
407 |
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
|
408 |
.flatMap(Arrays::stream).toArray(String[]::new); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
409 |
OpenType<?>[] v6Types = new OpenType<?>[v6Names.length]; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
410 |
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
|
411 |
String name = v6Names[i]; |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
412 |
OpenType<?> ot = threadInfoCompositeType.getType(name); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
413 |
if (name.equals(STACK_TRACE)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
414 |
ot = new ArrayType<>(1, StackTraceElementCompositeData.v5CompositeType()); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
415 |
} else if (name.equals(LOCKED_MONITORS)) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
416 |
ot = new ArrayType<>(1, MonitorInfoCompositeData.v6CompositeType()); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
417 |
} |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
418 |
v6Types[i] = ot; |
2 | 419 |
} |
49077
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
420 |
return new CompositeType("ThreadInfo", |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
421 |
"JDK 6 ThreadInfo", |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
422 |
v6Names, |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
423 |
v6Names, |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
424 |
v6Types); |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
425 |
} catch (OpenDataException e) { |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
426 |
// Should never reach here |
b1c42b3cd19b
8198253: ThreadInfo.from(CompositeData) incorrectly accepts CompositeData with missing JDK 6 attributes
mchung
parents:
47216
diff
changeset
|
427 |
throw new AssertionError(e); |
2 | 428 |
} |
429 |
} |
|
430 |
} |
|
4173
d01972926813
6895875: Missing serialVersionUID in sun.management classes
mchung
parents:
715
diff
changeset
|
431 |
private static final long serialVersionUID = 2464378539119753175L; |
2 | 432 |
} |