try to get a code statement with BCEL library
Wayne Chien <[email protected]>
| Newsgroups | gmane.comp.jakarta.bcel.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am using BCEL to parse a java class file to get the information
I need and I run into the following issue:
Question: How can I get a line of code that I am interested from a
class file? This is what my current implementation:
"Utility.codeToString(mthd.getCode().getCode(), mthd.getConstantPool(), 0, -1)"
But this code will generate a bunch of instructions like this:
1: getfield myPackageName.myClass.m_myObj LmySuperClass; (177)
4: ldc " aValue" (185)
6: invokevirtual mySuperClass.getFieldValue
(Ljava/lang/String;)Ljava/lang/String; (186)
9: invokevirtual java.lang.String.toString ()Ljava/lang/String; (15)
Instead, I wish I can locate a code string like this:
"String prevValue = m_myObj.getFieldValue("aValue").toString();"
Do you have any better way to achieve this?
Thank you in advance…