Skip to content

Class creation

hydrophobis edited this page Mar 25, 2025 · 2 revisions

Class Header and Footer

emit_class_header()

  • Emits the Java class file magic number (0xCAFEBABE).
  • Sets the class file version to Java 8 (minor_version = 0, major_version = 52).

emit_class_footer(uint16_t this_class, uint8_t this_class_flags, uint16_t super_class)

  • Sets the access flags to the given flag integer.
  • References the class and its superclass (this_class and super_class).

Code Attribute Handling

code_attribute_start(uint16_t name_index, uint16_t max_stack, uint16_t max_locals)

  • Starts a code attribute with the method's name and stack/locals limits.
  • Begins bytecode emission with bytecode_start().

code_attribute_end()

  • Ends bytecode emission with bytecode_end().
  • Emits 0 for exception table length and attributes count.
  • Ends the attribute with attribute_end().

Clone this wiki locally