Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 ASM 为 Java 类文件编写分析器。我要确定的一件事是类中字段的修饰符(public、static、final?)是什么。但我不知道该怎么做。
在文档中,我找到了修饰符的操作码,这似乎与 FieldNode 类的访问值相关。但是我看不出我是如何从这个值中导出字段的修饰符的。
有什么建议么?
访问成员变量是一个位域,每个位位置对应一个特定的访问修饰符。要检查一下,您必须使用带有常量 from 的二进制 ANDOpcodes并检查结果是否不为零。例如:
Opcodes
boolean isPublic = (node.access & Opcodes.ACC_PUBLIC) != 0; boolean isStatic = (node.access & Opcodes.ACC_STATIC) != 0;