-
Notifications
You must be signed in to change notification settings - Fork 0
Attribute management
These functions manage the attributes section of the Java class file. This section lists the attributes associated with the class.
-
void attributes_start()
Initializes the attributes section. Reserves space for theattributes_countand starts the counter at0. -
void attributes_end()
Finalizes the attributes section by patching the total entry count at the reserved location.
-
Attribute Reference →
attribute_start(uint16_t attribute_name_index)
Adds an attribute reference to the section. Increments the counter and reserves space forattribute_length. -
void attribute_end()
Finalizes the current attribute by calculating its length and updating theattribute_lengthfield.
-
void patch_u2(size_t pos, uint16_t v)
Updates a 2-byte value in the buffer (used to finalizeattributes_count). -
void patch_u4(size_t pos, uint32_t v)
Updates a 4-byte value in the buffer (used forattribute_length).
attributes_start();
attribute_start(5); // Adds an attribute reference with name index 5
attribute_end(); // Finalizes the attribute
attributes_end();This will generate an attributes section with one entry.