-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass_File.java
More file actions
109 lines (87 loc) · 3.36 KB
/
Copy pathClass_File.java
File metadata and controls
109 lines (87 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package model;
public class Class_File extends Table {
public String class_file_path;
public U4 magic;
public U2 minor_version;
public U2 major_version;
public U2 constant_pool_count;
public Constant_Info[] constant_infos;
public Class_Access_Flag class_access_flag;
public Class_Interface_Info this_class;
public Class_Interface_Info super_class;
public U2 interfaces_count;
public Class_Interface_Info[] interfaces;
public U2 fields_count;
public Field_Info[] field_infos;
public U2 methods_count;
public Method_Info[] method_infos;
public U2 attributes_count;
public Attribute_Info[] attribute_infos;
public void newBytes() {
super.newBytes();
}
private StringBuilder sb;
private void append(String s) {
sb.append(s);
sb.append("\n");
}
public String toString() {
sb = new StringBuilder();
append("--------Begin Parse Class File " + class_file_path + "--------");
append("--------Begin Magic--------");
append("magic: " + magic.parseBytesToHexString());
append("--------End Magic--------");
append("");
append("--------Begin Version--------");
append("minor_version: " + minor_version);
append("major_version: " + major_version);
append("--------End Version--------");
append("");
append("--------Begin Constant Pool--------");
append("constant_pool_count: " + constant_pool_count);
for (int i = 1; i < constant_pool_count.getValue(); i ++) {
append("[" + i + "] " + constant_infos[i]);
}
append("--------End Constant Pool--------");
append("");
append("--------Begin Access Flag--------");
append("[access_flag] " + class_access_flag);
append("--------END Access Flag--------");
append("");
append("--------Begin Class & Interfaces--------");
append("[this_class] " + this_class);
append("");
append("[super_class] " + super_class);
append("");
append("interfaces_count: " + interfaces_count);
for (int i = 0; i < interfaces_count.getValue(); i ++) {
Class_Interface_Info interface_ = interfaces[i];
append("[" + i + "] " + interface_);
}
append("--------End Class & Interfaces--------");
append("");
append("--------Begin Fields--------");
append("fields_count: " + fields_count);
for (int i = 0; i < fields_count.getValue(); i ++) {
append("[" + i + "] " + field_infos[i]);
}
append("--------End Fields--------");
append("");
append("--------Begin Methods--------");
append("methods_count: " + methods_count);
for (int i = 0; i < methods_count.getValue(); i ++) {
append("[" + i + "] " + method_infos[i]);
}
append("--------End Methods--------");
append("");
append("--------Begin Attributes--------");
append("attributes_count: " + attributes_count);
for (int i = 0; i < attributes_count.getValue(); i ++) {
append("[" + i + "] " + attribute_infos[i]);
}
append("--------End Attributes--------");
append("");
append("--------End Parse Class File " + class_file_path + "--------");
return sb.toString();
}
}