/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
//### Bug: If the name of a thread is changed via Thread.setName(), the
//### thread tree view does not reflect this. The name of the thread at
//### the time it is created is used throughout its lifetime.
super(new BorderLayout());
// Create a tree that allows one selection at a time.
public void mouseClicked(MouseEvent e) {
if(selRow != -1) {
if(e.getClickCount() == 1) {
// If user clicks on leaf, select it, and issue 'thread' command.
node.getThreadId() +
" (\"" +
}
}
}
}
};
// Create listener.
//### remove listeners on exit!
}
// May exit abnormally if VM disconnects.
}
return l;
}
implements JDIListener, SessionListener {
// SessionListener
try {
}
} catch (VMDisconnectedException ee) {
// VM went away unexpectedly.
} catch (NoSessionException ee) {
// Ignore. Should not happen.
}
}
// JDIListener
}
}
// Clear the contents of this view.
}
}
}
long uid;
name = "<unnamed>";
}
this.uid = -1;
this.description = name;
} else {
}
}
return description;
}
return name;
}
return thread;
}
}
private boolean isThreadGroup() {
}
public boolean isLeaf() {
return !isThreadGroup();
}
// This can fail if the VM disconnects.
// It is important to do all necessary JDI calls
// before modifying the tree, so we don't abort
// midway through!
// Add thread only if not already present.
try {
// May not get here due to exception.
// If we get here, we are committed.
// We must not leave the tree partially updated.
try {
//### Assertion failure.
throw new RuntimeException("ThreadTree corrupted");
}
} catch (VMDisconnectedException ee) {
// Ignore. Thread will not be added.
}
}
}
if (size == 0) {
return;
} else if (size == 1) {
} else {
}
}
for (int i = 0; i < getChildCount(); i++) {
// A like-named interior node already exists.
return child;
} else if (cmp < 0) {
// Insert new node before the child.
return newChild;
}
}
// Insert new node after last child.
return newChild;
}
// Only remove thread if we recorded it in table.
// Original add may have failed due to VM disconnect.
if (threadPath != null) {
}
}
if (size == 0) {
return;
} else if (size == 1) {
} else {
// Prune non-leaf nodes with no children.
}
}
}
for (int i = 0; i < getChildCount(); i++) {
//### Assertion failure.
throw new RuntimeException("name mismatch");
}
return child;
}
}
//### Assertion failure.
throw new RuntimeException("not found");
}
for (int i = 0; i < getChildCount(); i++) {
return child;
}
}
//### Assertion failure.
throw new RuntimeException("not found");
}
}
}