如何使用javassist获取常量池表

时间:2022-01-28 13:13:59

How we can get the constant pool table from the class file using javassist? I hava wtitten the code till here,

我们如何使用javassist从类文件中获取常量池表?我把这些代码重新编码到这里,

ClassPool pool = ClassPool.getDefault(); pool.insertClassPath(filepath); CtClass cc = pool.get(filename);

ClassPool pool = ClassPool.getDefault(); pool.insertClassPath(文件路径); CtClass cc = pool.get(filename);

now please please tell me the further steps.

现在请告诉我进一步的步骤。

1 个解决方案

#1


0  

Once you have the CtClass you just need to access the classFile object to retrieve the constant pool, like the following:

获得CtClass后,您只需要访问classFile对象以检索常量池,如下所示:

ClassPool pool = ClassPool.getDefault(); 
pool.insertClassPath(filepath); 
CtClass cc = pool.get(filename);
ConstPool classConstantPool = cc.getClassFile().getConstPool()

#1


0  

Once you have the CtClass you just need to access the classFile object to retrieve the constant pool, like the following:

获得CtClass后,您只需要访问classFile对象以检索常量池,如下所示:

ClassPool pool = ClassPool.getDefault(); 
pool.insertClassPath(filepath); 
CtClass cc = pool.get(filename);
ConstPool classConstantPool = cc.getClassFile().getConstPool()