JsArray<?> 的大小为 1 但得到 "java.lang.IndexOutOfBoundsException: Index: 0, Size: 0"

JsArray<?> has size 1 but getting "java.lang.IndexOutOfBoundsException: Index: 0, Size: 0"

我开始为此失去理智..

我想做的就是从 NodeList

中排除某个 Node
private List<Node> excludeDraggedElement(JsArray<Node> jsNodeList) {

    List<Node> nodeList = new ArrayList<>();

    GWT.log(jsNodeList.length() + ""); // Prints: 1

    for(int i = 0; i < jsNodeList.length(); i++) {

        Element element = (Element)nodeList.get(i);

        if(element == this.draggedElement.getElement()) {
            continue;
        }           
        nodeList.add(jsNodeList.get(i));
    }

    return nodeList;
}

如您所料,输出是:

1
Uncaught java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

我也试过用splice

public native void remove(JsArray<?> removeFrom, int index, int count) /*-{
    removeFrom.splice(index, count);
}-*/;

但这是 giving me another error:

Uncaught TypeError: arr_0_g$.splice is not a function

知道如何解决这个问题吗?

节点列表为空。所以 nodeList.get(i) 抛出异常。