views:

92

answers:

1

Given a line number, the code file, as well as the compiled class file if necessary, what is the most elegant way to get the signature of the surrounding method (if the line number is even in a method)?

Things to keep in mind:

  • the line might not even be in a method
  • the line might be in a method of an inner or anonymous class


While Googling I discovered this duplicate question so I'm closing this down myself.

+1  A: 

That information should be available from the debugger meta information generated by the compiler.

javac -g:lines foo.java

Oliver Weichhold