BCEL bytecode, how to get method source line?

178 Views Asked by At

I want to get the number of line where a method is in a class. I was doing this getting the first LineNumber of the method, and getting the src_line from that. But, it doesn't work because comments and initializations doesn't have LineNumber initialization.

Actual code that doesn't work:

MethodGen.getLineNumbers()[0].getSourceLine() - 1

In my project, I've instances of Method and MethodGen. Thanks.

0

There are 0 best solutions below