31
31
import java .util .stream .Stream ;
32
32
import javax .management .ObjectName ;
33
33
import java .util .Objects ;
34
- import sun .management .Util ;
35
34
36
35
/**
37
36
* Implementation for java.lang.management.ThreadMXBean as well as providing the
@@ -222,7 +221,7 @@ public void setThreadContentionMonitoringEnabled(boolean enable) {
222
221
223
222
private boolean verifyCurrentThreadCpuTime () {
224
223
// check if Thread CPU time measurement is supported.
225
- if (Util . isVirtual ( Thread .currentThread ())) {
224
+ if (Thread .currentThread (). isVirtual ( )) {
226
225
throw new UnsupportedOperationException ("Not supported by virtual threads" );
227
226
}
228
227
if (!isCurrentThreadCpuTimeSupported ()) {
@@ -284,7 +283,7 @@ protected long[] getThreadCpuTime(long[] ids) {
284
283
long id = ids [0 ];
285
284
Thread thread = Thread .currentThread ();
286
285
if (id == thread .threadId ()) {
287
- if (Util .isVirtual (thread )) {
286
+ if (thread .isVirtual ()) {
288
287
times [0 ] = -1 ;
289
288
} else {
290
289
times [0 ] = getThreadTotalCpuTime0 (0 );
@@ -327,7 +326,7 @@ protected long[] getThreadUserTime(long[] ids) {
327
326
long id = ids [0 ];
328
327
Thread thread = Thread .currentThread ();
329
328
if (id == thread .threadId ()) {
330
- if (Util .isVirtual (thread )) {
329
+ if (thread .isVirtual ()) {
331
330
times [0 ] = -1 ;
332
331
} else {
333
332
times [0 ] = getThreadUserCpuTime0 (0 );
@@ -361,7 +360,7 @@ public void setThreadCpuTimeEnabled(boolean enable) {
361
360
}
362
361
363
362
protected long getCurrentThreadAllocatedBytes () {
364
- if (isThreadAllocatedMemoryEnabled () && !Util . isVirtual ( Thread .currentThread ())) {
363
+ if (isThreadAllocatedMemoryEnabled () && !Thread .currentThread (). isVirtual ( )) {
365
364
return getThreadAllocatedMemory0 (0 );
366
365
}
367
366
return -1 ;
@@ -377,7 +376,7 @@ protected long getThreadAllocatedBytes(long id) {
377
376
if (verified ) {
378
377
Thread thread = Thread .currentThread ();
379
378
if (id == thread .threadId ()) {
380
- if (Util .isVirtual (thread )) {
379
+ if (thread .isVirtual ()) {
381
380
return -1L ;
382
381
} else {
383
382
return getThreadAllocatedMemory0 (0 );
@@ -577,7 +576,7 @@ public ObjectName getObjectName() {
577
576
*/
578
577
private static long [] platformThreadIds (Thread [] threads ) {
579
578
return Stream .of (threads )
580
- .filter (t -> !Util .isVirtual (t ))
579
+ .filter (t -> !t .isVirtual ())
581
580
.mapToLong (Thread ::threadId )
582
581
.toArray ();
583
582
}
0 commit comments