我阅读了有关Java ClassFile的文章,并试图了解其中的每个字节。基本上,除了一件事情外,所有内容都是清楚的...在方法定义(代码属性)之后,有SourceFile属性。但在此之前还有一个字节。
Hello.java
public class Hello {
}
Hello.class
CA FE BA BE 00 00 00 34 00 0D 0A 00 03 00 0A 07 00 0B 07
00 0C 01 00 06 3C 69 6E 69 74 3E 01 00 03 28 29 56 01 00
04 43 6F 64 65 01 00 0F 4C 69 6E 65 4E 75 6D 62 65 72 54
61 62 6C 65 01 00 0A 53 6F 75 72 63 65 46 69 6C 65 01 00
0A 48 65 6C 6C 6F 2E 6A 61 76 61 0C 00 04 00 05 01 00 05
48 65 6C 6C 6F 01 00 10 6A 61 76 61 2F 6C 61 6E 67 2F 4F
62 6A 65 63 74 00 21 00 02 00 03 00 00 00 00 00 01 00 01
00 04 00 05 00 01 00 06 00 00 00 1D 00 01 00 01 00 00 00
05 2A B7 00 01 B1 00 00 00 01 00 07 00 00 00 06 00 01 00
00 00 01 00 01 00 08 00 00 00 02 00 09
我们对以下字节感兴趣:(这些是最后一个)
Code attribute 06 00 00 00 1D 00 01 00 01 00 00 00 05 2A B7 00 01 B1 00
00 00 01 00 07 00 00 00 06 00 01 00 00 00 01
What are these? 00 01
SourceFile attribute 00 08 00 00 00 02 00 09
分析了Code属性的数据
答案 0 :(得分:2)
应为attributes_count
。
attributes_count
项的值表示Code属性的属性数。
来源:
https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 https://en.wikipedia.org/wiki/Java_class_file