如何区分JVM类文件中的属性_info?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何区分JVM类文件中的属性_info?相关的知识,希望对你有一定的参考价值。

我正在挖掘The ClassFile Structure

根据上面提到的文件,attribute_info可以出现在各种位置。

我的问题是如何区分attribute_infos的类型?

我知道我可以通过他们的constant_infos区分tags。

我怎样才能区分attribute_infos?

所有attribute_info都是这样的。

attribute_info {
    u2 attribute_name_index;
    u4 attribute_length;
    u1 info[attribute_length];
}

Fields似乎有attribute_infoConstantValueSynthetic

我怎样才能区分他们的类型?

答案

我知道了。

constant_pool上的attribute_name_index条目必须是代表属性名称的CONSTANT_Utf8_info结构(§4.4.7)。

以上是关于如何区分JVM类文件中的属性_info?的主要内容,如果未能解决你的问题,请参考以下文章