访问.class文件中的符号表 [英] Accessing symbol table in .class files

查看:137
本文介绍了访问.class文件中的符号表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Java中的任意代码库,我想(概念上)创建符号和类型之间的USES和USED-BY关系的表.符号表包含我需要的信息.但是,编写前端似乎是一项艰巨的任务,并且有可能将我的项目变成更大的子项目.在我看来,没有理由,因为字节码,Java .class文件在其中必须包含每个类的这样一个符号表,以便它可以解析类型和引用.

For an arbitrary code base in Java, I want to create a table (conceptually) of USES and USED-BY relations between symbols and types. A symbol table has the information I need. However, writing a front end seems like a huge task and threatens to turn my project into an even bigger sub-project. There's no reason for this, it seems to me ,because bytecode, the Java .class file necessarily contains within it such a symbol table for each class so that it can resolve types and references.

我的问题是-

如何以编程方式访问一组 .class文件,以便我可以创建所需的USES/USED-BY表?已 任何人都已经做到了(肯定的答案是肯定的)并且是工具 要这样做还不是图书馆?

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字节码操作框架 .此教程具有从字节码中检索依赖项的示例.尽管可以使用最近引入的 RemappingClassAdapter .

Take a look at ASM bytecode manipulation framework. This tutorial has an example of dependencies retrieval from the bytecode. Though it can be significantly simplified if you use more recently introduced RemappingClassAdapter.

这篇关于访问.class文件中的符号表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆