I'm just analyzing code, not re-engineering.

What I want to do is get the corresponding line number in source code
for a given instruction. Here's my basic code.

Code code = method.getCode();
String instructions = Utility.codeToString(code.getCode(),
constantPool, 0, -1, false);
BufferedReader reader = new BufferedReader(new StringReader(instructions));
String line = null;
while(null != (line = reader.readLine())) {
  // How can I get the source code line number that corresponds to
this line in the instructions?
}

Another thing I want to do is analyze constructor invocations within code.

In the same code above inside the while loop I can recognize lines
that start with "new ", which tells me that a constructor is being
called. But, every time I see an object being "newed" it's always the
"<init>" method being invoked. Can I inspect the code in that method
as well?

I hope this all makes sense. I appreciate any help I can get.

Thanks.

- Laran Evans

---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscr...@jakarta.apache.org
For additional commands, e-mail: bcel-user-h...@jakarta.apache.org

Reply via email to