我正在使用这个 hack:我定义了一个 Java 类Debugger
,它看起来像这样:
public class Debugger {
private static final Logger log = LoggerFactory.getLogger( Debugger.class );
/**
* Invoke this method anywhere to end up in the Java debugger.
*
* <p>Sometimes, you have code that might eventually be executed or you have a place
* where you want to stop but no code line.
*
* <p>In these case, use this method.
*
* <p>Don't forget to set a breakpoint, first :-)
* */
public static void stopInDebugger() {
log.error( "Please set a breakpoint in Debugger.stopInDebugger() and try again whatever you just did!" );
}
}
我log.error
在 Ecipse 的行中有一个断点。
现在,我可以将此行放入需要断点的脚本中:
Debugger.stopInDebugger();
当然,它不允许我轻松地单步执行脚本,但总比没有好。