我正在
com.sun.jdi.InvocationException发生了调用方法。误差..
创建对象时的对象。
代码就像:
SearchTree tree = new SearchTree();
// here I am getting com.sun.jdi.InvocationException
// occurred invoking method.
try
{
if (searchTreeNodes != null && searchTreeNodes.size() > 0)
{
for (SearchTreeNode node: searchTreeNodes)
{
tree.add(node);
}
}
}
添加方法:
public void add(SearchTreeNode data_) {
String[] ids = data_.getPath().split("/", 0);
if (ids.length == 1) {
System.out.println("Do nothing: There is no result.");
}
if (ids.length == 2) {
this.setData(data_);
} else {
String lastButOne = ids[ids.length - 2];
SearchTree foundNode = getNodeRecursive(this, lastButOne);
if (foundNode == null) {
System.out.println("Something is wrong: ");
} else {
foundNode.addChild(new SearchTree(data_));
}
}
}
public SearchTree getNodeRecursive(SearchTree node_, String nodeString_) {
if (node_ == null)
return null;
if (node_.getData().getCode().equals(nodeString_))
return node_;
if (node_.getChildren().size() > 0) {
for (SearchTree node : node_.getChildren()) {
SearchTree foundNode = getNodeRecursive(node, nodeString_);
if (foundNode != null) {
return foundNode;
}
}
}
return null;
}