views:

391

answers:

4

This is a jstack output from a running JVM

"FooThread" prio=10 tid=0x00007f159c2ca000 nid=0x6e21 waiting on condition ..snipped
    java.lang.Thread.State: TIMED_WAITING (sleeping) 
    at java.lang.Thread.sleep(Native Method)
    at com.myco.impl.QueueFooThread.run(Unknown Source)

I want the line number in QueueFooThread to show up like this frame for the Catalina process

 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1548)

What should I do during compilation/bootstrap time to enable this ? Thanks

+3  A: 

This may not be a complete answer, but passing the -g (debugging) option to javac enables the debugger (jdb) to display source information, including line numbers. I'm not sure if it'll work for your case.

David Zaslavsky
I had to do: -g:lines,source to get it to work.
ashitaka
Hm, I thought just -g would include all debugging info (including lines and source). But whatever works...
David Zaslavsky
+1  A: 

Compile your source with debug option. E.g.

<javac target="1.5" source="1.5" classpathref="class.path" srcdir="${src}" destdir="${build}" debug="true" encoding="UTF-8"/>
FoxyBOA
A: 

You need to enable debugging when the code is compiled. Note: For libraries, they have to have debugging enabled when they are compiled.

Peter Lawrey
A: 

Compiling with debug info is the best of course. But if it's not your source, you can always decompile with something like jad. That doesn't help you with line numbers but if you make some educated guesses it can still be useful in a pinch.

Alex Miller