Hello. I was just minding my own business with an inner class and BOOM, NoClassDefFoundError. I’ve done nothing wrong or weird, but it keeps throwing it at me every time I use the inner class!
The line where the error is thrown:
ScriptFunctions.queuePathfinding(new Callback(unit), unit.getX(), unit.getY(),
width * (0.5 - unitArea/2) + Math.random()*width * unitArea,
height * (0.5 - unitArea/2) + Math.random() * height * unitArea);
queuePathfinding is defined as the following:
public static void queuePathfinding(PathfinderCallback callback, double startX, double startY, double destX, double destY)
PathfinderCallback is just a simple interface:
public interface PathfinderCallback {
public void result(ScriptPath path);
}
(I removed the package line)
Callback is just a simple inner class:
private class Callback implements PathfinderCallback{
public ScriptUnit unit;
public Callback(ScriptUnit unit){
this.unit = unit;
}
@Override
public void result(ScriptPath path) {
if(path.found()){
unit.setState(path);
}
}
}
Everything compiles fine and if I comment out the failing line, everything works fine. Even just
new Callback(unit);
crashes! I’ve also made sure that the extra .class file for the inner class is being generated! What the hell is wrong?!