简体   繁体   English

有人可以帮我调试我的应用程序(不是很大)吗?

[英]Could someone help me debug my app (not very big)?

Not sure if this kind of help is accepted to ask for here, tell me if it isn't. 不知道是否可以接受这种帮助,请告诉我是否接受。

It has to get done before tomorrow, it's not entirerly finished but it should work somewhat ok by now. 它必须在明天之前完成,还没有完全完成,但是现在应该可以了。 I'm trying to use the Eclipse debugger (not very used to it). 我正在尝试使用Eclipse调试器(不是很习惯)。

OK, I had an old class called "Debugging" in another project folder, which was a debugging-test. 好的,我在另一个项目文件夹中有一个名为“ Debugging”的旧类,这是一个调试测试。 I didn't give it that name, it was an assignment. 我没有给它起这个名字,这是一个任务。 It seemed to cause some problems, removed it and now my stacktrace is much smaller. 它似乎引起了一些问题,将其删除,现在我的stacktrace小得多了。

I tried debugging the Board constructor, added the original code from the constructor into a method and tried running that method in the constructor. 我尝试调试Board构造函数,将来自构造函数的原始代码添加到方法中,并尝试在构造函数中运行该方法。 Which doesn't make any difference, but still. 这没有什么区别,但仍然如此。

Now the stacktrace looks like this: 现在,堆栈跟踪如下所示:

Thread [main] (Suspended)   
Board(Object).<init>() line: 20 
Board.<init>() line: 9  
Game.<init>() line: 15  
Game.main(String[]) line: 11    

The board constructor: 板子构造函数:

public class Board { 公开课董事会{

private int COLUMNS = 8;
private int ROWS = 8;
private Square[][] grid;

public Board(){
    addGrid();
}

public void addGrid(){
    grid = new Square[COLUMNS][ROWS];
    for(int row = 0; row < 8; row++){
        for(int col = 0; col < 8; col++){
            grid[col][row] = new Square(this);
        }
    }
}

The square constructor: 正方形构造函数:

public class Square {

    private Piece piece;
    private Board board;

    public Square(Board b){
        board = b;
    }

Among my breakpoints I noticed this: 在我的断点中,我注意到了这一点:

ArrayIndexOutOfBoundsException: caught and uncaught 

Tried again and got something similar as before: 再次尝试,并得到与以前相似的内容:

Thread [main] (Suspended)   
ClassNotFoundException(Throwable).<init>(String, Throwable) line: 217   
ClassNotFoundException(Exception).<init>(String, Throwable) line: not available 
ClassNotFoundException.<init>(String) 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.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  
Board.addGrid() line: 14    
Board.<init>() line: 10 
Game.<init>() line: 15  
Game.main(String[]) line: 11    

For whatever reason, your Game class cannot see the Board class. 无论出于何种原因,您的游戏班级都看不到棋盘班级。 If the code sections you posted are correct, it looks like it's because they don't have package declarations at the top of the code. 如果您发布的代码部分正确,则看起来是因为它们在代码顶部没有包声明。 You need to put something along the lines of this as the first line of your code: 您需要在代码的第一行中加上一些内容:

package boardGame;

public class Board {

etc. at the start of each class. 等在每个课程的开始。 Also, the package name must be the same as the name of the folder containing the source files. 另外,程序包名称必须与包含源文件的文件夹的名称相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM