< prev index next >
src/share/classes/com/sun/tools/example/debug/gui/ThreadTreeTool.java
Print this page
rev 1388 : 6600143: Remove another 450 unnecessary casts
Reviewed-by: alanb, iris, lmalvent, bristor, peterjones, darcy, wetmore
*** 131,143 ****
// SessionListener
public void sessionStart(EventObject e) {
try {
! Iterator iter = runtime.allThreads().iterator();
! while (iter.hasNext()) {
! ThreadReference thread = ((ThreadReference)iter.next());
root.addThread(thread);
}
} catch (VMDisconnectedException ee) {
// VM went away unexpectedly.
} catch (NoSessionException ee) {
--- 131,141 ----
// SessionListener
public void sessionStart(EventObject e) {
try {
! for (ThreadReference thread : runtime.allThreads()) {
root.addThread(thread);
}
} catch (VMDisconnectedException ee) {
// VM went away unexpectedly.
} catch (NoSessionException ee) {
*** 242,261 ****
// Ignore. Thread will not be added.
}
}
}
! private void addThread(List threadPath, ThreadReference thread) {
int size = threadPath.size();
if (size == 0) {
return;
} else if (size == 1) {
! String name = (String)threadPath.get(0);
insertNode(name, thread);
} else {
! String head = (String)threadPath.get(0);
! List tail = threadPath.subList(1, size);
ThreadTreeNode child = insertNode(head, null);
child.addThread(tail, thread);
}
}
--- 240,259 ----
// Ignore. Thread will not be added.
}
}
}
! private void addThread(List<String> threadPath, ThreadReference thread) {
int size = threadPath.size();
if (size == 0) {
return;
} else if (size == 1) {
! String name = threadPath.get(0);
insertNode(name, thread);
} else {
! String head = threadPath.get(0);
! List<String> tail = threadPath.subList(1, size);
ThreadTreeNode child = insertNode(head, null);
child.addThread(tail, thread);
}
}
*** 286,306 ****
if (threadPath != null) {
removeThread(threadPath, thread);
}
}
! private void removeThread(List threadPath, ThreadReference thread) {
int size = threadPath.size();
if (size == 0) {
return;
} else if (size == 1) {
! String name = (String)threadPath.get(0);
ThreadTreeNode child = findLeafNode(thread, name);
treeModel.removeNodeFromParent(child);
} else {
! String head = (String)threadPath.get(0);
! List tail = threadPath.subList(1, size);
ThreadTreeNode child = findInternalNode(head);
child.removeThread(tail, thread);
if (child.isThreadGroup() && child.getChildCount() < 1) {
// Prune non-leaf nodes with no children.
treeModel.removeNodeFromParent(child);
--- 284,304 ----
if (threadPath != null) {
removeThread(threadPath, thread);
}
}
! private void removeThread(List<String> threadPath, ThreadReference thread) {
int size = threadPath.size();
if (size == 0) {
return;
} else if (size == 1) {
! String name = threadPath.get(0);
ThreadTreeNode child = findLeafNode(thread, name);
treeModel.removeNodeFromParent(child);
} else {
! String head = threadPath.get(0);
! List<String> tail = threadPath.subList(1, size);
ThreadTreeNode child = findInternalNode(head);
child.removeThread(tail, thread);
if (child.isThreadGroup() && child.getChildCount() < 1) {
// Prune non-leaf nodes with no children.
treeModel.removeNodeFromParent(child);
< prev index next >