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).
OK, I had an old class called "Debugging" in another project folder, which was a debugging-test. 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.
I tried debugging the Board constructor, added the original code from the constructor into a method and tried running that method in the constructor. 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.
精彩评论