quick guess: check if the previous instruction is ldc.
HTH,
Stephan
On 10.09.2017 21:50, Showalter, Jim wrote:
The use case is, suppose you want to recover the source from a .class file.
In the original source, it said:
public class SomeExperiment {
public static void main(String[] args) {
System.out.println(SomeOtherClass.class); <<< WANT TO RECOVER THE
".class" FROM HERE
}
}
In the visitor I wrote, there's an override:
public void visitConstantClass(final ConstantClass obj) {
String className =
JavaUtils.dotsToSlashes(javaClass().getConstantPool().getConstant(obj.getNameIndex()).toString());
System.out.println(class file name + ": " + className);
}
Dumping out the data on a .class from a .java file that contains no occurrences of the
string ".class", I get:
com/intuit/qbo/Misc.class: com/intuit/qbo/Misc$Reader
com/intuit/qbo/Misc.class: com/intuit/qbo/util/SomeException
com/intuit/qbo/Misc.class: com/intuit/qbo/Misc
com/intuit/qbo/Misc.class: com/intuit/qbo/api/MiscIf
This means ClassConstant isn't just for .class references. It's for all
references to classes.
How can I use BCEL to recover the original ".class" reference in SomeExperiment?
Jim Showalter
Programmer
Intuit, 2003H-265Z
Garcia Avenue
Mountain View, CA 94043
(408) 353-4954
(408) 204-1661
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]