• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Panda Binary File Format
2
3This document describes Panda binary file format with the following goals in mind:
4
5* Compactness.
6* Support for fast access to information.
7* Support for low memory footprint.
8* Extensibility and compatibility.
9
10## Compactness
11
12Many mobile applications use a lot of types, methods and fields. Their number is so large that it
13doesn't fit in 16-bit unsigned integer. It leads to application developer have to create several
14files and as a result not all data can be deduplicated.
15
16Current binary file format should extend these limits to conform to the modern requirements.
17
18To achieve this, all references in the binary file are 4 bytes long. It allows to have 4Gb for
19addressing fields, methods, classes, etc.
20
21The format uses [TaggedValue](#taggedvalue) which allows to store only information we have and
22avoid 0 offsets to absent information.
23
24But to achieve more compactness 16-bit indexes are used to refer classes, methods and fields in
25the bytecode and some metadata. File can contain multiple indexes each one covers part of the
26file and described by [RegionHeader](#regionheader).
27
28## Fast information access
29
30Binary file format should support fast access to information. It means that
31redundant references should be avoided. Also, if it possible, binary file format should avoid data
32indexes (like sorted list of strings). However, the described binary format supports one index:
33a sorted list of offsets to classes. This index is compact and allows to find a type definition
34quickly, which runtime requires a lot during application launch time.
35
36All classes, fields and methods are separated into 2 groups: foreign and local.
37Foreign classes, fields and methods are declared in other files, with references from the
38current binary file. Local classes, fields and methods are declared in the current file.
39Local entities has the same header as the corresponding foreign. So
40having an offset to an entity it doesn't matter whether the entity is local or foreign.
41
42Runtime can easily check type of an offset by checking it is in the foreign region
43(*\[foreign_off; foreign_off + foreign_size)*).
44Depending on the result runtime can search the entity in other files (for foreign entities)
45or create a runtime object from the definition by the offset (for local entities).
46
47To improve data access speed most data structures have 4 bytes alignment.
48Since most target architectures are little endian all multibyte values are little endian.
49
50## Offsets
51
52Unless otherwise specified, all offsets are calculated from the beginning of the file.
53An offset cannot contain values in the range *\[0; 32)*, except for specially mentioned cases.
54
55## Support for low memory footprint
56
57As practice shows, most of file data is not used by the application. It means memory footprint
58of a file may be significantly reduced by grouping frequently used data.
59To support this feature, the described binary file format uses offsets and doesn't specify how
60structures should be located relatively to each other.
61
62## Extensibility and compatibility
63
64The binary file format supports future changes via version number.
65The version field in the header is 4 bytes long and is encoded as byte array to
66avoid misinterpretation on platforms with different endianness.
67
68Any tool which supports format version `N` must support format version `N - 1` too.
69
70## Data types
71
72| Type       | Description                                  |
73| ----       | -----------                                  |
74| `uint8_t`  | 8-bit unsigned integer value                 |
75| `uint16_t` | 16-bit unsigned integer value                |
76| `uint32_t` | 32-bit little endian unsigned integer value. |
77| `uleb128`  | unsigned integer value in leb128 encoding.   |
78| `sleb128`  | signed integer value in leb128 encoding.     |
79
80### MUTF-8 Encoding
81
82Binary file format uses MUTF-8 (Modified UTF-8) encoding for strings.
83
84### String
85
86Alignment: none
87
88Format:
89
90| Name               | Format        | Description |
91| ----               | ------        | ----------- |
92| `utf16_length`     | `uleb128`     | `len << 1 \| is_ascii` where `len` is the length of the string in UTF-16 code units. |
93| `data`             | `uint8_t[]`   | 0-terminated character sequence in MUTF-8 encoding. |
94
95### TaggedValue
96
97Alignment: none
98
99Format:
100
101| Name               | Format        | Description |
102| ----               | ------        | ----------- |
103| `tag_value`        | `uint8_t`     | The first 8 bits contain tag which determines the meaning of the data. Depending on the tag there may be optional data. Runtime must be able to determine size of the data. |
104| `data`             | `uint8_t[]`   | Optional payload. |
105
106## String syntax
107
108### TypeDescriptor
109
110```
111TypeDescriptor -> PrimitiveType | ArrayType | RefType
112PrimitiveType  -> 'Z' | 'B' | 'H' | 'S' | 'C' | 'I' | 'U' | 'J' | 'Q' | 'F' | 'D' | 'A'
113ArrayType      -> '[' TypeDescriptor
114RefType        -> 'L' ClassName ';'
115```
116
117`PrimitiveType` is a one letter encoding for primitive type
118
119| Type  | Encoding |
120| ----  | :--: |
121| `u1`  | `Z` |
122| `i8`  | `B` |
123| `u8`  | `H` |
124| `i16` | `S` |
125| `u16` | `C` |
126| `i32` | `I` |
127| `u32` | `U` |
128| `f32` | `F` |
129| `f64` | `D` |
130| `i64` | `J` |
131| `u64` | `Q` |
132| `any` | `A` |
133
134`ClassName` is a qualified name of a class with `.` replaced with `/`.
135
136## Access flags
137
138#### Field access flags
139
140| Name             | Value    | Description |
141| ----             | :---:    | ----------- |
142| `ACC_PUBLIC`     | `0x0001` | Declared public; may be accessed from outside its package. |
143| `ACC_PRIVATE`    | `0x0002` | Declared private; usable only within the defining class. |
144| `ACC_PROTECTED`  | `0x0004` | Declared protected; may be accessed within subclasses. |
145| `ACC_STATIC`     | `0x0008` | Declared static. |
146| `ACC_FINAL`      | `0x0010` | Declared final; never directly assigned to after object construction (JLS ยง17.5). |
147| `ACC_VOLATILE`   | `0x0040` | Declared volatile; cannot be cached. |
148| `ACC_TRANSIENT`  | `0x0080` | Declared transient; not written or read by a persistent object manager. |
149| `ACC_SYNTHETIC`  | `0x1000` | Declared synthetic; not present in the source code. |
150| `ACC_ENUM`       | `0x4000` | Declared as an element of an enum. |
151
152#### Method access flags
153
154| Name               | Value    | Description |
155| ----               | :---:    | ----------- |
156| `ACC_PUBLIC`       | `0x0001` | Declared public; may be accessed from outside its package. |
157| `ACC_PRIVATE`      | `0x0002` | Declared private; accessible only within the defining class. |
158| `ACC_PROTECTED`    | `0x0004` | Declared protected; may be accessed within subclasses. |
159| `ACC_STATIC`       | `0x0008` | Declared static. |
160| `ACC_FINAL`        | `0x0010` | Declared final; must not be overridden. |
161| `ACC_SYNCHRONIZED` | `0x0020` | Declared synchronized; invocation is wrapped by a monitor use. |
162| `ACC_BRIDGE`       | `0x0040` | A bridge method, generated by the compiler. |
163| `ACC_VARARGS`      | `0x0080` | Declared with variable number of arguments. |
164| `ACC_NATIVE`       | `0x0100` | Declared native; |
165| `ACC_ABSTRACT`     | `0x0400` | Declared abstract; no implementation is provided. |
166| `ACC_STRICT`       | `0x0800` | Declared strictfp; floating-point mode is FP-strict. |
167| `ACC_SYNTHETIC`    | `0x1000` | Declared synthetic; not present in the source code. |
168
169#### Class access flags
170
171| Name             | Value    | Description |
172| ----             | :---:    | ----------- |
173| `ACC_PUBLIC`     | `0x0001` | Declared public; may be accessed from outside its package. |
174| `ACC_FINAL`      | `0x0010` | Declared final; no subclasses allowed. |
175| `ACC_SUPER`      | `0x0020` | No special meaning, exists for compatibility |
176| `ACC_INTERFACE`  | `0x0200` | Is an interface, not a class. |
177| `ACC_ABSTRACT`   | `0x0400` | Declared abstract; must not be instantiated. |
178| `ACC_SYNTHETIC`  | `0x1000` | Declared synthetic; not present in the source code. |
179| `ACC_ANNOTATION` | `0x2000` | Declared as an annotation type. |
180| `ACC_ENUM`       | `0x4000` | Declared as an enum type. |
181
182## Source language
183
184A file can be emitted from sources that are written in following languages:
185
186| Name             | Value         |
187| ----             | ----          |
188| Reserved         | `0x00`        |
189| `Panda Assembly` | `0x01`        |
190| Reserved         | `0x02 - 0x0f` |
191
192
193Source language can be specified for classes and methods. For classes Panda Assembly language is assumed by default. Default language for methods is the class's one.
194
195## Data layout
196
197A file begins with the header which is located at offset 0.
198All other data can be reached from the header.
199
200### Header
201
202Alignment: 4 bytes
203
204Format:
205
206| Name                   | Format          | Description |
207| ----                   | ------          | ----------- |
208| `magic`                | `uint8_t[8]`    | Magic string. Must be 'P' 'A' 'N' 'D' 'A' '\\0' '\\0' '\\0' |
209| `checksum`             | `uint8_t[4]`    | adler32 checksum of the file except magic and checksum fields. |
210| `version`              | `uint8_t[4]`    | Version of the format. Current version is 0002. |
211| `file_size`            | `uint32_t`      | Size of the file in bytes.  |
212| `foreign_off`          | `uint32_t`      | Offset to the foreign region. The region must contain elements only of types [ForeignField](#foreignfield), [ForeignMethod](#foreignmethod), or [ForeignClass](#foreignclass). It is not necessary `foreign_off` points to the first entity. Runtime should use `foreign_off` and `foreign_size` to determine type of an offset. |
213| `foreign_size`         | `uint32_t`      | Size of the foreign region in bytes. |
214| `num_classes`          | `uint32_t`      | Number of classes defined in the file. Also this is the number of elements in the [ClassIndex](#classindex) structure. |
215| `class_idx_off`        | `uint32_t`      | Offset to the class index structure. The offset must point to a structure in [ClassIndex](#classindex) format. |
216| `num_lnps`             | `uint32_t`      | Number of line number programs in the file. Also this is the number of elements in the [LineNumberProgramIndex](#linenumberprogramindex) structure. |
217| `lnp_idx_off`          | `uint32_t`      | Offset to the line number program index structure. The offset must point to a structure in [LineNumberProgramIndex](#linenumberprogramindex) format. |
218| `num_literalarrays`    | `uint32_t`      | Number of literalArrays defined in the file. Also this is the number of elements in the [LiteralArrayIndex](#literalarrayindex) structure. |
219| `literalarray_idx_off` | `uint32_t`      | Offset to the literalarray index structure. The offset must point to a structure in [LiteralArrayIndex](#literalarrayindex) format. |
220| `num_index_regions`    | `uint32_t`      | Number of the index regions in the file. Also this is the number of elements in the [RegionIndex](#regionindex) structure. |
221| `index_section_off`    | `uint32_t`      | Offset to the index section. The offset must point to a structure in [RegionIndex](#indexheaderindex) format. |
222
223Constraint: size of header must be > 16 bytes. [FieldType](#fieldType) uses this fact.
224
225### RegionHeader
226
227To address file structures using 16-bit indexes file is split into regions. Each region has class, method, field and proto indexes and described by `RegionHeader` structure.
228
229Alignment: 4 bytes
230
231Format:
232
233| Name              | Format     | Description |
234| ----              | ------     | ----------- |
235| `start_off`       | `uint32_t` | Start offset of the region. |
236| `end_off`         | `uint32_t` | End offset of the region. |
237| `class_idx_size`  | `uint32_t` | Number of elements in the [ClassRegionIndex](#classregionindex) structure. Max value is 65536. |
238| `class_idx_off`   | `uint32_t` | Offset to the class index structure. The offset must point to a structure in [ClassRegionIndex](#classregionindex) format. |
239| `method_idx_size` | `uint32_t` | Number of elements in the [MethodRegionIndex](#methodregionindex) structure. Max value is 65536. |
240| `method_idx_off`  | `uint32_t` | Offset to the method index structure. The offset must point to a structure in [MethodRegionIndex](#methodregionindex) format. |
241| `field_idx_size`  | `uint32_t` | Number of elements in the [FieldRegionIndex](#fieldregionindex) structure. Max value is 65536. |
242| `field_idx_off`   | `uint32_t` | Offset to the field index structure. The offset must point to a structure in [FieldRegionIndex](#fieldregionindex) format. |
243| `proto_idx_size`  | `uint32_t` | Number of elements in the [ProtoRegionIndex](#protoregionindex) structure. Max value is 65536. |
244| `proto_idx_off`   | `uint32_t` | Offset to the proto index structure. The offset must point to a structure in [ProtoRegionIndex](#protoregionindex) format. |
245
246Constraint: regions must not overlap each other.
247
248### RegionIndex
249
250`RegionIndex` structure is aimed to allow runtime to find index structure that covers specified offset in the file.
251It is organized as an array of [RegionHeader](#regionheader) structures.
252All regions are sorted by the start offset of the region. Number of elements in the index is `num_index_regions`
253from [Header](#header).
254
255Alignment: 4 bytes
256
257### ForeignField
258
259Alignment: none
260
261Format:
262
263| Name               | Format          | Description |
264| ----               | ------          | ----------- |
265| `class_idx`        | `uint16_t`      | Index of the declaring class in a [`ClassRegionIndex`](#classregionindex) structure. Corresponding index entry must be an offset to a [Class](#class) or a [ForeignClass](#foreignclass). |
266| `type_idx`         | `uint16_t`      | Index of the field's type in a [`ClassRegionIndex`](#classregionindex) structure. Corresponding index entry must be in [FieldType](#fieldtype) format. |
267| `name_off`         | `uint32_t`      | Offset to the name of the field. The offset must point to a [String](#string) |
268
269Note: Proper region index to resolve `class_idx` and `type_idx` can be found by foreign field's offset.
270
271### Field
272
273Alignment: none
274
275Format:
276
277| Name               | Format          | Description |
278| ----               | ------          | ----------- |
279| `class_idx`        | `uint16_t`      | Index of the declaring class in a [`ClassRegionIndex`](#classregionindex) structure. Corresponding index entry must be an offset to a [Class](#class). |
280| `type_idx`         | `uint16_t`      | Index of the field's type in a [`ClassRegionIndex`](#classregionindex) structure. Corresponding index entry must be in [FieldType](#fieldtype) format. |
281| `name_off`         | `uint32_t`      | Offset to the name of the field. The offset must point to a [String](#string) |
282| `access_flags`     | `uleb128`       | Access flags of the field. The value must be a combination of the [Field access flags](#field-access-flags). |
283| `field_data`       | `TaggedValue[]` | Variable length list of tagged values. Each element must have type [TaggedValue](#taggedvalue). Tag must have values from [FieldTag](#fieldtag) and follow in order of increasing tag (except `0x00` tag). |
284
285Note: Proper region index to resolve `class_idx` and `type_idx` can be found by field's offset.
286
287### FieldTag
288
289| Name                      | Tag    | Quantity | Data format  | Description |
290| ----                      | :-:    | :------: | -----------  | ----------- |
291| `NOTHING`                 | `0x00` | `1`      | `none`       | No more values. The value with this tag must be the last. |
292| `INT_VALUE`               | `0x01` | `0-1`    | `sleb128`    | Integral value of the field. This tag is used when the field has type `boolean`, `byte`, `char`, `short` or `int`. |
293| `VALUE`                   | `0x02` | `0-1`    | `uint8_t[4]` | Contains value in the [Value](#value) format. |
294| `RUNTIME_ANNOTATIONS`     | `0x03` | `>=0`    | `uint8_t[4]` | Offset to runtime **visible** annotation of the field. The tag may be repeated in case the field has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
295| `ANNOTATIONS`             | `0x04` | `>=0`    | `uint8_t[4]` | Offset to runtime **invisible** annotation of the field. The tag may be repeated in case the field has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
296| `RUNTIME_TYPE_ANNOTATION` | `0x05` | `>=0`    | `uint8_t[4]` | Offset to runtime **visible** type annotation of the field. The tag may be repeated in case the field has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
297| `TYPE_ANNOTATION`         | `0x06` | `>=0`    | `uint8_t[4]` | Offset to runtime **invisible** type annotation of the field. The tag may be repeated in case the field has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
298
299Note: Only `INT_VALUE` or `VALUE` tags must be present.
300
301### FieldType
302
303Since the first bytes of the file contain the header and size of the header > 16 bytes, any offset in the range `[0; sizeof(Header))` is invalid.
304`FieldType` encoding uses this fact to encode primitive types of the field in the low 4 bits.
305For non-primitive type the value is an offset to [Class](#class) or to
306[ForeignClass](#foreignclass). In both cases [FieldType](#fieldtype) is `uint32_t`.
307
308Primitive types are encoded as follows:
309
310| Type  | Code |
311| ----  | :--: |
312| `u1`  | 0x00 |
313| `i8`  | 0x01 |
314| `u8`  | 0x02 |
315| `i16` | 0x03 |
316| `u16` | 0x04 |
317| `i32` | 0x05 |
318| `u32` | 0x06 |
319| `f32` | 0x07 |
320| `f64` | 0x08 |
321| `i64` | 0x09 |
322| `u64` | 0x0a |
323| `any` | 0x0b |
324
325### ForeignMethod
326
327Alignment: none
328
329Format:
330
331| Name               | Format          | Description |
332| ----               | ------          | ----------- |
333| `class_idx`        | `uint16_t`      | Index of the declaring class in a [`ClassRegionIndex`](#classregionindex) structure. Corresponding index entry must be an offset to a [Class](#class) or a [ForeignClass](#foreignclass). |
334| `proto_idx`        | `uint16_t`      | Index of the method's prototype in a [`ProtoRegionIndex`](#classregionindex) structure. Corresponding index entry must be an offset to a [Proto](#proto). |
335| `name_off`         | `uint32_t`      | Offset to the name of the method. The offset must point to a [String](#string). |
336| `access_flags`     | `uleb128`       | Access flags of the method. The value must be a combination of [Method access flags](#method-access-flags). For foreign methods, only `ACC_STATIC` flag is used, other flags should be ignored. |
337
338Note: Proper region index to resolve `class_idx` and `proto_idx` can be found by foreign method's offset.
339
340### Method
341
342Alignment: none
343
344Format:
345
346| Name               | Format          | Description |
347| ----               | ------          | ----------- |
348| `class_idx`        | `uint16_t`      | Index of the declaring class in a [`ClassRegionIndex`](#classregionindex) structure. Corresponding index entry must be an offset to a [Class](#class). |
349| `proto_idx`        | `uint16_t`      | Index of the method's prototype in a [`ProtoRegionIndex`](#classregionindex) structure. Corresponding index entry must be an offset to a [Proto](#proto). |
350| `name_off`         | `uint32_t`      | Offset to the name of the method. The offset must point to a [String](#string). |
351| `access_flags`     | `uleb128`       | Access flags of the method. The value must be a combination of [Method access flags](#method-access-flags). |
352| `method_data`      | `TaggedValue[]` | Variable length list of tagged values. Each element must have type [TaggedValue](#taggedvalue). Tag must have values from [MethodTag](#methodtag) and follow in order of increasing tag (except `0x00` tag). |
353
354Note: Proper region index to resolve `class_idx` and `proto_idx` can be found by method's offset.
355
356### MethodTag
357
358| Name                       | Tag     | Quantity  | Data format      | Description |
359| ----                       | :-:     | :------:  | -----------      | ----------- |
360| `NOTHING`                  | `0x00`  | `1`       | `none`           | No more values. The value with this tag must be the last. |
361| `CODE`                     | `0x01`  | `0-1`     | `uint8_t[4]`     | Data represents the offset to method's code. The offset must point to [Code](#code). |
362| `SOURCE_LANG`              | `0x02`  | `0-1`     | `uint8_t`        | Data represents the [source language](#source-language). |
363| `RUNTIME_ANNOTATION`       | `0x03`  | `>=0`     | `uint8_t[4]`     | Data represents the offset to runtime **visible** annotation of the method. The tag may be repeated in case the method has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
364| `RUNTIME_PARAM_ANNOTATION` | `0x04`  | `0-1`     | `uint8_t[4]`     | Data represents the offset to the runtime **visible** annotations of the method's parameters. The offset must point to the value in [ParamAnnotations](#paramannotations) format. |
365| `DEBUG_INFO`               | `0x05`  | `0-1`     | `uint8_t[4]`     | Data represents the offset to debug information related to the method. The offset must point to [DebugInfo](#debuginfo). |
366| `ANNOTATION`               | `0x06`  | `>=0`     | `uint8_t[4]`     | Data represents the offset to runtime **invisible** annotation of the method. The tag may be repeated in case the method has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
367| `PARAM_ANNOTATION`         | `0x07`  | `0-1`     | `uint8_t[4]`     | Data represents the offset to the runtime **invisible** annotations of the method's parameters. The offset must point to the value in [ParamAnnotations](#paramannotations) format. |
368| `TYPE_ANNOTATION`          | `0x08`  | `>=0`     | `uint8_t[4]`     | Data represents the offset to runtime **invisible** type annotation of the method. The tag may be repeated in case the method has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
369| `RUNTIME_TYPE_ANNOTATION`  | `0x09`  | `>=0`     | `uint8_t[4]`     | Data represents the offset to runtime **visible** type annotation of the method. The tag may be repeated in case the method has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
370
371### ForeignClass
372
373Alignment: none
374
375Format:
376
377| Name               | Format          | Description |
378| ----               | ------          | ----------- |
379| `name`             | `String`        | Name of the foreign type. The name must conform to [TypeDescriptor](#typedescriptor) syntax. |
380
381### Class
382
383Alignment: none
384
385Format:
386
387| Name               | Format          | Description |
388| ----               | ------          | ----------- |
389| `name`             | `String`        | Name of the class. The name must conform to [TypeDescriptor](#typedescriptor) syntax. |
390| `super_class_off`  | `uint8_t[4]`    | Offset to the name of the super class or `0` for root object class (`panda.Object` in Panda Assembly, plugin-specific in plugins). Non-zero offset must point to a [ForeignClass](#foreignclass) or to a [Class](#class). |
391| `access_flags`     | `uleb128`       | Access flags of the class. The value must be a combination of [Class access flags](#class-access-flags). |
392| `num_fields`       | `uleb128`       | Number of fields the class has.
393| `num_methods`      | `uleb128`       | Number of methods the class has.
394| `class_data`       | `TaggedValue[]` | Variable length list of tagged values. Each element must have type [TaggedValue](#taggedvalue). Tag must have values from [ClassTag](#classtag) and follow in order of increasing tag (except `0x00` tag). |
395| `fields`           | `Field[]`       | Class fields. Number of elements is `num_fields`. Each element must have [Field](#field) format. |
396| `methods`          | `Method[]`      | Class methods. Number of elements is `num_methods`. Each element must have [Method](#method) format. |
397
398#### ClassTag
399
400| Name                      | Tag    | Quantity  | Data format           | Description |
401| ----                      | :-:    | :------:  | -----------           | ----------- |
402| `NOTHING`                 | `0x00` | `1`       | `none`                | No more values. The value with this tag must be the last. |
403| `INTERFACES`              | `0x01` | `0-1`     | `uleb128 uint8_t[]`   | List of interfaces the class implements. Data contains number of interfaces encoded in `uleb128` format followed by indexes of the interfaces in a [`ClassRegionIndex`](#classregionindex) structure. Each index is 2 bytes long and must be resolved to offset point to a [ForeignClass](#foreignclass) or to a [Class](#class). Number of indexes is equal to number of interfaces. |
404| `SOURCE_LANG`             | `0x02` | `0-1`     | `uint8_t`             | Data represents the [source language](#source-language). |
405| `RUNTIME_ANNOTATION`      | `0x03` | `>=0`     | `uint8_t[4]`          | Offset to runtime **visible** annotation of the class. The tag may be repeated in case the class has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
406| `ANNOTATION`              | `0x04` | `>=0`     | `uint8_t[4]`          | Offset to runtime **invisible** annotation of the class. The tag may be repeated in case the class has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
407| `RUNTIME_TYPE_ANNOTATION` | `0x05` | `>=0`     | `uint8_t[4]`          | Offset to runtime **visible** type annotation of the class. The tag may be repeated in case the class has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
408| `TYPE_ANNOTATION`         | `0x06` | `>=0`     | `uint8_t[4]`          | Offset to runtime **invisible** type annotation of the class. The tag may be repeated in case the class has several annotations. The offset must point to the value in [Annotation](#annotation) format. |
409| `SOURCE_FILE`             | `0x07` | `0-1`     | `uint8_t[4]`          | Offset to a file name string containing source code of this class. |
410
411Note: Proper region index to resolve interfaces indexes can be found by class's offset.
412
413### LiteralArray
414
415Alignment: none
416
417| Name               | Format        | Description |
418| ----               | ------        | ----------- |
419| `num_literals`     | `uint32_t`    | num of literals that a literalarray has. |
420| `literals`         | `literal[]`   | Array of `literal` in one LiteralArray. The array has `num_literals` elements in [Literal](#literal) format. |
421
422### Proto
423
424Alignment: 2 bytes
425
426Format:
427
428| Name               | Format        | Description |
429| ----               | ------        | ----------- |
430| `shorty`           | `uint16_t[]`  | Short representation of the prototype. Encoding of the shorty is described in [Shorty](#shorty). |
431| `reference_types`  | `uint16_t[]`  | Array of indexes of the method's signature non-primitive types. For each non-primitive type in the shorty there is the corresponding element in the array. Size of the array is equals to number of reference types in the shorty. |
432
433Note: Proper region index to resolve reference types indexes can be found by proto's offset.
434
435#### Shorty
436
437Shorty is a short description of method's signature without detailed information about reference types.
438A shorty begins with a return type followed by method arguments and ends with `0x0`.
439
440Shorty syntax:
441
442```
443Shorty -> ReturnType ParamTypeList End
444ReturnType -> Type
445ParamTypeList -> '' | Type ParamTypeList
446Type -> <encoded type>
447End -> 0x0
448```
449
450`<encoded type>` must be one of:
451
452| Type   | Value   |
453| ----   | :---:   |
454| `void` | `0x01`  |
455| `u1`   | `0x02`  |
456| `i8`   | `0x03`  |
457| `u8`   | `0x04`  |
458| `i16`  | `0x05`  |
459| `u16`  | `0x06`  |
460| `i32`  | `0x07`  |
461| `u32`  | `0x08`  |
462| `f32`  | `0x09`  |
463| `f64`  | `0x0a`  |
464| `i64`  | `0x0b`  |
465| `u64`  | `0x0c`  |
466| `ref`  | `0x0d`  |
467| `any`  | `0x0e`  |
468
469All shorty elements are divided into groups of 4 elements starting from the beginning.
470Each group is encoded in `uint16_t`. Each element is encoded in 4 bits.
471A group with 4 elements `v1`, `v2`, ..., `v4` is encoded in `uint16_t` as follow:
472
473```
474| bits   | 0 - 3 | 4 - 7 | 8 - 11 | 12 - 15 |
475| ------ | ----- | ----- | ------ | ------- |
476| values | v1    | v2    | v3     | v4      |
477```
478
479If the group contains less then 4 elements the rest bits are filled with `0x0`.
480
481### Code
482
483Alignment: none
484
485Format:
486
487| Name               | Format        | Description |
488| ----               | ------        | ----------- |
489| `num_vregs`        | `uleb128`     | Number of registers (without argument registers). |
490| `num_args`         | `uleb128`     | Number of arguments. |
491| `code_size`        | `uleb128`     | Size of instructions in bytes. |
492| `tries_size`       | `uleb128`     | Number of try blocks. |
493| `instructions`     | `uint8_t[]`   | Instructions. |
494| `try_blocks`       | `TryBlock[]`  | Array of try blocks. The array has `tries_size` elements in [TryBlock](#tryblock) format. |
495
496### TryBlock
497
498Alignment: none
499
500Format:
501
502| Name               | Format         | Description |
503| ----               | ------         | ----------- |
504| `start_pc`         | `uleb128`      | Start `pc` of the `try` block. This `pc` points to the first instruction covered by this try block. |
505| `length`           | `uleb128`      | Number of instructions covered by the `try` block. |
506| `num_catches`      | `uleb128`      | Number of catch blocks associated with the `try` block. |
507| `catch_blocks`     | `CatchBlock[]` | Array of `catch` blocks associated with the `try` block. The array has `num_catches` elements in [CatchBlock](#catchblock) format. Catch blocks follows in the order runtime must check the exception's type. The `catch all` block, if present, must be the last. |
508
509### CatchBlock
510
511Alignment: none
512
513Format:
514
515| Name               | Format        | Description |
516| ----               | ------        | ----------- |
517| `type_idx`         | `uleb128`     | Index + 1 of the exception's type the block handles in a [`ClassRegionIndex`](#classregionindex) structure or 0 in case of `catch all` block. Corresponding index entry must be an offset to a [ForeignClass](#foreignclass) or to [Class](#class). The case when the index is 0 means it is a `catch all` block which catches all exceptions. |
518| `handler_pc`       | `uleb128`     | `pc` of the first instruction of the exception handler. |
519| `code_size`        | `uleb128`     | Handler's code size in bytes |
520
521Note: Proper region index to resolve `type_idx` can be found by corresponding method's offset.
522
523### Annotation
524
525Alignment: none
526
527Format:
528
529| Name               | Format                | Description |
530| ----               | ------                | ----------- |
531| `class_idx`        | `uint16_t`            | Index of the declaring class in a [`ClassRegionIndex`](#classregionindex) structure. Corresponding index entry must be an offset to a [Class](#class) or a [ForeignClass](#foreignclass). |
532| `count`            | `uint16_t`            | Number of name-value pairs in the annotation (number of elements in `elements` array). |
533| `elements`         | `AnnotationElement[]` | Array of annotation elements. Each element is in [AnnotationElement](#annotationelement) format. Order of elements must be the same as they follow in the annotation class. |
534| `element_types`    | `uint8_t[]`           | Array of annotation element's types. Each element in the array describes the type of `AnnotationElement`. The order of elements in the array matches the order of `elements` field. |
535
536Note: Proper region index to resolve `class_idx` can be found by annotation's offset.
537
538### Tags description
539
540|        Type       | Tag |
541| ------------------| --- |
542| `u1`              | `1` |
543| `i8`              | `2` |
544| `u8`              | `3` |
545| `i16`             | `4` |
546| `u16`             | `5` |
547| `i32`             | `6` |
548| `u32`             | `7` |
549| `i64`             | `8` |
550| `u64`             | `9` |
551| `f32`             | `A` |
552| `f64`             | `B` |
553| `string`          | `C` |
554| `record`          | `D` |
555| `method`          | `E` |
556| `enum`            | `F` |
557| `annotation`      | `G` |
558| `method_handle`   | `J` |
559| `array`           | `H` |
560| `u1[]`            | `K` |
561| `i8[]`            | `L` |
562| `u8[]`            | `M` |
563| `i16[]`           | `N` |
564| `u16[]`           | `O` |
565| `i32[]`           | `P` |
566| `u32[]`           | `Q` |
567| `i64[]`           | `R` |
568| `u64[]`           | `S` |
569| `f32[]`           | `T` |
570| `f64[]`           | `U` |
571| `string[]`        | `V` |
572| `record[]`        | `W` |
573| `method[]`        | `X` |
574| `enum[]`          | `Y` |
575| `annotation[]`    | `Z` |
576| `method_handle[]` | `@` |
577| `nullptr string`  | `*` |
578
579The correct value for element with `nullptr string` tag is 0 (`\x00\x00\x00\x00`)
580
581### AnnotationElement
582
583Alignment: none
584
585Format:
586
587| Name               | Format          | Description |
588| ----               | ------          | ----------- |
589| `name_off`         | `uint32_t`      | Offset to the element's name. The offset must point to a [String](#string). |
590| `value`            | `uint32_t`      | Value of the element. If the annotation element has type boolean, byte, short, char, int or float the field *value* contains the value itself in the corresponding [Value](#value) format. Else the field contains offset to a [Value](#value). Format of the value could be determined based on element's type. |
591
592
593### ParamAnnotations
594
595Alignment: none
596
597Format:
598
599| Name               | Format                | Description |
600| ----               | ------                | ----------- |
601| `count`            | `uint32_t`            | Number of parameters the method has. This number includes synthetic and mandated parameters. |
602| `annotations`      | `AnnotationArray[]`  | Array of annotation lists for each parameter. The array has `count` elements and each element is in [AnnotationArray](#annotationarray) format. |
603
604### AnnotationArray
605
606Alignment: none
607
608Format:
609
610| Name               | Format          | Description |
611| ----               | ------          | ----------- |
612| `count`            | `uint32_t`      | Number of elements in the array. |
613| `offsets`          | `uint32_t[]`    | Array of offsets to the parameter annotations. Each offset must refers to an [Annotation](#annotation). The array has `count` elements. |
614
615### Value
616
617There are different value encodings depending on the value's type.
618
619#### ByteValue
620
621Alignment: None
622
623Format:
624
625| Name               | Format          | Description |
626| ----               | ------          | ----------- |
627| `value`            | `uint8_t`    | Signed 1-byte integer value. |
628
629#### ShortValue
630
631Alignment: 2 bytes
632
633Format:
634
635| Name               | Format          | Description |
636| ----               | ------          | ----------- |
637| `value`            | `uint8_t[2]`    | Signed 2-byte integer value. |
638
639#### IntegerValue
640
641Alignment: 4 bytes
642
643Format:
644
645| Name               | Format          | Description |
646| ----               | ------          | ----------- |
647| `value`            | `uint8_t[4]`    | Signed 4-byte integer value. |
648
649#### LongValue
650
651Alignment: 8 bytes
652
653Format:
654
655| Name               | Format          | Description |
656| ----               | ------          | ----------- |
657| `value`            | `uint8_t[8]`    | Signed 8-byte integer value. |
658
659#### FloatValue
660
661Alignment: 4 bytes
662
663Format:
664
665| Name               | Format          | Description |
666| ----               | ------          | ----------- |
667| `value`            | `uint8_t[4]`    | 4-byte bit pattern, zero-extended to the right, and interpreted as an IEEE754 32-bit floating point value. |
668
669#### DoubleValue
670
671Alignment: 8 bytes
672
673Format:
674
675| Name               | Format          | Description |
676| ----               | ------          | ----------- |
677| `value`            | `uint8_t[8]`    | 8-byte bit pattern, zero-extended to the right, and interpreted as an IEEE754 64-bit floating point value. |
678
679#### StringValue
680
681Alignment: 4 bytes
682
683Format:
684
685| Name               | Format          | Description |
686| ----               | ------          | ----------- |
687| `value`            | `uint32_t`      | The value represents an offset to [String](#string). |
688
689#### EnumValue
690
691Alignment: 4 bytes
692
693Format:
694
695| Name               | Format          | Description |
696| ----               | ------          | ----------- |
697| `value`            | `uint32_t`      | The value represents an offset to an enum's field. The offset must point to [Field](#field) or [ForeignField](#foreignfield). |
698
699#### ClassValue
700
701Alignment: 4 bytes
702
703Format:
704
705| Name               | Format          | Description |
706| ----               | ------          | ----------- |
707| `value`            | `uint32_t`      | The value represents an offset to [Class](#class) or [ForeignClass](#foreignclass). |
708
709#### AnnotationValue
710
711Alignment: 4 bytes
712
713Format:
714
715| Name               | Format          | Description |
716| ----               | ------          | ----------- |
717| `value`            | `uint32_t`      | The value represents an offset to [Annotation](#annotation). |
718
719#### MethodValue
720
721Alignment: 4 bytes
722
723Format:
724
725| Name               | Format          | Description |
726| ----               | ------          | ----------- |
727| `value`            | `uint32_t`      | The value represents an offset to [Method](#method) or [ForeignMethod](#foreignmethod). |
728
729#### MethodHandleValue
730
731Alignment: 4 bytes
732
733Format:
734
735| Name               | Format          | Description |
736| ----               | ------          | ----------- |
737| `value`            | `uint32_t`      | The value represents an offset to [MethodHandle](#methodhandle). |
738
739#### MethodTypeValue
740
741Alignment: 4 bytes
742
743Format:
744
745| Name               | Format          | Description |
746| ----               | ------          | ----------- |
747| `value`            | `uint32_t`      | The value represents an offset to [Proto](#proto). |
748
749#### ArrayValue
750
751Alignment: None
752
753Format:
754
755| Name               | Format          | Description |
756| ----               | ------          | ----------- |
757| `count`            | `uleb128`       | Number of elements in the array. |
758| `elements`         | `Value[]`       | Unaligned array of [Value](#value) items. The array has `count` elements. |
759
760### Literal
761
762There are different literal encodings depending on the num of value's bytes.
763
764#### ByteOne
765
766Alignment: None
767
768Format:
769
770| Name               | Format          | Description |
771| ----               | ------          | ----------- |
772| `value`            | `uint8_t`       | 1-byte value. |
773
774#### ByteTwo
775
776Alignment: 2 bytes
777
778Format:
779
780| Name               | Format          | Description |
781| ----               | ------          | ----------- |
782| `value`            | `uint8_t[2]`    | 2-byte value. |
783
784#### ByteFour
785
786Alignment: 4 bytes
787
788Format:
789
790| Name               | Format          | Description |
791| ----               | ------          | ----------- |
792| `value`            | `uint8_t[4]`    | 4-byte value. |
793
794#### ByteEight
795
796Alignment: 8 bytes
797
798Format:
799
800| Name               | Format          | Description |
801| ----               | ------          | ----------- |
802| `value`            | `uint8_t[8]`    | 8-byte value. |
803
804### ClassIndex
805
806`ClassIndex` structure is aimed to allow runtime to find a type definition by name quickly.
807The structure is organized as an array of offsets from the beginning of the file to the
808[Class](#class) or [ForeignClass](#foreignclass) structures. All the offsets are sorted by corresponding class names.
809Number of elements in the index is `num_classes` from [Header](#header).
810
811Alignment: 4 bytes
812
813Format:
814
815| Name               | Format          | Description |
816| ----               | ------          | ----------- |
817| `offsets`          | `uint32_t[]`    | Sorted array of offsets to [Class](#class) or [ForeignClass](#foreignclass) structures. The array must be sorted by class names. |
818
819### LineNumberProgramIndex
820
821`LineNumberProgramIndex` structure is aimed to allow use more compact references to [Line Number Program](#line-number-program).
822The structure is organized as an array of offsets from the beginning of the file to the [Line Number Program](#line-number-program)
823structures. Number of elements in the index is `num_lnps` from [Header](#header).
824
825Alignment: 4 bytes
826
827Format:
828
829| Name               | Format          | Description |
830| ----               | ------          | ----------- |
831| `offsets`          | `uint32_t[]`    | Array of offsets to [Line Number Program](#line-number-program) structures. |
832
833### ClassRegionIndex
834
835`ClassRegionIndex` structure is aimed to allow runtime to find a type definition by index.
836The structure is organized as an array of [FieldType](#fieldtype). Number of elements in the index is `class_idx_size` from [RegionHeader](#regionheader).
837
838Alignment: 4 bytes
839
840Format:
841
842| Name               | Format             | Description |
843| ----               | ------             | ----------- |
844| `types`            | `FieldType[]`      | Array of [FieldType](#fieldtype) structures. |
845
846### MethodRegionIndex
847
848`MethodRegionIndex` structure is aimed to allow runtime to find a method definition by index.
849The structure is organized as an array of offsets from the beginning og the file to the [Method](#method) or the [ForeignMethod](#foreignmethod) structure.
850Number of elements in the index is `method_idx_size` from [RegionHeader](#regionheader).
851
852Alignment: 4 bytes
853
854Format:
855
856| Name               | Format             | Description |
857| ----               | ------             | ----------- |
858| `offsets`          | `uint32_t[]`       | Array of offsets to [Method](#method) or [ForeignMethod](#foreignmethod) structures. |
859
860### FieldRegionIndex
861
862`FieldRegionIndex` structure is aimed to allow runtime to find a field definition by index.
863The structure is organized as an array of offsets from the beginning og the file to the [Field](#field) or the [ForeignField](#foreignfield) structure.
864Number of elements in the index is `field_idx_size` from [RegionHeader](#regionheader).
865
866Alignment: 4 bytes
867
868Format:
869
870| Name               | Format             | Description |
871| ----               | ------             | ----------- |
872| `offsets`          | `uint32_t[]`       | Array of offsets to [Field](#field) or [ForeignField](#foreignfield) structures. |
873
874### ProtoRegionIndex
875
876`ProtoRegionIndex` structure is aimed to allow runtime to find a proto definition by index.
877The structure is organized as an array of offsets from the beginning og the file to the [Proto](#proto) structure.
878Number of elements in the index is `proto_idx_size` from [RegionHeader](#regionheader).
879
880Alignment: 4 bytes
881
882Format:
883
884| Name               | Format             | Description |
885| ----               | ------             | ----------- |
886| `offsets`          | `uint32_t[]`       | Array of offsets to [Proto](#proto) structures. |
887
888### LiteralArrayIndex
889
890`LiteralArrayIndex` structure is aimed to allow runtime to find a LiteralArray definition by index.
891The structure is organized as an array of offsets from the beginning of the file to the [LiteralArray](#literalarray) structures.
892Number of elements in the index is `num_literalarrays` from [Header](#header).
893
894Alignment: 4 bytes
895
896Format:
897
898| Name               | Format          | Description |
899| ----               | ------          | ----------- |
900| `offsets`          | `uint32_t[]`    | Sorted array of offsets to [LiteralArray](#literalarray) structures. |
901
902### DebugInfo
903
904Debug information contains mapping between program counter of a method and line numbers in source
905code and information about local variables. The format is derived from DWARF Debugging Information
906Format, Version 3 (see item 6.2). The mapping and local variable information are encoded in
907[line number program](#line-number-program) which is interpreted by
908[the state machine](#state-machine). To deduplicate the same line number programs of different
909methods all constants the program refers to are moved into [the constant pool](#constant-pool).
910
911Alignment: none
912
913Format:
914
915| Name                      | Format          | Description |
916| ----                      | ------          | ----------- |
917| `line_start`              | `uleb128`       | The initial value of line register of [the state machine](#state-machine). |
918| `num_parameters`          | `uleb128`       | Number of method parameters. |
919| `parameters`              | `uleb128[]`     | Parameters names of the method. The array has `num_parameters` elements. Each element is an offset to [String](#string) or 0 if there is no name. |
920| `constant_pool_size`      | `uleb128`       | Size of constant pool in bytes. |
921| `constant_pool`           | `uleb128[]`     | [Constant pool](#constant-pool) data of length `constant_pool_size` bytes. |
922| `line_number_program_idx` | `uleb128`       | [Line number program](#line-number-program) index in a [`LineNumberProgramIndex`](#linenumberprogramindex) structure. The program has variable length and ends with `DBG_END_SEQUENCE` opcode. |
923
924#### Constant pool
925
926Many methods has similar line number program. The difference is only in variable names,
927variable types and file names. To deduplicate such programs all constants the program refers to
928are stored in the constant pool. During interpretation of the program
929[the state machine](#state-machine) tracks a pointer to the constant pool.
930When [the state machine](#state-machine) interprets an instruction which requires a constant
931argument the machine reads the value from memory constant pool pointer points to and then increments
932the pointer. Thus programs has no explicit references to constants and could be deduplicated.
933
934#### State Machine
935
936The aim of the state machine is to generate a mapping between program counter and line numbers and
937local variable information. The machine has the following registers:
938
939| Name                 | Initial value | Description       |
940| ----                 | ------------- | ----------------- |
941| `address`            | 0             | Program counter (refers to method's instructions). Must only monotonically increase. |
942| `line`               | `line_start` from [DebugInfo](#debug_info). | Unsigned integer which corresponds to line number in source code. All lines are numbered beginning at 1 so the register mustn't have value less then 1. |
943| `file`               | Value of `SOURCE_FILE` tag in `class_data` (see [Class](#class)) or 0 | Offset to the name of source file. If there is no such information (`SOURCE_FILE` tag is absent in [Class](#class)) then the register has value 0. |
944| `prologue_end`       | `false`       | The register indicates the current address is one where entry breakpoint of the method could be set. |
945| `epilogue_begin`     | `false`       | The register indicates the current address is one where exit breakpoint of the method could be set. |
946| `constant_pool_ptr`  | Address of the `constant_pool`'s first byte from [DebugInfo](#debug_info). | Pointer to the current constant value. |
947
948#### Line Number Program
949
950A line number program consists of instructions. Each instruction has one byte opcode and optional arguments. Depending on opcode argument's value may be encoded into the instruction or the instruction requires reading the value from constant pool.
951
952| Opcode                 | Value        | Instruction Format | Constant pool arguments   | Description                           |
953| ------                 | -----        | ------------------ | -----------------------   | -----------                           |
954| `END_SEQUENCE`         | `0x00`       |                    |                           | Marks the end of line number program. |
955| `ADVANCE_PC`           | `0x01`       |                    | `uleb128`                 | Increment `address` register by the value `constant_pool_ptr` refers to without emitting a line. |
956| `ADVANCE_LINE`         | `0x02`       |                    | `sleb128`                 | Increment `line` register by the value `constant_pool_ptr` refers to without emitting a line. |
957| `START_LOCAL`          | `0x03`       | `sleb128`          | `uleb128 uleb128`         | Introduce a local variable with name and type the `constant_pool_ptr` refers to at the current address. The number of the register contains the variable is encoded in the instruction. The register's value `-1` means the accumulator register. The name is an offset to [String](#String) and the type is an offset to [ForeignClass](#foreignclass) or [Class](#class). The offsets may be `0` which means the corresponding information is absent. |
958| `START_LOCAL_EXTENDED` | `0x04`       | `sleb128`          | `uleb128 uleb128 uleb128` | Introduce a local variable with name, type and type signature the *constant_pool_ptr* refers to at the current address. The number of the register contains the variable is encoded in the instruction. The register's value `-1` means the accumulator register. The name is an offset to [String](#String), the type is an offset to [ForeignClass](#foreignclass) or [Class](#class) and the signature is an offset to TODO: figure out what are signatures. The offsets may be `0` which means the corresponding information is absent. |
959| `END_LOCAL`            | `0x05`       | `sleb128`          |                           | Mark the local variable in the specified register is out of scope. The register number is encoded in the instruction. The register's value `-1` means the accumulator register. |
960| `RESTART_LOCAL`        | `0x06`       | `sleb128`          |                           | Re-introduces a local variable at the specified register. The name and type are the same as the last local that was in the register. The register number is encoded in the instruction. The register's value `-1` means the accumulator register. |
961| `SET_PROLOGUE_END`     | `0x07`       |                    |                           | Set `prologue_end` register to `true`. Any special opcodes clear `prologue_end` register. |
962| `SET_EPILOGUE_BEGIN`   | `0x08`       |                    |                           | Set `epilogue_end` register to `true`. Any special opcodes clear `epilogue_end` register. |
963| `SET_FILE`             | `0x09`       |                    | `uleb128`                 | Set `file` register to the value `constant_pool_ptr` refers to. The argument is an offset to [String](#string) which represents the file name or `0`. |
964| `SET_SOURCE_CODE`      | `0x0a`       |                    | `uleb128`                 | Set `source_code` register to the value `constant_pool_ptr` refers to. The argument is an offset to [String](#string) which represents the source code or `0`. |
965| SET_COLUMN | `0x0b` | | `uleb128` | Set `column` register by the value `constant_pool_ptr` refers to |
966| Special opcodes        | `0x0c..0xff` |                    |                           | |
967
968Special opcodes:
969
970[The state machine](#state-machine) interprets each special opcode as follow
971(see DWARF Debugging Information Format item 6.2.5.1 Special Opcodes):
972
9731. Calculate the adjusted opcode: `adjusted_opcode = opcode - OPCODE_BASE`.
9742. Increment `address` register: `address += adjusted_opcode / LINE_RANGE`.
9753. Increment `line` register: `line += LINE_BASE + (adjusted_opcode % LINE_RANGE)`.
9764. Emit line number.
9775. Set `prologue_end` register to `false`.
9786. Set `epilogue_begin` register to `false`.
979
980Where:
981
982* `OPCODE_BASE = 0x0c`: the first special opcode.
983* `LINE_BASE = -4`: the smallest line number increment.
984* `LINE_RANGE = 15`: the number of line increments presented.
985
986### MethodHandle
987
988Alignment: none
989
990Format:
991
992| Name               | Format          | Description |
993| ----               | ------          | ----------- |
994| `type`             | `uint8_t`       | Type of the handle. Must be one of [MethodHandle's type](#types_of_methodhandle). |
995| `offset`           | `uleb128`       | Offset to the entity of the corresponding type. Type of the entity is determined depending on handle's type (see [Types of MethodHandle](#types_of_methodhandle)). |
996
997#### Types of MethodHandle
998
999The available types of a method handle are:
1000
1001| Name                 | Code              | Description |
1002| ----                 | :--:              | ----------- |
1003| `PUT_STATIC`         | `0x00`            | Method handle refers to a static setter. Offset in [MethodHandle](#methodhandle) must point to [Field](#field) or [ForeignField](#foreignfield). |
1004| `GET_STATIC`         | `0x01`            | Method handle refers to a static getter. Offset in [MethodHandle](#methodhandle) must point to [Field](#field) or [ForeignField](#foreignfield). |
1005| `PUT_INSTANCE`       | `0x02`            | Method handle refers to an instance getter. Offset in [MethodHandle](#methodhandle) must point to [Field](#field) or [ForeignField](#foreignfield). |
1006| `GET_INSTANCE`       | `0x03`            | Method handle refers to an instance setter. Offset in [MethodHandle](#methodhandle) must point to [Field](#field) or [ForeignField](#foreignfield). |
1007| `INVOKE_STATIC`      | `0x04`            | Method handle refers to a static method. Offset in [MethodHandle](#methodhandle) must point to [Method](#method) or [ForeignMethod](#foreignmethod). |
1008| `INVOKE_INSTANCE`    | `0x05`            | Method handle refers to an instance method. Offset in [MethodHandle](#methodhandle) must point to [Method](#method) or [ForeignMethod](#foreignmethod). |
1009| `INVOKE_CONSTRUCTOR` | `0x06`            | Method handle refers to a constructor. Offset in [MethodHandle](#methodhandle) must point to [Method](#method) or [ForeignMethod](#foreignmethod). |
1010| `INVOKE_DIRECT`      | `0x07`            | Method handle refers to a direct method. Offset in [MethodHandle](#methodhandle) must point to [Method](#method) or [ForeignMethod](#foreignmethod). |
1011| `INVOKE_INTERFACE`   | `0x08`            | Method handle refers to an interface method. Offset in [MethodHandle](#methodhandle) must point to [Method](#method) or [ForeignMethod](#foreignmethod). |
1012
1013#### Argument Types
1014
1015A bootstrap method can accept static arguments of the following types:
1016
1017| Type               | Code            | Description |
1018| -----              | :--:            | ----------- |
1019| `Integer`          | `0x00`          | The corresponding argument has [IntegerValue](#integervalue) encoding. |
1020| `Long`             | `0x01`          | The corresponding argument has [LongValue](#longvalue) encoding. |
1021| `Float`            | `0x02`          | The corresponding argument has [FloatValue](#floatvalue) encoding. |
1022| `Double`           | `0x03`          | The corresponding argument has [DoubleValue](#doublevalue) encoding. |
1023| `String`           | `0x04`          | The corresponding argument has [StringValue](#stringvalue) encoding. |
1024| `Class`            | `0x05`          | The corresponding argument has [ClassValue](#classvalue) encoding. |
1025| `MethodHandle`     | `0x06`          | The corresponding argument has [MethodHandleValue](#methodhandlevalue) encoding. |
1026| `MethodType`       | `0x07`          | The corresponding argument has [MethodTypeValue](#methodtypevalue) encoding. |
1027