unageanu-javaclass 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +0 -0
- data/README +4 -0
- data/lib/javaclass/accessflag.rb +279 -0
- data/lib/javaclass/attribute.rb +1061 -0
- data/lib/javaclass/base.rb +369 -0
- data/lib/javaclass/class.rb +282 -0
- data/lib/javaclass/constant.rb +522 -0
- data/lib/javaclass/member.rb +194 -0
- data/lib/javaclass/reader.rb +449 -0
- data/lib/javaclass.rb +8 -0
- data/sample/class_list.rb +22 -0
- data/sample/create_assert.rb +69 -0
- data/sample/java_class/HelloWorld.class +0 -0
- data/sample/java_class/com/example/Constants.class +0 -0
- data/sample/java_class/com/example/Deprecated.class +0 -0
- data/sample/java_class/com/example/InnerClass$1.class +0 -0
- data/sample/java_class/com/example/InnerClass$BasicInnerClass.class +0 -0
- data/sample/java_class/com/example/InnerClass$StaticInnerClass$InnerInnerClass.class +0 -0
- data/sample/java_class/com/example/InnerClass$StaticInnerClass$StaticInnerInnerClass.class +0 -0
- data/sample/java_class/com/example/InnerClass$StaticInnerClass.class +0 -0
- data/sample/java_class/com/example/InnerClass.class +0 -0
- data/sample/java_class/com/example/InnerClassImpl$1.class +0 -0
- data/sample/java_class/com/example/InnerClassImpl$1MethodInnerClass.class +0 -0
- data/sample/java_class/com/example/InnerClassImpl$2.class +0 -0
- data/sample/java_class/com/example/InnerClassImpl$BasicInnerClass2.class +0 -0
- data/sample/java_class/com/example/InnerClassImpl$StaticInnerClass2.class +0 -0
- data/sample/java_class/com/example/InnerClassImpl.class +0 -0
- data/sample/java_class/com/example/Kitten.class +0 -0
- data/sample/java_class/com/example/ThrowsException.class +0 -0
- data/sample/java_class/com/example/annotation/Annotated.class +0 -0
- data/sample/java_class/com/example/annotation/AnnotatedMethod$A.class +0 -0
- data/sample/java_class/com/example/annotation/AnnotatedMethod$B.class +0 -0
- data/sample/java_class/com/example/annotation/AnnotatedMethod$C.class +0 -0
- data/sample/java_class/com/example/annotation/AnnotatedMethod.class +0 -0
- data/sample/java_class/com/example/annotation/ClassAnnotationA.class +0 -0
- data/sample/java_class/com/example/annotation/HasDefaultValue.class +0 -0
- data/sample/java_class/com/example/annotation/RuntimeAnnotationA.class +0 -0
- data/sample/java_class/com/example/annotation/RuntimeAnnotationB.class +0 -0
- data/sample/java_class/com/example/annotation/RuntimeAnnotationC.class +0 -0
- data/sample/java_class/com/example/annotation/SourceAnnotationA.class +0 -0
- data/sample/java_class/com/example/types/TypeVariables.class +0 -0
- data/sample/java_src/HelloWorld.java +6 -0
- data/sample/java_src/com/example/Constants.java +45 -0
- data/sample/java_src/com/example/Deprecated.java +16 -0
- data/sample/java_src/com/example/InnerClass.java +23 -0
- data/sample/java_src/com/example/InnerClassImpl.java +31 -0
- data/sample/java_src/com/example/Kitten.java +78 -0
- data/sample/java_src/com/example/ThrowsException.java +12 -0
- data/sample/java_src/com/example/annotation/Annotated.java +47 -0
- data/sample/java_src/com/example/annotation/AnnotatedMethod.java +18 -0
- data/sample/java_src/com/example/annotation/ClassAnnotationA.java +10 -0
- data/sample/java_src/com/example/annotation/HasDefaultValue.java +10 -0
- data/sample/java_src/com/example/annotation/RuntimeAnnotationA.java +15 -0
- data/sample/java_src/com/example/annotation/RuntimeAnnotationB.java +10 -0
- data/sample/java_src/com/example/annotation/RuntimeAnnotationC.java +8 -0
- data/sample/java_src/com/example/annotation/SourceAnnotationA.java +10 -0
- data/sample/java_src/com/example/types/TypeVariables.java +19 -0
- data/sample/sample.rb +27 -0
- data/test/all-tests.rb +32 -0
- data/test/java_class/com/example/TestClass1$1.class +0 -0
- data/test/java_class/com/example/TestClass1$Hoo.class +0 -0
- data/test/java_class/com/example/TestClass1$Var.class +0 -0
- data/test/java_class/com/example/TestClass1.class +0 -0
- data/test/java_src/com/example/TestClass1.java +28 -0
- data/test/test_access_flag.rb +205 -0
- data/test/test_attribute.rb +955 -0
- data/test/test_class.rb +90 -0
- data/test/test_constant.rb +830 -0
- data/test/test_member.rb +282 -0
- data/test/test_util.rb +20 -0
- metadata +157 -0
@@ -0,0 +1,1061 @@
|
|
1
|
+
require "javaclass/base"
|
2
|
+
|
3
|
+
module JavaClass
|
4
|
+
|
5
|
+
#
|
6
|
+
#=== 属性の基底クラス
|
7
|
+
#
|
8
|
+
class Attribute
|
9
|
+
include JavaClass::Base
|
10
|
+
|
11
|
+
#
|
12
|
+
#===コンストラクタ
|
13
|
+
#
|
14
|
+
#*java_class::属性の所有者であるJavaクラス
|
15
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
16
|
+
#
|
17
|
+
def initialize( java_class, name_index )
|
18
|
+
@java_class = java_class
|
19
|
+
@name_index = name_index
|
20
|
+
end
|
21
|
+
#
|
22
|
+
#===属性名を取得する。
|
23
|
+
#
|
24
|
+
#<b>戻り値</b>::属性名
|
25
|
+
#
|
26
|
+
def name
|
27
|
+
@java_class.get_constant_value(@name_index)
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_bytes
|
31
|
+
to_byte( @name_index, 2)
|
32
|
+
end
|
33
|
+
|
34
|
+
attr :java_class, true
|
35
|
+
attr :name_index, true
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
#=== 定数値属性
|
40
|
+
#
|
41
|
+
class ConstantValueAttribute < Attribute
|
42
|
+
#
|
43
|
+
#===コンストラクタ
|
44
|
+
#
|
45
|
+
#*java_class::属性の所有者であるJavaクラス
|
46
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
47
|
+
#*constant_value_index::定数値を示すconstant_poolのインデックス
|
48
|
+
#
|
49
|
+
def initialize( java_class, name_index, constant_value_index )
|
50
|
+
super( java_class, name_index)
|
51
|
+
@constant_value_index = constant_value_index
|
52
|
+
end
|
53
|
+
#
|
54
|
+
#===定数値を取得する。
|
55
|
+
#
|
56
|
+
#<b>戻り値</b>::定数値
|
57
|
+
#
|
58
|
+
def value
|
59
|
+
@java_class.get_constant_value(@constant_value_index)
|
60
|
+
end
|
61
|
+
#
|
62
|
+
#===定数値の文字列表現を取得する。
|
63
|
+
#
|
64
|
+
#<b>戻り値</b>::定数値の文字列表現
|
65
|
+
#
|
66
|
+
def to_s
|
67
|
+
@java_class.get_constant_as_string(@constant_value_index)
|
68
|
+
end
|
69
|
+
|
70
|
+
def to_bytes
|
71
|
+
bytes = super
|
72
|
+
bytes += to_byte( 2, 4)
|
73
|
+
bytes += to_byte( @constant_value_index, 2)
|
74
|
+
end
|
75
|
+
|
76
|
+
#定数値を示すconstant_poolのインデックス
|
77
|
+
attr :constant_value_index, true
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
#=== 例外属性
|
82
|
+
#
|
83
|
+
class ExceptionsAttribute < Attribute
|
84
|
+
#
|
85
|
+
#===コンストラクタ
|
86
|
+
#
|
87
|
+
#*java_class::属性の所有者であるJavaクラス
|
88
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
89
|
+
#*constant_value_index::定数値を示すconstant_poolのインデックス
|
90
|
+
#
|
91
|
+
def initialize( java_class, name_index, exception_index_table )
|
92
|
+
super( java_class, name_index)
|
93
|
+
@exception_index_table = exception_index_table
|
94
|
+
end
|
95
|
+
#
|
96
|
+
#===例外の配列を取得する。
|
97
|
+
#
|
98
|
+
#<b>戻り値</b>::例外の配列
|
99
|
+
#
|
100
|
+
def exceptions
|
101
|
+
exception_index_table.map() {|index|
|
102
|
+
@java_class.get_constant(index)
|
103
|
+
}
|
104
|
+
end
|
105
|
+
def to_s
|
106
|
+
"throws " << exceptions.map(){|ex| ex.name }.join(", ")
|
107
|
+
end
|
108
|
+
def to_bytes
|
109
|
+
bytes = super
|
110
|
+
bytes += to_byte( 2+(2 * (@exception_index_table.length)), 4)
|
111
|
+
bytes += to_byte( @exception_index_table.length, 2)
|
112
|
+
@exception_index_table.each {|index|
|
113
|
+
bytes += to_byte( index, 2)
|
114
|
+
}
|
115
|
+
return bytes
|
116
|
+
end
|
117
|
+
#例外テーブル
|
118
|
+
attr :exception_index_table, true
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
#=== インナークラス属性
|
123
|
+
#
|
124
|
+
class InnerClassesAttribute < Attribute
|
125
|
+
#
|
126
|
+
#===コンストラクタ
|
127
|
+
#
|
128
|
+
#*java_class::属性の所有者であるJavaクラス
|
129
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
130
|
+
#*constant_value_index::定数値を示すconstant_poolのインデックス
|
131
|
+
#
|
132
|
+
def initialize( java_class, name_index, classes )
|
133
|
+
super( java_class, name_index)
|
134
|
+
@classes = classes
|
135
|
+
end
|
136
|
+
def to_s
|
137
|
+
@classes.map{|c| c.to_s }.join( "\n" )
|
138
|
+
end
|
139
|
+
def to_bytes
|
140
|
+
bytes = super
|
141
|
+
body = to_byte( @classes.length, 2)
|
142
|
+
@classes.each {|c|
|
143
|
+
body += c.to_bytes()
|
144
|
+
}
|
145
|
+
bytes += to_byte( body.length, 4)
|
146
|
+
bytes += body
|
147
|
+
end
|
148
|
+
|
149
|
+
# インナークラスの配列
|
150
|
+
attr :classes, true
|
151
|
+
end
|
152
|
+
|
153
|
+
#
|
154
|
+
#=== インナークラス
|
155
|
+
#
|
156
|
+
class InnerClass
|
157
|
+
include JavaClass::Base
|
158
|
+
|
159
|
+
#
|
160
|
+
#===コンストラクタ
|
161
|
+
#
|
162
|
+
#*java_class::属性の所有者であるJavaクラス
|
163
|
+
#*inner_class_index::インナークラス情報を示すconstant_poolのインデックス
|
164
|
+
#*outer_class_index::インナークラスを所有するクラスの情報を示すconstant_poolのインデックス
|
165
|
+
#*name_index::インナークラス名を示すconstant_poolのインデックス
|
166
|
+
#*access_flag::アクセスフラグ
|
167
|
+
#
|
168
|
+
def initialize( java_class, inner_class_index=nil, \
|
169
|
+
outer_class_index=nil, name_index=nil, access_flag=nil )
|
170
|
+
@java_class = java_class
|
171
|
+
@inner_class_index = inner_class_index
|
172
|
+
@outer_class_index = outer_class_index
|
173
|
+
@name_index = name_index
|
174
|
+
@access_flag = access_flag
|
175
|
+
end
|
176
|
+
|
177
|
+
#
|
178
|
+
#===インナークラスの情報を取得する。
|
179
|
+
#
|
180
|
+
#<b>戻り値</b>::インナークラスの情報。
|
181
|
+
#
|
182
|
+
def inner_class
|
183
|
+
@java_class.get_constant( @inner_class_index )
|
184
|
+
end
|
185
|
+
|
186
|
+
#
|
187
|
+
#===インナークラスを所有するクラスの情報を取得する。
|
188
|
+
#
|
189
|
+
#<b>戻り値</b>::インナークラスを所有するクラスの情報。匿名クラスの場合はnullが返される。
|
190
|
+
#
|
191
|
+
def outer_class
|
192
|
+
@java_class.get_constant( @outer_class_index )
|
193
|
+
end
|
194
|
+
#
|
195
|
+
#===インナークラスの名前を取得する。無名クラスの場合nilが返される
|
196
|
+
#
|
197
|
+
#<b>戻り値</b>::インナークラスの名前。無名クラスの場合nilが返される
|
198
|
+
#
|
199
|
+
def name
|
200
|
+
@name_index == 0 ? nil : @java_class.get_constant_value(@name_index)
|
201
|
+
end
|
202
|
+
def to_s
|
203
|
+
str = "// use inner #{@access_flag.to_s}"
|
204
|
+
str << " " << inner_class.name if inner_class != nil
|
205
|
+
return str
|
206
|
+
end
|
207
|
+
def to_bytes
|
208
|
+
bytes = to_byte( @inner_class_index, 2)
|
209
|
+
bytes += to_byte( @outer_class_index, 2)
|
210
|
+
bytes += to_byte( @name_index, 2)
|
211
|
+
bytes += @access_flag.to_bytes()
|
212
|
+
end
|
213
|
+
# インナークラス情報を示すconstant_poolのインデックス
|
214
|
+
attr :inner_class_index, true
|
215
|
+
# インナークラスを所有するクラスの情報を示すconstant_poolのインデックス
|
216
|
+
attr :outer_class_index, true
|
217
|
+
# インナークラス名を示すconstant_poolのインデックス
|
218
|
+
attr :name_index, true
|
219
|
+
# アクセスフラグ
|
220
|
+
attr :access_flag, true
|
221
|
+
end
|
222
|
+
|
223
|
+
#
|
224
|
+
#=== クラスを同封するメソッドの属性
|
225
|
+
#
|
226
|
+
class EnclosingMethodAttribute < Attribute
|
227
|
+
#
|
228
|
+
#===コンストラクタ
|
229
|
+
#
|
230
|
+
#*java_class::属性の所有者であるJavaクラス
|
231
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
232
|
+
#*enclosing_class_index::クラスを同封するメソッドを持つクラスの情報を示すconstant_poolのインデックス
|
233
|
+
#*enclosing_method_index::クラスを同封するメソッドの情報を示すconstant_poolのインデックス
|
234
|
+
#
|
235
|
+
def initialize( java_class, name_index, class_index, method_index )
|
236
|
+
super( java_class, name_index)
|
237
|
+
@enclosing_class_index = class_index
|
238
|
+
@enclosing_method_index = method_index
|
239
|
+
end
|
240
|
+
#
|
241
|
+
#===クラスを同封するメソッドを持つクラスの情報を取得する。
|
242
|
+
#
|
243
|
+
#<b>戻り値</b>::クラスを同封するメソッドを持つクラスの情報
|
244
|
+
#
|
245
|
+
def enclosing_class
|
246
|
+
@java_class.get_constant( @enclosing_class_index )
|
247
|
+
end
|
248
|
+
#
|
249
|
+
#===クラスを同封するメソッドの情報を取得する。
|
250
|
+
#
|
251
|
+
#<b>戻り値</b>::クラスを同封するメソッドの情報
|
252
|
+
#
|
253
|
+
def enclosing_method
|
254
|
+
@java_class.get_constant( @enclosing_method_index )
|
255
|
+
end
|
256
|
+
def to_s
|
257
|
+
"// enclosed by #{enclosing_class.name}##{enclosing_method.name}"
|
258
|
+
end
|
259
|
+
def to_bytes
|
260
|
+
bytes = super
|
261
|
+
bytes += to_byte( 4, 4 )
|
262
|
+
bytes += to_byte( @enclosing_class_index, 2 )
|
263
|
+
bytes += to_byte( @enclosing_method_index, 2 )
|
264
|
+
end
|
265
|
+
|
266
|
+
# クラスを同封するメソッドを持つクラスの情報を示すconstant_poolのインデックス
|
267
|
+
attr :enclosing_class_index, true
|
268
|
+
# クラスを同封するメソッドの情報を示すconstant_poolのインデックス
|
269
|
+
attr :enclosing_method_index, true
|
270
|
+
end
|
271
|
+
|
272
|
+
|
273
|
+
#
|
274
|
+
#=== Deprecated属性
|
275
|
+
#
|
276
|
+
class DeprecatedAttribute < Attribute
|
277
|
+
#
|
278
|
+
#===コンストラクタ
|
279
|
+
#
|
280
|
+
#*java_class::属性の所有者であるJavaクラス
|
281
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
282
|
+
#
|
283
|
+
def initialize( java_class, name_index )
|
284
|
+
super( java_class, name_index)
|
285
|
+
end
|
286
|
+
def to_s
|
287
|
+
"// !!Deprecated!!"
|
288
|
+
end
|
289
|
+
def to_bytes
|
290
|
+
bytes = super
|
291
|
+
bytes += to_byte( 0, 4 )
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
#
|
296
|
+
#=== Synthetic属性
|
297
|
+
#
|
298
|
+
class SyntheticAttribute < Attribute
|
299
|
+
#
|
300
|
+
#===コンストラクタ
|
301
|
+
#
|
302
|
+
#*java_class::属性の所有者であるJavaクラス
|
303
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
304
|
+
#
|
305
|
+
def initialize( java_class, name_index )
|
306
|
+
super( java_class, name_index)
|
307
|
+
end
|
308
|
+
def to_bytes
|
309
|
+
bytes = super
|
310
|
+
bytes += to_byte( 0, 4 )
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
#
|
315
|
+
#=== ソースファイル属性
|
316
|
+
#
|
317
|
+
class SourceFileAttribute < Attribute
|
318
|
+
#
|
319
|
+
#===コンストラクタ
|
320
|
+
#
|
321
|
+
#*java_class::属性の所有者であるJavaクラス
|
322
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
323
|
+
#*source_file_index::ソースファイルを示すconstant_poolのインデックス
|
324
|
+
#
|
325
|
+
def initialize( java_class, name_index, source_file_index )
|
326
|
+
super( java_class, name_index)
|
327
|
+
@source_file_index = source_file_index
|
328
|
+
end
|
329
|
+
#
|
330
|
+
#===ソースファイル名を取得する。
|
331
|
+
#
|
332
|
+
#<b>戻り値</b>::ソースファイル名
|
333
|
+
#
|
334
|
+
def source_file
|
335
|
+
@java_class.get_constant_value(@source_file_index)
|
336
|
+
end
|
337
|
+
def to_s
|
338
|
+
"// source #{source_file}"
|
339
|
+
end
|
340
|
+
def to_bytes
|
341
|
+
bytes = super
|
342
|
+
bytes += to_byte( 2, 4)
|
343
|
+
bytes += to_byte( @source_file_index, 2)
|
344
|
+
end
|
345
|
+
# ソースファイルを示すconstant_poolのインデックス
|
346
|
+
attr :source_file_index, true
|
347
|
+
end
|
348
|
+
|
349
|
+
#
|
350
|
+
#=== ソースデバッグ拡張属性
|
351
|
+
#
|
352
|
+
class SourceDebugExtensionAttribute < Attribute
|
353
|
+
#
|
354
|
+
#===コンストラクタ
|
355
|
+
#
|
356
|
+
#*java_class::属性の所有者であるJavaクラス
|
357
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
358
|
+
#*debug_extension::デバッグ情報
|
359
|
+
#
|
360
|
+
def initialize( java_class, name_index, debug_extension )
|
361
|
+
super( java_class, name_index)
|
362
|
+
@debug_extension = debug_extension
|
363
|
+
end
|
364
|
+
def to_s
|
365
|
+
"// debug_extension #{debug_extension}"
|
366
|
+
end
|
367
|
+
def to_bytes
|
368
|
+
bytes = super
|
369
|
+
body = []
|
370
|
+
@debug_extension.each_byte {|i|
|
371
|
+
body += to_byte( i, 1 )
|
372
|
+
}
|
373
|
+
bytes += to_byte( body.length, 4 )
|
374
|
+
bytes += body
|
375
|
+
end
|
376
|
+
|
377
|
+
# デバッグ情報
|
378
|
+
attr :debug_extension, true
|
379
|
+
end
|
380
|
+
|
381
|
+
#
|
382
|
+
#=== シグネチャ属性
|
383
|
+
#
|
384
|
+
class SignatureAttribute < Attribute
|
385
|
+
#
|
386
|
+
#===コンストラクタ
|
387
|
+
#
|
388
|
+
#*java_class::属性の所有者であるJavaクラス
|
389
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
390
|
+
#*signature_index::シグネチャを示すconstant_poolのインデックス
|
391
|
+
#
|
392
|
+
def initialize( java_class, name_index, signature_index )
|
393
|
+
super( java_class, name_index)
|
394
|
+
@signature_index = signature_index
|
395
|
+
end
|
396
|
+
#
|
397
|
+
#===シグネチャを取得する。
|
398
|
+
#
|
399
|
+
#<b>戻り値</b>::シグネチャ
|
400
|
+
#
|
401
|
+
def signature
|
402
|
+
@java_class.get_constant_value(@signature_index)
|
403
|
+
end
|
404
|
+
def to_s
|
405
|
+
"// signature #{signature}"
|
406
|
+
end
|
407
|
+
def to_bytes
|
408
|
+
bytes = super
|
409
|
+
bytes += to_byte( 2, 4)
|
410
|
+
bytes += to_byte( @signature_index, 2)
|
411
|
+
end
|
412
|
+
# シグネチャを示すconstant_poolのインデックス
|
413
|
+
attr :signature_index, true
|
414
|
+
end
|
415
|
+
|
416
|
+
#
|
417
|
+
#=== アノテーション属性
|
418
|
+
#
|
419
|
+
class AnnotationsAttribute < Attribute
|
420
|
+
#
|
421
|
+
#===コンストラクタ
|
422
|
+
#
|
423
|
+
#*java_class::属性の所有者であるJavaクラス
|
424
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
425
|
+
#*annotations::アノテーションの配列
|
426
|
+
#
|
427
|
+
def initialize( java_class, name_index, annotations=[] )
|
428
|
+
super( java_class, name_index)
|
429
|
+
@annotations = annotations
|
430
|
+
end
|
431
|
+
def to_s
|
432
|
+
@annotations.map{|a| a.to_s }.join("\n")
|
433
|
+
end
|
434
|
+
def to_bytes
|
435
|
+
bytes = super
|
436
|
+
body = to_byte( @annotations.length, 2)
|
437
|
+
@annotations.each {|c|
|
438
|
+
body += c.to_bytes()
|
439
|
+
}
|
440
|
+
bytes += to_byte( body.length, 4)
|
441
|
+
bytes += body
|
442
|
+
end
|
443
|
+
|
444
|
+
attr :annotations, true
|
445
|
+
end
|
446
|
+
|
447
|
+
#
|
448
|
+
#=== アノテーション
|
449
|
+
#
|
450
|
+
class Annotation
|
451
|
+
include JavaClass::Base
|
452
|
+
include JavaClass::Converters
|
453
|
+
|
454
|
+
#
|
455
|
+
#===コンストラクタ
|
456
|
+
#
|
457
|
+
#*java_class::属性の所有者であるJavaクラス
|
458
|
+
#*type_index::アノテーションの種別を示すconstant_poolのインデックス
|
459
|
+
#*elements::アノテーションのデータペア一覧
|
460
|
+
#
|
461
|
+
def initialize( java_class, type_index, elements={} )
|
462
|
+
@java_class = java_class
|
463
|
+
@type_index = type_index
|
464
|
+
@elements = elements
|
465
|
+
end
|
466
|
+
def type
|
467
|
+
@java_class.get_constant_value(@type_index)
|
468
|
+
end
|
469
|
+
def to_s
|
470
|
+
str = "@" << convert_field_descriptor(type)
|
471
|
+
str << "(\n" unless @elements.empty?
|
472
|
+
str << @elements.map {|k,v| " " << v.to_s }.join( ",\n" )
|
473
|
+
str << "\n)" unless @elements.empty?
|
474
|
+
return str
|
475
|
+
end
|
476
|
+
def to_bytes
|
477
|
+
bytes = to_byte( @type_index, 2)
|
478
|
+
bytes += to_byte( @elements.size, 2)
|
479
|
+
@elements.each {|k,v|
|
480
|
+
bytes += v.to_bytes()
|
481
|
+
}
|
482
|
+
return bytes
|
483
|
+
end
|
484
|
+
|
485
|
+
attr :type_index, true
|
486
|
+
attr :elements, true
|
487
|
+
end
|
488
|
+
#
|
489
|
+
#=== アノテーションのデータ
|
490
|
+
#
|
491
|
+
class AnnotationElement
|
492
|
+
include JavaClass::Base
|
493
|
+
|
494
|
+
#
|
495
|
+
#===コンストラクタ
|
496
|
+
#
|
497
|
+
#*java_class::属性の所有者であるJavaクラス
|
498
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
499
|
+
#*value::値
|
500
|
+
#
|
501
|
+
def initialize( java_class, name_index=nil, value=nil )
|
502
|
+
@java_class = java_class
|
503
|
+
@name_index = name_index
|
504
|
+
@value = value
|
505
|
+
end
|
506
|
+
def name
|
507
|
+
@java_class.get_constant_value(@name_index)
|
508
|
+
end
|
509
|
+
def to_s
|
510
|
+
"#{name} = #{value.to_s}"
|
511
|
+
end
|
512
|
+
def to_bytes
|
513
|
+
bytes = to_byte( @name_index, 2)
|
514
|
+
bytes += @value.to_bytes()
|
515
|
+
end
|
516
|
+
|
517
|
+
attr :name_index, true
|
518
|
+
attr :value, true
|
519
|
+
end
|
520
|
+
|
521
|
+
#
|
522
|
+
#=== アノテーションデータの基底クラス
|
523
|
+
#
|
524
|
+
class AnnotationElementValue
|
525
|
+
include JavaClass::Base
|
526
|
+
include JavaClass::Converters
|
527
|
+
|
528
|
+
#
|
529
|
+
#===コンストラクタ
|
530
|
+
#
|
531
|
+
#*java_class::属性の所有者であるJavaクラス
|
532
|
+
#*tag::データの種別を示すconstant_poolのインデックス
|
533
|
+
#
|
534
|
+
def initialize( java_class, tag=nil )
|
535
|
+
@java_class = java_class
|
536
|
+
@tag = tag
|
537
|
+
end
|
538
|
+
def to_bytes
|
539
|
+
to_byte( @tag, 1)
|
540
|
+
end
|
541
|
+
|
542
|
+
attr :tag, true
|
543
|
+
end
|
544
|
+
|
545
|
+
#
|
546
|
+
#=== 定数のアノテーションデータ
|
547
|
+
#
|
548
|
+
class ConstAnnotationElementValue < AnnotationElementValue
|
549
|
+
#
|
550
|
+
#===コンストラクタ
|
551
|
+
#
|
552
|
+
#*java_class::属性の所有者であるJavaクラス
|
553
|
+
#*tag::データの種別を示すconstant_poolのインデックス
|
554
|
+
#*const_value_index::定数値を示すconstant_poolのインデックス
|
555
|
+
#
|
556
|
+
def initialize( java_class, tag=nil, const_value_index=nil )
|
557
|
+
super( java_class, tag )
|
558
|
+
@const_value_index = const_value_index
|
559
|
+
end
|
560
|
+
def value
|
561
|
+
@java_class.get_constant_value(@const_value_index)
|
562
|
+
end
|
563
|
+
def to_s
|
564
|
+
@java_class.get_constant_as_string(@const_value_index)
|
565
|
+
end
|
566
|
+
def to_bytes
|
567
|
+
bytes = super
|
568
|
+
bytes += to_byte( @const_value_index, 2)
|
569
|
+
end
|
570
|
+
# 定数値を示すconstant_poolのインデックス
|
571
|
+
attr :const_value_index, true
|
572
|
+
end
|
573
|
+
|
574
|
+
#
|
575
|
+
#=== 列挙型のアノテーションデータ
|
576
|
+
#
|
577
|
+
class EnumAnnotationElementValue < AnnotationElementValue
|
578
|
+
#
|
579
|
+
#===コンストラクタ
|
580
|
+
#
|
581
|
+
#*java_class::属性の所有者であるJavaクラス
|
582
|
+
#*tag::データの種別を示すconstant_poolのインデックス
|
583
|
+
#*type_name_index::列挙型の型名を示すconstant_poolのインデックス
|
584
|
+
#*const_name_index::列挙型の定数名を示すconstant_poolのインデックス
|
585
|
+
#
|
586
|
+
def initialize( java_class, tag=nil, type_name_index=nil, const_name_index=nil )
|
587
|
+
super( java_class, tag )
|
588
|
+
@type_name_index = type_name_index
|
589
|
+
@const_name_index = const_name_index
|
590
|
+
end
|
591
|
+
def type_name
|
592
|
+
@java_class.get_constant_value(@type_name_index)
|
593
|
+
end
|
594
|
+
def const_name
|
595
|
+
@java_class.get_constant_value(@const_name_index)
|
596
|
+
end
|
597
|
+
def to_s
|
598
|
+
convert_field_descriptor(type_name) << "." << const_name.to_s
|
599
|
+
end
|
600
|
+
def to_bytes
|
601
|
+
bytes = super
|
602
|
+
bytes += to_byte( @type_name_index, 2)
|
603
|
+
bytes += to_byte( @const_name_index, 2)
|
604
|
+
end
|
605
|
+
|
606
|
+
attr :type_name_index, true
|
607
|
+
attr :const_name_index, true
|
608
|
+
end
|
609
|
+
|
610
|
+
#
|
611
|
+
#=== クラス型のアノテーションデータ
|
612
|
+
#
|
613
|
+
class ClassAnnotationElementValue < AnnotationElementValue
|
614
|
+
#
|
615
|
+
#===コンストラクタ
|
616
|
+
#
|
617
|
+
#*java_class::属性の所有者であるJavaクラス
|
618
|
+
#*tag::データの種別を示すconstant_poolのインデックス
|
619
|
+
#*class_info_index::クラスを示すconstant_poolのインデックス
|
620
|
+
#
|
621
|
+
def initialize( java_class, tag=nil, class_info_index=nil )
|
622
|
+
super( java_class, tag )
|
623
|
+
@class_info_index = class_info_index
|
624
|
+
end
|
625
|
+
def class_info
|
626
|
+
@java_class.get_constant_value(@class_info_index)
|
627
|
+
end
|
628
|
+
def to_s
|
629
|
+
convert_field_descriptor(class_info) << ".class"
|
630
|
+
end
|
631
|
+
def to_bytes
|
632
|
+
bytes = super
|
633
|
+
bytes += to_byte( @class_info_index, 2)
|
634
|
+
end
|
635
|
+
|
636
|
+
attr :class_info_index, true
|
637
|
+
end
|
638
|
+
|
639
|
+
#
|
640
|
+
#=== アノテーション型のアノテーションデータ
|
641
|
+
#
|
642
|
+
class AnnotationAnnotationElementValue < AnnotationElementValue
|
643
|
+
#
|
644
|
+
#===コンストラクタ
|
645
|
+
#
|
646
|
+
#*java_class::属性の所有者であるJavaクラス
|
647
|
+
#*tag::データの種別を示すconstant_poolのインデックス
|
648
|
+
#*annotation::アノテーション
|
649
|
+
#
|
650
|
+
def initialize( java_class, tag=nil, annotation=nil )
|
651
|
+
super( java_class, tag )
|
652
|
+
@annotation = annotation
|
653
|
+
end
|
654
|
+
def to_s
|
655
|
+
@annotation.to_s
|
656
|
+
end
|
657
|
+
def to_bytes
|
658
|
+
bytes = super
|
659
|
+
bytes += annotation.to_bytes()
|
660
|
+
end
|
661
|
+
|
662
|
+
attr :annotation, true
|
663
|
+
end
|
664
|
+
|
665
|
+
#
|
666
|
+
#=== 配列型のアノテーションデータ
|
667
|
+
#
|
668
|
+
class ArrayAnnotationElementValue < AnnotationElementValue
|
669
|
+
#
|
670
|
+
#===コンストラクタ
|
671
|
+
#
|
672
|
+
#*java_class::属性の所有者であるJavaクラス
|
673
|
+
#*tag::データの種別を示すconstant_poolのインデックス
|
674
|
+
#*array::配列
|
675
|
+
#
|
676
|
+
def initialize( java_class, tag=nil, array=[] )
|
677
|
+
super( java_class, tag )
|
678
|
+
@array = array
|
679
|
+
end
|
680
|
+
def to_s
|
681
|
+
"[" << @array.map{|a| a.to_s }.join(",") << "]"
|
682
|
+
end
|
683
|
+
def to_bytes
|
684
|
+
bytes = super
|
685
|
+
bytes += to_byte( @array.length, 2 )
|
686
|
+
@array.each {|a|
|
687
|
+
bytes += a.to_bytes()
|
688
|
+
}
|
689
|
+
return bytes
|
690
|
+
end
|
691
|
+
|
692
|
+
attr :array, true
|
693
|
+
end
|
694
|
+
|
695
|
+
#
|
696
|
+
#=== 引数のアノテーション属性
|
697
|
+
#
|
698
|
+
class ParameterAnnotationsAttribute < Attribute
|
699
|
+
#
|
700
|
+
#===コンストラクタ
|
701
|
+
#
|
702
|
+
#*java_class::属性の所有者であるJavaクラス
|
703
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
704
|
+
#*parameter_annotations::パラメータ番号に対応するアノテーションの配列の配列
|
705
|
+
# (0番目のパラメータのアノテーションは0番目の配列に格納される。)
|
706
|
+
#
|
707
|
+
def initialize( java_class, name_index, parameter_annotations=[])
|
708
|
+
super( java_class, name_index )
|
709
|
+
@parameter_annotations = parameter_annotations
|
710
|
+
end
|
711
|
+
|
712
|
+
#
|
713
|
+
#=== 引数のindexに対応するアノテーションの配列を取得する。
|
714
|
+
#*index::引数の位置を示すインデックス
|
715
|
+
#<b>戻り値</b>::引数に設定されたアノテーションの配列
|
716
|
+
#
|
717
|
+
def [](index)
|
718
|
+
@parameter_annotations[index] != nil ? @parameter_annotations[index] : []
|
719
|
+
end
|
720
|
+
#
|
721
|
+
#=== 引数のindexに対応するアノテーションの配列を設定する。
|
722
|
+
#*index::引数の位置を示すインデックス
|
723
|
+
#*annotations::引数に設定するアノテーションの配列
|
724
|
+
#
|
725
|
+
def []=(index,annotations)
|
726
|
+
@parameter_annotations[index] = annotations
|
727
|
+
end
|
728
|
+
def to_bytes
|
729
|
+
bytes = super
|
730
|
+
body = to_byte( @parameter_annotations.length, 1)
|
731
|
+
@parameter_annotations.each {|annotations|
|
732
|
+
body += to_byte( annotations != nil ? annotations.length : 0, 2)
|
733
|
+
if ( annotations != nil )
|
734
|
+
annotations.each {|a|
|
735
|
+
body += a.to_bytes()
|
736
|
+
}
|
737
|
+
end
|
738
|
+
}
|
739
|
+
bytes += to_byte( body.length, 4)
|
740
|
+
bytes += body
|
741
|
+
end
|
742
|
+
|
743
|
+
attr :parameter_annotations, true
|
744
|
+
end
|
745
|
+
|
746
|
+
#
|
747
|
+
#=== アノテーションの初期値属性
|
748
|
+
#
|
749
|
+
class AnnotationDefaultAttribute < Attribute
|
750
|
+
#
|
751
|
+
#===コンストラクタ
|
752
|
+
#
|
753
|
+
#*java_class::属性の所有者であるJavaクラス
|
754
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
755
|
+
#*element_value::アノテーションの初期値
|
756
|
+
#
|
757
|
+
def initialize( java_class, name_index, element_value=nil )
|
758
|
+
super( java_class, name_index)
|
759
|
+
@element_value = element_value
|
760
|
+
end
|
761
|
+
def to_s
|
762
|
+
"default " << @element_value.to_s
|
763
|
+
end
|
764
|
+
def to_bytes
|
765
|
+
bytes = super
|
766
|
+
body = element_value.to_bytes()
|
767
|
+
bytes += to_byte( body.length, 4)
|
768
|
+
bytes += body
|
769
|
+
end
|
770
|
+
|
771
|
+
attr :element_value, true
|
772
|
+
end
|
773
|
+
|
774
|
+
#
|
775
|
+
#=== コード属性
|
776
|
+
#
|
777
|
+
class CodeAttribute < Attribute
|
778
|
+
#
|
779
|
+
#===コンストラクタ
|
780
|
+
#
|
781
|
+
#*java_class::属性の所有者であるJavaクラス
|
782
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
783
|
+
#*max_stack::オペランドスタックの最大深度
|
784
|
+
#*max_locals::ローカル変数の数
|
785
|
+
#*codes::コード
|
786
|
+
#*exception_table::例外
|
787
|
+
#*attributes::属性
|
788
|
+
#
|
789
|
+
def initialize( java_class, name_index, max_stack=nil, \
|
790
|
+
max_locals=nil, codes=[], exception_table=[], attributes={} )
|
791
|
+
super( java_class, name_index)
|
792
|
+
@max_stack = max_stack
|
793
|
+
@max_locals = max_locals
|
794
|
+
@codes = codes
|
795
|
+
@exception_table = exception_table
|
796
|
+
@attributes = attributes
|
797
|
+
end
|
798
|
+
def to_s
|
799
|
+
# TODO
|
800
|
+
end
|
801
|
+
def to_bytes
|
802
|
+
bytes = super
|
803
|
+
|
804
|
+
body = to_byte( @max_stack, 2)
|
805
|
+
body += to_byte( @max_locals, 2)
|
806
|
+
body += to_byte( @codes.length, 4)
|
807
|
+
@codes.each {|c|
|
808
|
+
body += to_byte( c, 1 )
|
809
|
+
}
|
810
|
+
body += to_byte( @exception_table.length, 2)
|
811
|
+
@exception_table.each {|ex|
|
812
|
+
body += ex.to_bytes()
|
813
|
+
}
|
814
|
+
body += to_byte( @attributes.length, 2)
|
815
|
+
@attributes.each {|k,a|
|
816
|
+
body += a.to_bytes()
|
817
|
+
}
|
818
|
+
bytes += to_byte( body.length, 4)
|
819
|
+
bytes += body
|
820
|
+
end
|
821
|
+
|
822
|
+
attr :max_stack, true
|
823
|
+
attr :max_locals, true
|
824
|
+
attr :codes, true
|
825
|
+
attr :exception_table, true
|
826
|
+
attr :attributes, true
|
827
|
+
end
|
828
|
+
#
|
829
|
+
#=== 例外
|
830
|
+
#
|
831
|
+
class Excpetion
|
832
|
+
include JavaClass::Base
|
833
|
+
|
834
|
+
def initialize( java_class, start_pc=nil, end_pc=nil, handler_pc=nil, catch_type_index=nil )
|
835
|
+
@java_class=java_class
|
836
|
+
@start_pc=start_pc
|
837
|
+
@end_pc=end_pc
|
838
|
+
@handler_pc=handler_pc
|
839
|
+
@catch_type_index=catch_type_index
|
840
|
+
end
|
841
|
+
def catch_type
|
842
|
+
@catch_type_index == nil ? nil : @java_class.get_constant(@catch_type_index)
|
843
|
+
end
|
844
|
+
def to_bytes
|
845
|
+
bytes = []
|
846
|
+
bytes += to_byte( @start_pc, 2 )
|
847
|
+
bytes += to_byte( @end_pc, 2 )
|
848
|
+
bytes += to_byte( @handler_pc, 2 )
|
849
|
+
bytes += to_byte( @catch_type_index, 2 )
|
850
|
+
end
|
851
|
+
attr :start_pc, true
|
852
|
+
attr :end_pc, true
|
853
|
+
attr :handler_pc, true
|
854
|
+
attr :catch_type_index, true
|
855
|
+
end
|
856
|
+
|
857
|
+
#
|
858
|
+
#=== 行番号属性
|
859
|
+
#
|
860
|
+
class LineNumberTableAttribute < Attribute
|
861
|
+
#
|
862
|
+
#===コンストラクタ
|
863
|
+
#
|
864
|
+
#*java_class::属性の所有者であるJavaクラス
|
865
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
866
|
+
#
|
867
|
+
def initialize( java_class, name_index, line_numbers=[] )
|
868
|
+
super( java_class, name_index)
|
869
|
+
@line_numbers = line_numbers
|
870
|
+
end
|
871
|
+
#
|
872
|
+
#=== start_pcに対応する位置の行番号オブジェクトがあればそれを返す。
|
873
|
+
#*start_pc::コードの番号
|
874
|
+
#<b>戻り値</b>::start_pcに対応する位置のソースの行番号オブジェクト。見つからなければnil
|
875
|
+
#
|
876
|
+
def line_number( start_pc )
|
877
|
+
return @line_numbers.find {|l|
|
878
|
+
l.start_pc == start_pc
|
879
|
+
}
|
880
|
+
end
|
881
|
+
def to_bytes
|
882
|
+
bytes = super
|
883
|
+
body = to_byte( @line_numbers.length, 2 )
|
884
|
+
@line_numbers.each {|l|
|
885
|
+
body += l.to_bytes()
|
886
|
+
}
|
887
|
+
bytes += to_byte( body.length, 4 )
|
888
|
+
bytes += body
|
889
|
+
end
|
890
|
+
attr :line_numbers, true
|
891
|
+
end
|
892
|
+
|
893
|
+
#
|
894
|
+
#=== 行番号
|
895
|
+
#
|
896
|
+
class LineNumber
|
897
|
+
include JavaClass::Base
|
898
|
+
def initialize( java_class, start_pc=nil, line_number=nil )
|
899
|
+
@java_class=java_class
|
900
|
+
@start_pc=start_pc
|
901
|
+
@line_number=line_number
|
902
|
+
end
|
903
|
+
def to_s
|
904
|
+
"line : #{@line_number}"
|
905
|
+
end
|
906
|
+
def to_bytes
|
907
|
+
bytes = to_byte( @start_pc, 2 )
|
908
|
+
bytes += to_byte( @line_number, 2 )
|
909
|
+
end
|
910
|
+
attr :start_pc, true
|
911
|
+
attr :line_number, true
|
912
|
+
end
|
913
|
+
|
914
|
+
#
|
915
|
+
#=== ローカル変数テーブル属性
|
916
|
+
#
|
917
|
+
class LocalVariableTableAttribute < Attribute
|
918
|
+
#
|
919
|
+
#===コンストラクタ
|
920
|
+
#
|
921
|
+
#*java_class::属性の所有者であるJavaクラス
|
922
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
923
|
+
#*local_variable_table::ローカル変数テーブル
|
924
|
+
#
|
925
|
+
def initialize( java_class, name_index, local_variable_table=[] )
|
926
|
+
super( java_class, name_index)
|
927
|
+
@local_variable_table = local_variable_table
|
928
|
+
end
|
929
|
+
#
|
930
|
+
#=== indexに対応するローカル変数情報を取得します。
|
931
|
+
#*index::ローカル変数名
|
932
|
+
#<b>戻り値</b>::名前に対応するローカル変数情報。見つからなければnil
|
933
|
+
#
|
934
|
+
def find_by_index( index )
|
935
|
+
return @local_variable_table.find {|l|
|
936
|
+
l.index == index
|
937
|
+
}
|
938
|
+
end
|
939
|
+
def to_bytes
|
940
|
+
bytes = super
|
941
|
+
body = to_byte( @local_variable_table.length, 2 )
|
942
|
+
@local_variable_table.each {|l|
|
943
|
+
body += l.to_bytes()
|
944
|
+
}
|
945
|
+
bytes += to_byte( body.length, 4 )
|
946
|
+
bytes += body
|
947
|
+
end
|
948
|
+
attr :local_variable_table, true
|
949
|
+
end
|
950
|
+
|
951
|
+
#
|
952
|
+
#=== ローカル変数
|
953
|
+
#
|
954
|
+
class LocalVariable
|
955
|
+
include JavaClass::Base
|
956
|
+
include JavaClass::Converters
|
957
|
+
def initialize( java_class, start_pc=nil, \
|
958
|
+
length=nil, name_index=nil, descriptor_index=nil, index=nil )
|
959
|
+
@java_class=java_class
|
960
|
+
@start_pc = start_pc
|
961
|
+
@length = length
|
962
|
+
@name_index = name_index
|
963
|
+
@descriptor_index = descriptor_index
|
964
|
+
@index = index
|
965
|
+
end
|
966
|
+
def to_s
|
967
|
+
"#{convert_field_descriptor(descriptor)} #{name}"
|
968
|
+
end
|
969
|
+
def name
|
970
|
+
@java_class.get_constant_value( @name_index )
|
971
|
+
end
|
972
|
+
def descriptor
|
973
|
+
@java_class.get_constant_value( @descriptor_index )
|
974
|
+
end
|
975
|
+
def to_bytes
|
976
|
+
bytes = to_byte( @start_pc, 2 )
|
977
|
+
bytes += to_byte( @length, 2 )
|
978
|
+
bytes += to_byte( @name_index, 2 )
|
979
|
+
bytes += to_byte( @descriptor_index, 2 )
|
980
|
+
bytes += to_byte( @index, 2 )
|
981
|
+
end
|
982
|
+
attr :start_pc, true
|
983
|
+
attr :length, true
|
984
|
+
attr :name_index, true
|
985
|
+
attr :descriptor_index, true
|
986
|
+
attr :index, true
|
987
|
+
end
|
988
|
+
#
|
989
|
+
#=== ローカル変数の型テーブル属性
|
990
|
+
#
|
991
|
+
class LocalVariableTypeTableAttribute < Attribute
|
992
|
+
#
|
993
|
+
#===コンストラクタ
|
994
|
+
#
|
995
|
+
#*java_class::属性の所有者であるJavaクラス
|
996
|
+
#*name_index::名前を示すconstant_poolのインデックス
|
997
|
+
#*local_variable_table::ローカル変数型テーブル
|
998
|
+
#
|
999
|
+
def initialize( java_class, name_index, local_variable_type_table=[] )
|
1000
|
+
super( java_class, name_index)
|
1001
|
+
@local_variable_type_table = local_variable_type_table
|
1002
|
+
end
|
1003
|
+
#
|
1004
|
+
#=== indexに対応するローカル変数型情報を取得します。
|
1005
|
+
#*index::ローカル変数名
|
1006
|
+
#<b>戻り値</b>::名前に対応するローカル変数型情報。見つからなければnil
|
1007
|
+
#
|
1008
|
+
def find_by_index( index )
|
1009
|
+
return @local_variable_type_table.find {|l|
|
1010
|
+
l.index == index
|
1011
|
+
}
|
1012
|
+
end
|
1013
|
+
def to_bytes
|
1014
|
+
bytes = super
|
1015
|
+
body = to_byte( @local_variable_type_table.length, 2 )
|
1016
|
+
@local_variable_type_table.each {|l|
|
1017
|
+
body += l.to_bytes()
|
1018
|
+
}
|
1019
|
+
bytes += to_byte( body.length, 4 )
|
1020
|
+
bytes += body
|
1021
|
+
end
|
1022
|
+
attr :local_variable_type_table, true
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
#
|
1026
|
+
#=== ローカル変数の型
|
1027
|
+
#
|
1028
|
+
class LocalVariableType
|
1029
|
+
include JavaClass::Base
|
1030
|
+
def initialize( java_class, start_pc=nil, \
|
1031
|
+
length=nil, name_index=nil, signature_index=nil, index=nil )
|
1032
|
+
@java_class=java_class
|
1033
|
+
@start_pc = start_pc
|
1034
|
+
@length = length
|
1035
|
+
@name_index = name_index
|
1036
|
+
@signature_index = signature_index
|
1037
|
+
@index = index
|
1038
|
+
end
|
1039
|
+
def to_s
|
1040
|
+
# TODO
|
1041
|
+
end
|
1042
|
+
def name
|
1043
|
+
@java_class.get_constant_value( @name_index )
|
1044
|
+
end
|
1045
|
+
def signature
|
1046
|
+
@java_class.get_constant_value( @signature_index )
|
1047
|
+
end
|
1048
|
+
def to_bytes
|
1049
|
+
bytes = to_byte( @start_pc, 2 )
|
1050
|
+
bytes += to_byte( @length, 2 )
|
1051
|
+
bytes += to_byte( @name_index, 2 )
|
1052
|
+
bytes += to_byte( @signature_index, 2 )
|
1053
|
+
bytes += to_byte( @index, 2 )
|
1054
|
+
end
|
1055
|
+
attr :start_pc, true
|
1056
|
+
attr :length, true
|
1057
|
+
attr :name_index, true
|
1058
|
+
attr :signature_index, true
|
1059
|
+
attr :index, true
|
1060
|
+
end
|
1061
|
+
end
|