how to using bcel classparaser to get class names ,element names and method names ? ive already find a way to get class names but element and method names give me something wrong . Anyone can help me with that ? here is my code (with some errors there, and not completed):
import java.io.IOException;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import org.apache.bcel.classfile.ClassParser;
import org.apache.bcel.generic.ConstantPoolGen;
public final class BcelTest
{
// static int methods;
public static void main(String[] args)
{
ClassParser parser;
try
{
JarFile jar = new JarFile("C:\\Users\\OOO\\Desktop\\Sample.Jar");
Enumeration<JarEntry> entries = jar.entries();
ConstantPoolGen cpg = jar.entries();
while (entries.hasMoreElements())
{
JarEntry entry = entries.nextElement();
if (!entry.getName().endsWith(".class"))
continue;
parser =
new ClassParser("C:\\Users\\OOO\\Desktop\\Sample.Jar",
entry.getName());
methods = getMethodName(cpg);
MyClassVisitor visitor = new MyClassVisitor(parser.parse());
visitor.start();
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
public String getMethodName(ConstantPoolGen cpg)
{
return getMethodName(cpg);
}
}