how to get parameter names that are there in the .class file
hi...
package piotrk.example.asm;
import java.io.IOException;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.commons.EmptyVisitor;
/**
* This is a simple example showing how to retrieve Local Variable
Table (LVT)
* information (including method parameter names) from a class file using
* <em>ObjectWeb ASM 2.1</em>.
* <p>
* <b>Important:</b> To see expected results this should be compiled with
* <em>-g:vars</em> option.
*
* @author piotrk
*/
public class ShowLVT {
public static void main(String[] args) throws IOException {
String className = ShowLVT.class.getName();
new ClassReader(className)
.accept(new EmptyVisitor() {
@Override
public MethodVisitor visitMethod(int access, String name,
String desc, String signature, String[] exceptions) {
System.out.println("method name=" + name + ", desc=" +
desc);
return this;
}
@Override
public void visitLocalVariable(String name, String desc,
String signature, Label start, Label end, int index) {
System.out.println("local name=" + name + ", desc=" + desc
+ ", index=" + index);
}
}, false);
}
}
Is it possible to get the Parameter Names that are stored in the .class file using javac filename.java -g:vars