Java:构造对象矩阵时出现 Eclipse ClassNotFound 异常



我在 Java 中实现了一个四重链表作为 Node 对象的矩阵,我已经实现了它作为一个内部类:

public class Test {
    private Node[][] Matrix;
    class Node {
        int data; 
        Node up;
        Node down;
        Node left;
        Node right;
    }
    public Test() {
        Matrix = new Node[10][10];
        for (int col = 0; col < 10; col++) {
            for (int row = 0; row < 10; row++) {
                Matrix[row][col] = new Node();
            }
        }
    }
    public static void main(String[] args) {
        Test test = new Test();
    }
}

首先,这是正确/最好的方法吗? 其次,虽然它运行良好,但当我逐行调试时,我得到错误Test(Object).<init>() line: 37 [local variables unavailable],并且在我前进到行Matrix = new Node[10][10];之前还有一个Source not found窗口。然后它卡在那行,并给我一个 ClassNotFound 异常:

owns: Object  (id=28)   
owns: Object  (id=29)   
ClassNotFoundException(Throwable).<init>(String, Throwable) line: 286   
ClassNotFoundException(Exception).<init>(String, Throwable) line: not available 
ClassNotFoundException(ReflectiveOperationException).<init>(String, Throwable) line: not available  
ClassNotFoundException.<init>(String) line: not available   
URLClassLoader$1.run() line: not available  
URLClassLoader$1.run() line: not available  
AccessController.doPrivileged(PrivilegedExceptionAction<T>, AccessControlContext) line: not available [native method]   
Launcher$ExtClassLoader(URLClassLoader).findClass(String) line: not available   
Launcher$ExtClassLoader(ClassLoader).loadClass(String, boolean) line: not available 
Launcher$AppClassLoader(ClassLoader).loadClass(String, boolean) line: not available 
Launcher$AppClassLoader.loadClass(String, boolean) line: not available  
Launcher$AppClassLoader(ClassLoader).loadClass(String) line: not available  

为什么会这样?

谢谢!

可能是您有一个不需要的断点?调试视图上的堆栈是否显示Thread[main] (Suspended...)消息?转到"断点"视图,删除所有断点,在 Test 类上再次设置断点,然后再次尝试调试。

查看这篇文章(最初在此答案上看到)。

进一步思考,我认为这实际上不是一个错误。 它使用 Object 的默认构造函数,Eclipse 很可能无法访问源代码(因为它是 Java 库或其他库的一部分)。 不确定,但这是我最好的答案。

最好的解决方案是跨步,而不是介入 Node 的构建。

最新更新