开发者

Facing Issue with JDB - Breakpoint not being hit

I have the following piece of code:

void func()
{
  try
  {
    f1()
  }
  finally()
  {
     if (resource != null)
       resource.close();
  }
}

I put three breakpoints: call to f1(), inside f1(), on the if statement in the finally block.

It appears that the breakpoint in finall开发者_如何学Pythony block is not being hit. If after hitting the breakpoint inside f1() I step using the next command, I indeed end up going through the finally block.

Also If I put breakpoints on both the lines of the finally block, the breakpoint is indeed hit for the first one.

Not sure if this is due to a bug in JDB. Can someone tell me if this is a known issue or if I am missing something?

I am using JDK 6 on Linux.


I don't quite understand what unexpected behavior you're seeing, but JDB has no problem debugging if's, finally's, or if's inside of finally's. If you're seeing apparent breakpoints being skipped, then most likely you're looking at source code that differs from the bytecode that's running. It's possible to check the line numbers in the bytecode by disassembling it with

javap -c -l <simple class name>

in the same directory as the class file. It can also be run as

javap -c -l -classpath <build dir> <fully qualified class name>

It will show all of the instructions that each method contains with a numeric label. There will be a "LineNumberTable" that associates those labels to source code line numbers. Note: there are usually many bytecode instructions per source code line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜