ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; u2 access_flags; u2 this_class; u2 super_class; u2 interfaces_count; u2 interfaces[interfaces_count]; u2 fields_count; field_info fields[fields_count]; u2 methods_count; method_info methods[methods_count]; u2 attributes_count; attribute_info attributes[attributes_count]; }
構造体の形を見る限りこのような構成になっている
となっているから、interfaces countまでは2バイトづつとっていけば良いだろう。

Interface Fieldsともにカウントがゼロで、メソッドが二つだった。
method_info { u2 access_flags; u2 name_index; u2 descriptor_index; u2 attributes_count; attribute_info attributes[attributes_count]; } attribute_info { u2 attribute_name_index; u4 attribute_length; u1 info[attribute_length]; }

これに前回の表をあてはめていく
|
No |
tag |
Index |
|
|
|
|
|
1 |
0A |
0006 |
0014 |
|
|
|
|
2 |
09 |
0015 |
0016 |
|
|
|
|
3 |
08 |
0017 |
|
|
|
|
|
4 |
0A |
0018 |
0019 |
|
|
|
|
5 |
07 |
001A |
|
|
|
|
|
6 |
07 |
001B |
|
|
|
|
|
7 |
01 |
|
|
<init> |
|
|
|
8 |
01 |
|
|
()V |
|
|
|
9 |
01 |
|
|
Code |
|
|
|
A |
01 |
|
|
LineNumberTable |
|
|
|
B |
01 |
|
|
LocalVariableTable |
|
|
|
C |
01 |
|
|
This |
|
|
|
D |
01 |
|
|
Ltest/test; |
|
|
|
E |
01 |
|
|
|
|
|
|
F |
01 |
|
|
([Ljava/lang/String;)V |
|
|
|
10 |
01 |
|
|
Args |
|
|
|
11 |
01 |
|
|
[Ljava/lang/String; |
|
|
|
12 |
01 |
|
|
SourceFile |
|
|
|
13 |
0C |
0007 |
0008 |
|
|
|
|
14 |
07 |
001C |
|
|
|
|
|
15 |
0C |
001D |
001E |
|
|
|
|
16 |
01 |
|
|
test.java |
|
|
|
17 |
07 |
001F |
|
|
|
|
|
18 |
0C |
0020 |
0021 |
|
|
|
|
19 |
01 |
|
|
ABCDEFG |
|
|
|
1A |
01 |
|
|
test/test |
|
|
|
1B |
01 |
|
|
java/lang/Object |
|
|
|
1C |
01 |
|
|
java/lang/System |
|
|
|
1D |
01 |
|
|
Out |
|
|
|
1E |
01 |
|
|
Ljava/io/PrintStream; |
|
|
|
1F |
01 |
|
|
java/io/PrintStream |
|
|
|
20 |
01 |
|
|
Println |
|
|
|
21 |
01 |
|
|
(Ljava/lang/String;)V |
|
|
|
|
|
|
|
|
|
|
|
No |
tag |
Index |
|
|
|
|
|
1 |
0A |
0006 |
0014 |
class_index java/lang/Object name_and_type_index <init> ()V |
CONSTANT_Methodref_info |
|
|
2 |
09 |
0015 |
||||