对于 Java 中的任意代码库,我想创建一个(概念上)符号和类型之间的 USES 和 USED-BY 关系表。符号表包含我需要的信息。然而,编写前端似乎是一项艰巨的任务,并且有可能将我的项目变成一个更大的子项目。在我看来,这是没有原因的,因为字节码、Java .class 文件中必然包含每个类的符号表,以便它可以解析类型和引用。
我的问题是 -
How can I programmaticly access the symbol table inside a set of .class files so that I can create the USES / USED-BY table I want? Has anyone already done this (surely the answer is yes) and is the tool to do this not already a library ?
最佳答案
看看ASM bytecode manipulation framework 。这个tutorial有一个从字节码检索依赖项的示例。不过,如果您使用最近推出的RemappingClassAdapter,它可以显着简化。 .
关于java - 访问 .class 文件中的符号表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10979102/