views:

735

answers:

1

So I'm (remotely) debugging some a java/jboss application in Eclipse, stepping through line by line. At one point, an array of GridSquare objects (GridSquare is a fairly simple, standalone class, contains a few properties and methods) is created by a method call, i.e:

GridSquare[] squares = this.theGrid.getSquares(14, 18, 220, 222);

...While when I actually execute the code, the squares array does get populated with GridSquare objects, I get something odd when stepping through the code and debugging. At a breakpoint on the line immediately following the assignment shown above, if I try to view the squares array, instead of a value I get this:

org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.

...Anyone know what that's about?

+1  A: 

Basically it means the class loader has not loaded the GridSquare[] class. That being said it sounds like a bug in the debugger in some way. The breakpoint association with the code seems to be slightly broken. Either you need to recompile to get the line numbers in sync or some other issue is going on. At that point in the code (after the assignment) it needs to be loaded. Unless getSquares actually returns a subclass (GridSquareSubclass[]) at which point the JVM may not have loaded it because it doesn't need it (yet).

Yishai
Is there some way to force the JVM to load a class at a particular moment? Something similar to a compiler directive?
DanM
You can load the class in your code just to force it to happen (like have a line which explicitly loads the class such as creating a new array of the type the line before). You could also try sending a directive via evaluate expression in the debugger. (Like a Class.forName() or Array.newInstance())
Yishai
That did it. Thanks!!
DanM