pytecode 0.0.1__py3-none-any.whl
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.
- pytecode/__init__.py +22 -0
- pytecode/analysis.py +2402 -0
- pytecode/attributes.py +868 -0
- pytecode/bytes_utils.py +208 -0
- pytecode/class_reader.py +810 -0
- pytecode/class_writer.py +630 -0
- pytecode/constant_pool.py +196 -0
- pytecode/constant_pool_builder.py +844 -0
- pytecode/constants.py +208 -0
- pytecode/debug_info.py +319 -0
- pytecode/descriptors.py +791 -0
- pytecode/hierarchy.py +561 -0
- pytecode/info.py +123 -0
- pytecode/instructions.py +495 -0
- pytecode/jar.py +271 -0
- pytecode/labels.py +1041 -0
- pytecode/model.py +929 -0
- pytecode/modified_utf8.py +145 -0
- pytecode/operands.py +683 -0
- pytecode/py.typed +0 -0
- pytecode/transforms.py +954 -0
- pytecode/verify.py +1386 -0
- pytecode-0.0.1.dist-info/METADATA +218 -0
- pytecode-0.0.1.dist-info/RECORD +27 -0
- pytecode-0.0.1.dist-info/WHEEL +5 -0
- pytecode-0.0.1.dist-info/licenses/LICENSE +21 -0
- pytecode-0.0.1.dist-info/top_level.txt +1 -0
pytecode/attributes.py
ADDED
|
@@ -0,0 +1,868 @@
|
|
|
1
|
+
"""Dataclass definitions for JVM class file attributes (JVM spec §4.7)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from enum import Enum
|
|
7
|
+
|
|
8
|
+
from . import constants, instructions
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"AnnotationDefaultAttr",
|
|
12
|
+
"AnnotationInfo",
|
|
13
|
+
"AppendFrameInfo",
|
|
14
|
+
"ArrayValueInfo",
|
|
15
|
+
"AttributeInfo",
|
|
16
|
+
"AttributeInfoType",
|
|
17
|
+
"BootstrapMethodInfo",
|
|
18
|
+
"BootstrapMethodsAttr",
|
|
19
|
+
"CatchTargetInfo",
|
|
20
|
+
"ChopFrameInfo",
|
|
21
|
+
"ClassInfoValueInfo",
|
|
22
|
+
"CodeAttr",
|
|
23
|
+
"ConstValueInfo",
|
|
24
|
+
"ConstantValueAttr",
|
|
25
|
+
"DeprecatedAttr",
|
|
26
|
+
"DoubleVariableInfo",
|
|
27
|
+
"ElementValueInfo",
|
|
28
|
+
"ElementValuePairInfo",
|
|
29
|
+
"EmptyTargetInfo",
|
|
30
|
+
"EnclosingMethodAttr",
|
|
31
|
+
"EnumConstantValueInfo",
|
|
32
|
+
"ExceptionInfo",
|
|
33
|
+
"ExceptionsAttr",
|
|
34
|
+
"ExportInfo",
|
|
35
|
+
"FloatVariableInfo",
|
|
36
|
+
"FormalParameterTargetInfo",
|
|
37
|
+
"FullFrameInfo",
|
|
38
|
+
"InnerClassInfo",
|
|
39
|
+
"InnerClassesAttr",
|
|
40
|
+
"IntegerVariableInfo",
|
|
41
|
+
"LineNumberInfo",
|
|
42
|
+
"LineNumberTableAttr",
|
|
43
|
+
"LocalVariableInfo",
|
|
44
|
+
"LocalVariableTableAttr",
|
|
45
|
+
"LocalVariableTypeInfo",
|
|
46
|
+
"LocalVariableTypeTableAttr",
|
|
47
|
+
"LocalvarTargetInfo",
|
|
48
|
+
"LongVariableInfo",
|
|
49
|
+
"MethodParameterInfo",
|
|
50
|
+
"MethodParametersAttr",
|
|
51
|
+
"ModuleAttr",
|
|
52
|
+
"ModuleMainClassAttr",
|
|
53
|
+
"ModulePackagesAttr",
|
|
54
|
+
"NestHostAttr",
|
|
55
|
+
"NestMembersAttr",
|
|
56
|
+
"NullVariableInfo",
|
|
57
|
+
"ObjectVariableInfo",
|
|
58
|
+
"OffsetTargetInfo",
|
|
59
|
+
"OpensInfo",
|
|
60
|
+
"ParameterAnnotationInfo",
|
|
61
|
+
"PathInfo",
|
|
62
|
+
"PermittedSubclassesAttr",
|
|
63
|
+
"ProvidesInfo",
|
|
64
|
+
"RecordAttr",
|
|
65
|
+
"RecordComponentInfo",
|
|
66
|
+
"RequiresInfo",
|
|
67
|
+
"RuntimeInvisibleAnnotationsAttr",
|
|
68
|
+
"RuntimeInvisibleParameterAnnotationsAttr",
|
|
69
|
+
"RuntimeInvisibleTypeAnnotationsAttr",
|
|
70
|
+
"RuntimeTypeAnnotationsAttr",
|
|
71
|
+
"RuntimeVisibleAnnotationsAttr",
|
|
72
|
+
"RuntimeVisibleParameterAnnotationsAttr",
|
|
73
|
+
"RuntimeVisibleTypeAnnotationsAttr",
|
|
74
|
+
"SameFrameExtendedInfo",
|
|
75
|
+
"SameFrameInfo",
|
|
76
|
+
"SameLocals1StackItemFrameExtendedInfo",
|
|
77
|
+
"SameLocals1StackItemFrameInfo",
|
|
78
|
+
"SignatureAttr",
|
|
79
|
+
"SourceDebugExtensionAttr",
|
|
80
|
+
"SourceFileAttr",
|
|
81
|
+
"StackMapFrameInfo",
|
|
82
|
+
"StackMapTableAttr",
|
|
83
|
+
"SupertypeTargetInfo",
|
|
84
|
+
"SyntheticAttr",
|
|
85
|
+
"TableInfo",
|
|
86
|
+
"TargetInfo",
|
|
87
|
+
"ThrowsTargetInfo",
|
|
88
|
+
"TopVariableInfo",
|
|
89
|
+
"TypeAnnotationInfo",
|
|
90
|
+
"TypeArgumentTargetInfo",
|
|
91
|
+
"TypeParameterBoundTargetInfo",
|
|
92
|
+
"TypeParameterTargetInfo",
|
|
93
|
+
"TypePathInfo",
|
|
94
|
+
"UnimplementedAttr",
|
|
95
|
+
"UninitializedThisVariableInfo",
|
|
96
|
+
"UninitializedVariableInfo",
|
|
97
|
+
"VerificationTypeInfo",
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@dataclass
|
|
102
|
+
class AttributeInfo:
|
|
103
|
+
"""Base class for all JVM class file attribute structures (§4.7)."""
|
|
104
|
+
|
|
105
|
+
attribute_name_index: int
|
|
106
|
+
attribute_length: int
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@dataclass
|
|
110
|
+
class UnimplementedAttr(AttributeInfo):
|
|
111
|
+
"""Placeholder for attribute types not yet implemented by pytecode."""
|
|
112
|
+
|
|
113
|
+
info: bytes
|
|
114
|
+
attr_type: AttributeInfoType
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@dataclass
|
|
118
|
+
class ConstantValueAttr(AttributeInfo):
|
|
119
|
+
"""Represents the ConstantValue attribute (§4.7.2)."""
|
|
120
|
+
|
|
121
|
+
constantvalue_index: int
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@dataclass
|
|
125
|
+
class ExceptionInfo:
|
|
126
|
+
"""Entry in the Code attribute exception_table (§4.7.3)."""
|
|
127
|
+
|
|
128
|
+
start_pc: int
|
|
129
|
+
end_pc: int
|
|
130
|
+
handler_pc: int
|
|
131
|
+
catch_type: int
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@dataclass
|
|
135
|
+
class CodeAttr(AttributeInfo):
|
|
136
|
+
"""Represents the Code attribute (§4.7.3)."""
|
|
137
|
+
|
|
138
|
+
max_stacks: int
|
|
139
|
+
max_locals: int
|
|
140
|
+
code_length: int
|
|
141
|
+
code: list[instructions.InsnInfo]
|
|
142
|
+
exception_table_length: int
|
|
143
|
+
exception_table: list[ExceptionInfo]
|
|
144
|
+
attributes_count: int
|
|
145
|
+
attributes: list[AttributeInfo]
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
@dataclass
|
|
149
|
+
class VerificationTypeInfo:
|
|
150
|
+
"""Base class for verification type info entries in StackMapTable frames (§4.7.4)."""
|
|
151
|
+
|
|
152
|
+
tag: constants.VerificationType
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@dataclass
|
|
156
|
+
class TopVariableInfo(VerificationTypeInfo):
|
|
157
|
+
"""Verification type indicating the top type (§4.7.4)."""
|
|
158
|
+
|
|
159
|
+
pass
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
@dataclass
|
|
163
|
+
class IntegerVariableInfo(VerificationTypeInfo):
|
|
164
|
+
"""Verification type indicating the integer type (§4.7.4)."""
|
|
165
|
+
|
|
166
|
+
pass
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
@dataclass
|
|
170
|
+
class FloatVariableInfo(VerificationTypeInfo):
|
|
171
|
+
"""Verification type indicating the float type (§4.7.4)."""
|
|
172
|
+
|
|
173
|
+
pass
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
@dataclass
|
|
177
|
+
class DoubleVariableInfo(VerificationTypeInfo):
|
|
178
|
+
"""Verification type indicating the double type (§4.7.4)."""
|
|
179
|
+
|
|
180
|
+
pass
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
@dataclass
|
|
184
|
+
class LongVariableInfo(VerificationTypeInfo):
|
|
185
|
+
"""Verification type indicating the long type (§4.7.4)."""
|
|
186
|
+
|
|
187
|
+
pass
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@dataclass
|
|
191
|
+
class NullVariableInfo(VerificationTypeInfo):
|
|
192
|
+
"""Verification type indicating the null type (§4.7.4)."""
|
|
193
|
+
|
|
194
|
+
pass
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@dataclass
|
|
198
|
+
class UninitializedThisVariableInfo(VerificationTypeInfo):
|
|
199
|
+
"""Verification type indicating the uninitializedThis type (§4.7.4)."""
|
|
200
|
+
|
|
201
|
+
pass
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
@dataclass
|
|
205
|
+
class ObjectVariableInfo(VerificationTypeInfo):
|
|
206
|
+
"""Verification type indicating an object type (§4.7.4)."""
|
|
207
|
+
|
|
208
|
+
cpool_index: int
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
@dataclass
|
|
212
|
+
class UninitializedVariableInfo(VerificationTypeInfo):
|
|
213
|
+
"""Verification type indicating an uninitialized type (§4.7.4)."""
|
|
214
|
+
|
|
215
|
+
offset: int
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
@dataclass
|
|
219
|
+
class StackMapFrameInfo:
|
|
220
|
+
"""Base class for stack map frame entries in the StackMapTable attribute (§4.7.4)."""
|
|
221
|
+
|
|
222
|
+
frame_type: int
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
@dataclass
|
|
226
|
+
class SameFrameInfo(StackMapFrameInfo):
|
|
227
|
+
"""Stack map frame with the same locals and empty stack (§4.7.4)."""
|
|
228
|
+
|
|
229
|
+
pass
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
@dataclass
|
|
233
|
+
class SameLocals1StackItemFrameInfo(StackMapFrameInfo):
|
|
234
|
+
"""Stack map frame with the same locals and one stack item (§4.7.4)."""
|
|
235
|
+
|
|
236
|
+
stack: VerificationTypeInfo
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@dataclass
|
|
240
|
+
class SameLocals1StackItemFrameExtendedInfo(StackMapFrameInfo):
|
|
241
|
+
"""Extended same-locals-1-stack-item frame with explicit offset_delta (§4.7.4)."""
|
|
242
|
+
|
|
243
|
+
offset_delta: int
|
|
244
|
+
stack: VerificationTypeInfo
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
@dataclass
|
|
248
|
+
class ChopFrameInfo(StackMapFrameInfo):
|
|
249
|
+
"""Stack map frame indicating removal of locals (§4.7.4)."""
|
|
250
|
+
|
|
251
|
+
offset_delta: int
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
@dataclass
|
|
255
|
+
class SameFrameExtendedInfo(StackMapFrameInfo):
|
|
256
|
+
"""Extended same frame with explicit offset_delta (§4.7.4)."""
|
|
257
|
+
|
|
258
|
+
offset_delta: int
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
@dataclass
|
|
262
|
+
class AppendFrameInfo(StackMapFrameInfo):
|
|
263
|
+
"""Stack map frame indicating additional locals (§4.7.4)."""
|
|
264
|
+
|
|
265
|
+
offset_delta: int
|
|
266
|
+
locals: list[VerificationTypeInfo]
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
@dataclass
|
|
270
|
+
class FullFrameInfo(StackMapFrameInfo):
|
|
271
|
+
"""Full stack map frame with explicit locals and stack (§4.7.4)."""
|
|
272
|
+
|
|
273
|
+
offset_delta: int
|
|
274
|
+
number_of_locals: int
|
|
275
|
+
locals: list[VerificationTypeInfo]
|
|
276
|
+
number_of_stack_items: int
|
|
277
|
+
stack: list[VerificationTypeInfo]
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
@dataclass
|
|
281
|
+
class StackMapTableAttr(AttributeInfo):
|
|
282
|
+
"""Represents the StackMapTable attribute (§4.7.4)."""
|
|
283
|
+
|
|
284
|
+
number_of_entries: int
|
|
285
|
+
entries: list[StackMapFrameInfo]
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
@dataclass
|
|
289
|
+
class ExceptionsAttr(AttributeInfo):
|
|
290
|
+
"""Represents the Exceptions attribute (§4.7.5)."""
|
|
291
|
+
|
|
292
|
+
number_of_exceptions: int
|
|
293
|
+
exception_index_table: list[int]
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
@dataclass
|
|
297
|
+
class InnerClassInfo:
|
|
298
|
+
"""Entry in the InnerClasses attribute classes table (§4.7.6)."""
|
|
299
|
+
|
|
300
|
+
inner_class_info_index: int
|
|
301
|
+
outer_class_info_index: int
|
|
302
|
+
inner_name_index: int
|
|
303
|
+
inner_class_access_flags: constants.NestedClassAccessFlag
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
@dataclass
|
|
307
|
+
class InnerClassesAttr(AttributeInfo):
|
|
308
|
+
"""Represents the InnerClasses attribute (§4.7.6)."""
|
|
309
|
+
|
|
310
|
+
number_of_classes: int
|
|
311
|
+
classes: list[InnerClassInfo]
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
@dataclass
|
|
315
|
+
class EnclosingMethodAttr(AttributeInfo):
|
|
316
|
+
"""Represents the EnclosingMethod attribute (§4.7.7)."""
|
|
317
|
+
|
|
318
|
+
class_index: int
|
|
319
|
+
method_index: int
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
@dataclass
|
|
323
|
+
class SyntheticAttr(AttributeInfo):
|
|
324
|
+
"""Represents the Synthetic attribute (§4.7.8)."""
|
|
325
|
+
|
|
326
|
+
pass
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
@dataclass
|
|
330
|
+
class SignatureAttr(AttributeInfo):
|
|
331
|
+
"""Represents the Signature attribute (§4.7.9)."""
|
|
332
|
+
|
|
333
|
+
signature_index: int
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
@dataclass
|
|
337
|
+
class SourceFileAttr(AttributeInfo):
|
|
338
|
+
"""Represents the SourceFile attribute (§4.7.10)."""
|
|
339
|
+
|
|
340
|
+
sourcefile_index: int
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
@dataclass
|
|
344
|
+
class SourceDebugExtensionAttr(AttributeInfo):
|
|
345
|
+
"""Represents the SourceDebugExtension attribute (§4.7.11)."""
|
|
346
|
+
|
|
347
|
+
debug_extension: str
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
@dataclass
|
|
351
|
+
class LineNumberInfo:
|
|
352
|
+
"""Entry in the LineNumberTable attribute (§4.7.12)."""
|
|
353
|
+
|
|
354
|
+
start_pc: int
|
|
355
|
+
line_number: int
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
@dataclass
|
|
359
|
+
class LineNumberTableAttr(AttributeInfo):
|
|
360
|
+
"""Represents the LineNumberTable attribute (§4.7.12)."""
|
|
361
|
+
|
|
362
|
+
line_number_table_length: int
|
|
363
|
+
line_number_table: list[LineNumberInfo]
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
@dataclass
|
|
367
|
+
class LocalVariableInfo:
|
|
368
|
+
"""Entry in the LocalVariableTable attribute (§4.7.13)."""
|
|
369
|
+
|
|
370
|
+
start_pc: int
|
|
371
|
+
length: int
|
|
372
|
+
name_index: int
|
|
373
|
+
descriptor_index: int
|
|
374
|
+
index: int
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
@dataclass
|
|
378
|
+
class LocalVariableTableAttr(AttributeInfo):
|
|
379
|
+
"""Represents the LocalVariableTable attribute (§4.7.13)."""
|
|
380
|
+
|
|
381
|
+
local_variable_table_length: int
|
|
382
|
+
local_variable_table: list[LocalVariableInfo]
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
@dataclass
|
|
386
|
+
class LocalVariableTypeInfo:
|
|
387
|
+
"""Entry in the LocalVariableTypeTable attribute (§4.7.14)."""
|
|
388
|
+
|
|
389
|
+
start_pc: int
|
|
390
|
+
length: int
|
|
391
|
+
name_index: int
|
|
392
|
+
signature_index: int
|
|
393
|
+
index: int
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
@dataclass
|
|
397
|
+
class LocalVariableTypeTableAttr(AttributeInfo):
|
|
398
|
+
"""Represents the LocalVariableTypeTable attribute (§4.7.14)."""
|
|
399
|
+
|
|
400
|
+
local_variable_type_table_length: int
|
|
401
|
+
local_variable_type_table: list[LocalVariableTypeInfo]
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
@dataclass
|
|
405
|
+
class DeprecatedAttr(AttributeInfo):
|
|
406
|
+
"""Represents the Deprecated attribute (§4.7.15)."""
|
|
407
|
+
|
|
408
|
+
pass
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
@dataclass
|
|
412
|
+
class ConstValueInfo:
|
|
413
|
+
"""Constant value in an element_value structure (§4.7.16.1)."""
|
|
414
|
+
|
|
415
|
+
const_value_index: int
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
@dataclass
|
|
419
|
+
class EnumConstantValueInfo:
|
|
420
|
+
"""Enum constant value in an element_value structure (§4.7.16.1)."""
|
|
421
|
+
|
|
422
|
+
type_name_index: int
|
|
423
|
+
const_name_index: int
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
@dataclass
|
|
427
|
+
class ClassInfoValueInfo:
|
|
428
|
+
"""Class literal value in an element_value structure (§4.7.16.1)."""
|
|
429
|
+
|
|
430
|
+
class_info_index: int
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
@dataclass
|
|
434
|
+
class ArrayValueInfo:
|
|
435
|
+
"""Array value in an element_value structure (§4.7.16.1)."""
|
|
436
|
+
|
|
437
|
+
num_values: int
|
|
438
|
+
values: list[ElementValueInfo]
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
@dataclass
|
|
442
|
+
class ElementValueInfo:
|
|
443
|
+
"""Represents an element_value structure (§4.7.16.1)."""
|
|
444
|
+
|
|
445
|
+
tag: int | str
|
|
446
|
+
value: ConstValueInfo | EnumConstantValueInfo | ClassInfoValueInfo | AnnotationInfo | ArrayValueInfo
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
@dataclass
|
|
450
|
+
class ElementValuePairInfo:
|
|
451
|
+
"""Represents an element-value pair in an annotation (§4.7.16)."""
|
|
452
|
+
|
|
453
|
+
element_name_index: int
|
|
454
|
+
element_value: ElementValueInfo
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
@dataclass
|
|
458
|
+
class AnnotationInfo:
|
|
459
|
+
"""Represents an annotation structure (§4.7.16)."""
|
|
460
|
+
|
|
461
|
+
type_index: int
|
|
462
|
+
num_element_value_pairs: int
|
|
463
|
+
element_value_pairs: list[ElementValuePairInfo]
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
@dataclass
|
|
467
|
+
class RuntimeVisibleAnnotationsAttr(AttributeInfo):
|
|
468
|
+
"""Represents the RuntimeVisibleAnnotations attribute (§4.7.16)."""
|
|
469
|
+
|
|
470
|
+
num_annotations: int
|
|
471
|
+
annotations: list[AnnotationInfo]
|
|
472
|
+
|
|
473
|
+
|
|
474
|
+
@dataclass
|
|
475
|
+
class RuntimeInvisibleAnnotationsAttr(AttributeInfo):
|
|
476
|
+
"""Represents the RuntimeInvisibleAnnotations attribute (§4.7.17)."""
|
|
477
|
+
|
|
478
|
+
num_annotations: int
|
|
479
|
+
annotations: list[AnnotationInfo]
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
@dataclass
|
|
483
|
+
class ParameterAnnotationInfo:
|
|
484
|
+
"""Annotations for a single parameter (§4.7.18)."""
|
|
485
|
+
|
|
486
|
+
num_annotations: int
|
|
487
|
+
annotations: list[AnnotationInfo]
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
@dataclass
|
|
491
|
+
class RuntimeVisibleParameterAnnotationsAttr(AttributeInfo):
|
|
492
|
+
"""Represents the RuntimeVisibleParameterAnnotations attribute (§4.7.18)."""
|
|
493
|
+
|
|
494
|
+
num_parameters: int
|
|
495
|
+
parameter_annotations: list[ParameterAnnotationInfo]
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
@dataclass
|
|
499
|
+
class RuntimeInvisibleParameterAnnotationsAttr(AttributeInfo):
|
|
500
|
+
"""Represents the RuntimeInvisibleParameterAnnotations attribute (§4.7.19)."""
|
|
501
|
+
|
|
502
|
+
num_parameters: int
|
|
503
|
+
parameter_annotations: list[ParameterAnnotationInfo]
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
@dataclass
|
|
507
|
+
class TargetInfo:
|
|
508
|
+
"""Base class for type annotation target_info union variants (§4.7.20.1)."""
|
|
509
|
+
|
|
510
|
+
pass
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
@dataclass
|
|
514
|
+
class TypeParameterTargetInfo(TargetInfo):
|
|
515
|
+
"""Target info for type parameter declarations (§4.7.20.1)."""
|
|
516
|
+
|
|
517
|
+
type_parameter_index: int
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
@dataclass
|
|
521
|
+
class SupertypeTargetInfo(TargetInfo):
|
|
522
|
+
"""Target info for extends/implements clauses (§4.7.20.1)."""
|
|
523
|
+
|
|
524
|
+
supertype_index: int
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
@dataclass
|
|
528
|
+
class TypeParameterBoundTargetInfo(TargetInfo):
|
|
529
|
+
"""Target info for type parameter bounds (§4.7.20.1)."""
|
|
530
|
+
|
|
531
|
+
type_parameter_index: int
|
|
532
|
+
bound_index: int
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
@dataclass
|
|
536
|
+
class EmptyTargetInfo(TargetInfo):
|
|
537
|
+
"""Target info for return types, receiver types, or field types (§4.7.20.1)."""
|
|
538
|
+
|
|
539
|
+
pass
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
@dataclass
|
|
543
|
+
class FormalParameterTargetInfo(TargetInfo):
|
|
544
|
+
"""Target info for formal parameter declarations (§4.7.20.1)."""
|
|
545
|
+
|
|
546
|
+
formal_parameter_index: int
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
@dataclass
|
|
550
|
+
class ThrowsTargetInfo(TargetInfo):
|
|
551
|
+
"""Target info for throws clause types (§4.7.20.1)."""
|
|
552
|
+
|
|
553
|
+
throws_type_index: int
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
@dataclass
|
|
557
|
+
class TableInfo:
|
|
558
|
+
"""Entry in the localvar_target table (§4.7.20.1)."""
|
|
559
|
+
|
|
560
|
+
start_pc: int
|
|
561
|
+
length: int
|
|
562
|
+
index: int
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
@dataclass
|
|
566
|
+
class LocalvarTargetInfo(TargetInfo):
|
|
567
|
+
"""Target info for local variable type annotations (§4.7.20.1)."""
|
|
568
|
+
|
|
569
|
+
table_length: int
|
|
570
|
+
table: list[TableInfo]
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
@dataclass
|
|
574
|
+
class CatchTargetInfo(TargetInfo):
|
|
575
|
+
"""Target info for exception parameter types (§4.7.20.1)."""
|
|
576
|
+
|
|
577
|
+
exception_table_index: int
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
@dataclass
|
|
581
|
+
class OffsetTargetInfo(TargetInfo):
|
|
582
|
+
"""Target info for instanceof, new, or method reference expressions (§4.7.20.1)."""
|
|
583
|
+
|
|
584
|
+
offset: int
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
@dataclass
|
|
588
|
+
class TypeArgumentTargetInfo(TargetInfo):
|
|
589
|
+
"""Target info for cast or type argument expressions (§4.7.20.1)."""
|
|
590
|
+
|
|
591
|
+
offset: int
|
|
592
|
+
type_argument_index: int
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
@dataclass
|
|
596
|
+
class PathInfo:
|
|
597
|
+
"""Single entry in a type_path structure (§4.7.20.2)."""
|
|
598
|
+
|
|
599
|
+
type_path_kind: int
|
|
600
|
+
type_argument_index: int
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
@dataclass
|
|
604
|
+
class TypePathInfo:
|
|
605
|
+
"""Represents a type_path structure (§4.7.20.2)."""
|
|
606
|
+
|
|
607
|
+
path_length: int
|
|
608
|
+
path: list[PathInfo]
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
@dataclass
|
|
612
|
+
class TypeAnnotationInfo:
|
|
613
|
+
"""Represents a type_annotation structure (§4.7.20)."""
|
|
614
|
+
|
|
615
|
+
target_type: int
|
|
616
|
+
target_info: TargetInfo
|
|
617
|
+
target_path: TypePathInfo
|
|
618
|
+
type_index: int
|
|
619
|
+
num_element_value_pairs: int
|
|
620
|
+
element_value_pairs: list[ElementValuePairInfo]
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
@dataclass
|
|
624
|
+
class RuntimeTypeAnnotationsAttr(AttributeInfo):
|
|
625
|
+
"""Base class for RuntimeVisibleTypeAnnotations and RuntimeInvisibleTypeAnnotations."""
|
|
626
|
+
|
|
627
|
+
num_annotations: int
|
|
628
|
+
annotations: list[TypeAnnotationInfo]
|
|
629
|
+
|
|
630
|
+
|
|
631
|
+
@dataclass
|
|
632
|
+
class RuntimeVisibleTypeAnnotationsAttr(RuntimeTypeAnnotationsAttr):
|
|
633
|
+
"""Represents the RuntimeVisibleTypeAnnotations attribute (§4.7.20)."""
|
|
634
|
+
|
|
635
|
+
pass
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
@dataclass
|
|
639
|
+
class RuntimeInvisibleTypeAnnotationsAttr(RuntimeTypeAnnotationsAttr):
|
|
640
|
+
"""Represents the RuntimeInvisibleTypeAnnotations attribute (§4.7.21)."""
|
|
641
|
+
|
|
642
|
+
pass
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
@dataclass
|
|
646
|
+
class AnnotationDefaultAttr(AttributeInfo):
|
|
647
|
+
"""Represents the AnnotationDefault attribute (§4.7.22)."""
|
|
648
|
+
|
|
649
|
+
default_value: ElementValueInfo
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
@dataclass
|
|
653
|
+
class BootstrapMethodInfo:
|
|
654
|
+
"""Entry in the BootstrapMethods attribute (§4.7.23)."""
|
|
655
|
+
|
|
656
|
+
bootstrap_method_ref: int
|
|
657
|
+
num_boostrap_arguments: int
|
|
658
|
+
boostrap_arguments: list[int]
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
@dataclass
|
|
662
|
+
class BootstrapMethodsAttr(AttributeInfo):
|
|
663
|
+
"""Represents the BootstrapMethods attribute (§4.7.23)."""
|
|
664
|
+
|
|
665
|
+
num_bootstrap_methods: int
|
|
666
|
+
bootstrap_methods: list[BootstrapMethodInfo]
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
@dataclass
|
|
670
|
+
class MethodParameterInfo:
|
|
671
|
+
"""Entry in the MethodParameters attribute (§4.7.24)."""
|
|
672
|
+
|
|
673
|
+
name_index: int
|
|
674
|
+
access_flags: constants.MethodParameterAccessFlag
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
@dataclass
|
|
678
|
+
class MethodParametersAttr(AttributeInfo):
|
|
679
|
+
"""Represents the MethodParameters attribute (§4.7.24)."""
|
|
680
|
+
|
|
681
|
+
parameters_count: int
|
|
682
|
+
parameters: list[MethodParameterInfo]
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
@dataclass
|
|
686
|
+
class RequiresInfo:
|
|
687
|
+
"""Entry in the Module attribute requires table (§4.7.25)."""
|
|
688
|
+
|
|
689
|
+
requires_index: int
|
|
690
|
+
requires_flag: constants.ModuleRequiresAccessFlag
|
|
691
|
+
requires_version_index: int
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
@dataclass
|
|
695
|
+
class ExportInfo:
|
|
696
|
+
"""Entry in the Module attribute exports table (§4.7.25)."""
|
|
697
|
+
|
|
698
|
+
exports_index: int
|
|
699
|
+
exports_flags: constants.ModuleExportsAccessFlag
|
|
700
|
+
exports_to_count: int
|
|
701
|
+
exports_to_index: list[int]
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
@dataclass
|
|
705
|
+
class OpensInfo:
|
|
706
|
+
"""Entry in the Module attribute opens table (§4.7.25)."""
|
|
707
|
+
|
|
708
|
+
opens_index: int
|
|
709
|
+
opens_flags: constants.ModuleOpensAccessFlag
|
|
710
|
+
opens_to_count: int
|
|
711
|
+
opens_to_index: list[int]
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
@dataclass
|
|
715
|
+
class ProvidesInfo:
|
|
716
|
+
"""Entry in the Module attribute provides table (§4.7.25)."""
|
|
717
|
+
|
|
718
|
+
provides_index: int
|
|
719
|
+
provides_with_count: int
|
|
720
|
+
provides_with_index: list[int]
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
@dataclass
|
|
724
|
+
class ModuleAttr(AttributeInfo):
|
|
725
|
+
"""Represents the Module attribute (§4.7.25)."""
|
|
726
|
+
|
|
727
|
+
module_name_index: int
|
|
728
|
+
module_flags: constants.ModuleAccessFlag
|
|
729
|
+
module_version_index: int
|
|
730
|
+
requires_count: int
|
|
731
|
+
requires: list[RequiresInfo]
|
|
732
|
+
exports_count: int
|
|
733
|
+
exports: list[ExportInfo]
|
|
734
|
+
opens_count: int
|
|
735
|
+
opens: list[OpensInfo]
|
|
736
|
+
uses_count: int
|
|
737
|
+
uses_index: list[int]
|
|
738
|
+
provides_count: int
|
|
739
|
+
provides: list[ProvidesInfo]
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
@dataclass
|
|
743
|
+
class ModulePackagesAttr(AttributeInfo):
|
|
744
|
+
"""Represents the ModulePackages attribute (§4.7.26)."""
|
|
745
|
+
|
|
746
|
+
package_count: int
|
|
747
|
+
package_index: list[int]
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
@dataclass
|
|
751
|
+
class ModuleMainClassAttr(AttributeInfo):
|
|
752
|
+
"""Represents the ModuleMainClass attribute (§4.7.27)."""
|
|
753
|
+
|
|
754
|
+
main_class_index: int
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
@dataclass
|
|
758
|
+
class NestHostAttr(AttributeInfo):
|
|
759
|
+
"""Represents the NestHost attribute (§4.7.28)."""
|
|
760
|
+
|
|
761
|
+
host_class_index: int
|
|
762
|
+
|
|
763
|
+
|
|
764
|
+
@dataclass
|
|
765
|
+
class NestMembersAttr(AttributeInfo):
|
|
766
|
+
"""Represents the NestMembers attribute (§4.7.29)."""
|
|
767
|
+
|
|
768
|
+
number_of_classes: int
|
|
769
|
+
classes: list[int]
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
@dataclass
|
|
773
|
+
class RecordComponentInfo:
|
|
774
|
+
"""Describes a single record component in the Record attribute (§4.7.30)."""
|
|
775
|
+
|
|
776
|
+
name_index: int
|
|
777
|
+
descriptor_index: int
|
|
778
|
+
attributes_count: int
|
|
779
|
+
attributes: list[AttributeInfo]
|
|
780
|
+
|
|
781
|
+
|
|
782
|
+
@dataclass
|
|
783
|
+
class RecordAttr(AttributeInfo):
|
|
784
|
+
"""Represents the Record attribute (§4.7.30)."""
|
|
785
|
+
|
|
786
|
+
components_count: int
|
|
787
|
+
components: list[RecordComponentInfo]
|
|
788
|
+
|
|
789
|
+
|
|
790
|
+
@dataclass
|
|
791
|
+
class PermittedSubclassesAttr(AttributeInfo):
|
|
792
|
+
"""Represents the PermittedSubclasses attribute (§4.7.31)."""
|
|
793
|
+
|
|
794
|
+
number_of_classes: int
|
|
795
|
+
classes: list[int]
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
class AttributeInfoType(Enum):
|
|
799
|
+
"""Enum mapping JVM attribute names to their dataclass types.
|
|
800
|
+
|
|
801
|
+
Attributes:
|
|
802
|
+
attr_class: The dataclass type that represents this attribute.
|
|
803
|
+
"""
|
|
804
|
+
|
|
805
|
+
CONSTANT_VALUE = "ConstantValue", ConstantValueAttr
|
|
806
|
+
CODE = "Code", CodeAttr
|
|
807
|
+
STACK_MAP_TABLE = "StackMapTable", StackMapTableAttr
|
|
808
|
+
EXCEPTIONS = "Exceptions", ExceptionsAttr
|
|
809
|
+
INNER_CLASSES = "InnerClasses", InnerClassesAttr
|
|
810
|
+
ENCLOSING_METHOD = "EnclosingMethod", EnclosingMethodAttr
|
|
811
|
+
SYNTHETIC = "Synthetic", SyntheticAttr
|
|
812
|
+
SIGNATURE = "Signature", SignatureAttr
|
|
813
|
+
SOURCE_FILE = "SourceFile", SourceFileAttr
|
|
814
|
+
SOURCE_DEBUG_EXTENSION = "SourceDebugExtension", SourceDebugExtensionAttr
|
|
815
|
+
LINE_NUMBER_TABLE = "LineNumberTable", LineNumberTableAttr
|
|
816
|
+
LOCAL_VARIABLE_TABLE = "LocalVariableTable", LocalVariableTableAttr
|
|
817
|
+
LOCAL_VARIABLE_TYPE_TABLE = "LocalVariableTypeTable", LocalVariableTypeTableAttr
|
|
818
|
+
DEPRECATED = "Deprecated", DeprecatedAttr
|
|
819
|
+
RUNTIME_VISIBLE_ANNOTATIONS = (
|
|
820
|
+
"RuntimeVisibleAnnotations",
|
|
821
|
+
RuntimeVisibleAnnotationsAttr,
|
|
822
|
+
)
|
|
823
|
+
RUNTIME_INVISIBLE_ANNOTATIONS = (
|
|
824
|
+
"RuntimeInvisibleAnnotations",
|
|
825
|
+
RuntimeInvisibleAnnotationsAttr,
|
|
826
|
+
)
|
|
827
|
+
RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS = (
|
|
828
|
+
"RuntimeVisibleParameterAnnotations",
|
|
829
|
+
RuntimeVisibleParameterAnnotationsAttr,
|
|
830
|
+
)
|
|
831
|
+
RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS = (
|
|
832
|
+
"RuntimeInvisibleParameterAnnotations",
|
|
833
|
+
RuntimeInvisibleParameterAnnotationsAttr,
|
|
834
|
+
)
|
|
835
|
+
RUNTIME_VISIBLE_TYPE_ANNOTATIONS = (
|
|
836
|
+
"RuntimeVisibleTypeAnnotations",
|
|
837
|
+
RuntimeVisibleTypeAnnotationsAttr,
|
|
838
|
+
)
|
|
839
|
+
RUNTIME_INVISIBLE_TYPE_ANNOTATIONS = (
|
|
840
|
+
"RuntimeInvisibleTypeAnnotations",
|
|
841
|
+
RuntimeInvisibleTypeAnnotationsAttr,
|
|
842
|
+
)
|
|
843
|
+
ANNOTATION_DEFAULT = "AnnotationDefault", AnnotationDefaultAttr
|
|
844
|
+
BOOTSTRAP_METHODS = "BootstrapMethods", BootstrapMethodsAttr
|
|
845
|
+
METHOD_PARAMETERS = "MethodParameters", MethodParametersAttr
|
|
846
|
+
MODULE = "Module", ModuleAttr
|
|
847
|
+
MODULE_PACKAGES = "ModulePackages", ModulePackagesAttr
|
|
848
|
+
MODULE_MAIN_CLASS = "ModuleMainClass", ModuleMainClassAttr
|
|
849
|
+
NEST_HOST = "NestHost", NestHostAttr
|
|
850
|
+
NEST_MEMBERS = "NestMembers", NestMembersAttr
|
|
851
|
+
RECORD = "Record", RecordAttr
|
|
852
|
+
PERMITTED_SUBCLASSES = "PermittedSubclasses", PermittedSubclassesAttr
|
|
853
|
+
|
|
854
|
+
UNIMPLEMENTED = "", UnimplementedAttr
|
|
855
|
+
|
|
856
|
+
attr_class: type[AttributeInfo]
|
|
857
|
+
|
|
858
|
+
def __new__(cls, name: str, attr_class: type[AttributeInfo]) -> AttributeInfoType:
|
|
859
|
+
obj = object.__new__(cls)
|
|
860
|
+
obj._value_ = name
|
|
861
|
+
obj.attr_class = attr_class
|
|
862
|
+
return obj
|
|
863
|
+
|
|
864
|
+
@classmethod
|
|
865
|
+
def _missing_(cls, value: object) -> AttributeInfoType:
|
|
866
|
+
obj = cls.UNIMPLEMENTED
|
|
867
|
+
obj._value_ = value
|
|
868
|
+
return obj
|