mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-11 10:58:26 +00:00
8274662: Replace 'while' cycles with iterator with enhanced-for in jdk.hotspot.agent
Reviewed-by: amenkov, cjplummer, sspitsyn
This commit is contained in:
parent
9629627e2c
commit
c06df25a4f
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,16 +55,14 @@ public class DeadlockDetector {
|
||||
heap = VM.getVM().getObjectHeap();
|
||||
createThreadTable();
|
||||
|
||||
Iterator i = threadTable.entrySet().iterator();
|
||||
while (i.hasNext()) {
|
||||
Entry e = (Entry)i.next();
|
||||
if (dfn(e) >= 0) {
|
||||
for (Entry<JavaThread, Integer> e : threadTable.entrySet()) {
|
||||
if (e.getValue() >= 0) {
|
||||
// this thread was already visited
|
||||
continue;
|
||||
}
|
||||
|
||||
thisDfn = globalDfn;
|
||||
JavaThread thread = (JavaThread)e.getKey();
|
||||
JavaThread thread = e.getKey();
|
||||
previousThread = thread;
|
||||
|
||||
// When there is a deadlock, all the monitors involved in the dependency
|
||||
@ -118,7 +116,7 @@ public class DeadlockDetector {
|
||||
break;
|
||||
}
|
||||
previousThread = currentThread;
|
||||
waitingToLockMonitor = (ObjectMonitor)currentThread.getCurrentPendingMonitor();
|
||||
waitingToLockMonitor = currentThread.getCurrentPendingMonitor();
|
||||
if (concurrentLocks) {
|
||||
waitingToLockBlocker = currentThread.getCurrentParkBlocker();
|
||||
}
|
||||
@ -162,10 +160,6 @@ public class DeadlockDetector {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static int dfn(Entry e) {
|
||||
return ((Integer)e.getValue()).intValue();
|
||||
}
|
||||
|
||||
private static void printOneDeadlock(PrintStream tty, JavaThread thread,
|
||||
boolean concurrentLocks) {
|
||||
tty.println("Found one Java-level deadlock:");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,6 @@
|
||||
package sun.jvm.hotspot.ui;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
@ -193,9 +192,8 @@ public class FindInHeapPanel extends JPanel {
|
||||
|
||||
private synchronized void updateResultWindow() {
|
||||
if (updates.size() > 0) {
|
||||
Iterator i = updates.iterator();
|
||||
while (i.hasNext()) {
|
||||
textArea.append((String)i.next());
|
||||
for (String update : updates) {
|
||||
textArea.append(update);
|
||||
}
|
||||
updates = new ArrayList<>();;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user