jclass
 
Loading...
Searching...
No Matches
jclass.c File Reference
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Macros

#define J_CLASS_BEGIN   {}
 Readability macro to mark where class generation starts.
 
#define J_CLASS_END   {}
 Readability macro to mark where class generation ends.
 
#define ACC_PUBLIC   0x0001
 Class or method is public (accessible from anywhere).
 
#define ACC_PRIVATE   0x0002
 Class or method is private (accessible only within the defining class).
 
#define ACC_PROTECTED   0x0004
 Class or method is protected (accessible within the same package and subclasses).
 
#define ACC_STATIC   0x0008
 Class, method, or field is static (belongs to the class rather than instances).
 
#define ACC_FINAL   0x0010
 Class or method is final (cannot be subclassed or overridden).
 
#define ACC_SUPER   0x0020
 Class uses the "super" keyword for method calls.
 
#define ACC_SYNCHRONIZED   0x0020
 Method is synchronized (can only be executed by one thread at a time).
 
#define ACC_NATIVE   0x0100
 Method is native (implemented in a language other than Java, such as C or Assembly).
 
#define ACC_INTERFACE   0x0200
 Class is an interface (cannot have instance fields or non-abstract methods).
 
#define ACC_ABSTRACT   0x0400
 Class is abstract (cannot be instantiated).
 
#define ACC_STRICT   0x0800
 Method is strict (follows strict floating-point calculations).
 
#define u1(v)   (uint8_t)(v)
 Creates a byte from the given value.
 
#define u2(v)
 Creates 2 bytes from the given value.
 
#define u4(v)
 Creates 4 bytes from the given value.
 
#define BUFFER_SIZE   65536
 The size of the buffer for bytecode, may be overidden if needed.
 

Enumerations

enum  {
  T_BOOLEAN = 4 , T_CHAR = 5 , T_FLOAT = 6 , T_DOUBLE = 7 ,
  T_BYTE = 8 , T_SHORT = 9 , T_INT = 10 , T_LONG = 11
}
 The magic numbers for primitive types in java. More...
 

Functions

static void emit_byte (uint8_t b)
 Helper function. Do not use unless you know what you're doing.
 
static void emit_u1 (uint8_t v)
 Writes a byte to the buffer.
 
static void emit_u2 (uint16_t v)
 Takes a uint16_t and splits it into 2 bytes (0x1024 -> { 0x10, 0x24 }), which it then writes into the buffer.
 
static void emit_u4 (uint32_t v)
 Splits a uint32_t into 4 bytes (0x12345678 -> { 0x12, 0x34, 0x56, 0x78 }) and writes them into the buffer.
 
static size_t current_offset ()
 Returns the current buffer position that will be emitted to.
 
static void patch_u2 (size_t pos, uint16_t v)
 Places 2 bytes in the given position in the buffer (0x1024 -> (0x10 -> pos) & (0x24 -> pos + 1))
 
static void patch_u4 (size_t pos, uint32_t v)
 Places 4 bytes in the given position in the buffer (0x12345678 -> (0x12 -> pos) & (0x34 -> pos + 1) & (0x56 -> pos + 2) & (0x78 -> pos + 3))
 
void constant_pool_start ()
 Begins the constant pool.
 
static void increment_cp_counter ()
 Helper function. Do not use unless you know what you are doing.
 
void constant_utf8 (const char *string)
 Converts a char* to a constant UTF-8 string.
 
void constant_integer (uint32_t value)
 Creates a constant integer.
 
void constant_float (uint32_t value)
 Creates a constant float.
 
void constant_long (uint64_t value)
 Creates a constant long.
 
void constant_double (uint64_t value)
 Creates a constant double.
 
void constant_class (uint16_t name_index)
 Creates a constant class reference.
 
void constant_string (uint16_t string_index)
 Creates a constant string from a constant UTF-8.
 
void constant_fieldref (uint16_t class_index, uint16_t name_and_type_index)
 Builds a reference to a field.
 
void constant_methodref (uint16_t class_index, uint16_t name_and_type_index)
 Builds a reference to a method.
 
void constant_interfacemethodref (uint16_t class_index, uint16_t name_and_type_index)
 Builds a reference to a method from an interface.
 
void constant_nameandtype (uint16_t name_index, uint16_t descriptor_index)
 Builds a name and type.
 
void constant_pool_end ()
 Marks the end of the constant pool.
 
void interfaces_start ()
 Marks the start of the list of interfaces the class is using.
 
void interface_entry (uint16_t interface_val)
 Adds a new interface to the list.
 
void interfaces_end ()
 Marks the end of the list of interfaces.
 
void attributes_start ()
 Marks the start of the list of attributes the class has.
 
void attribute_start (uint16_t attribute_name_index)
 Marks the start of a new attribute.
 
void attribute_end ()
 Marks the end of an attribute.
 
void attributes_end ()
 Marks the start of the attributes section.
 
void fields_start ()
 Marks the start of the fields section.
 
void field_info (uint16_t access_flags, uint16_t name_index, uint16_t descriptor_index)
 Creates a new field and begins it's attributes section.
 
void end_field_info ()
 Ends the current fields attributes section and the field itself.
 
void fields_end ()
 Marks the end of the fields section.
 
void methods_start ()
 Marks the start of the methods section.
 
void method_info (uint16_t access_flags, uint16_t name_index, uint16_t descriptor_index)
 Creates a new method and begins it's attributes section.
 
void end_method_info ()
 Ends the current methods attributes section and the method itself.
 
void methods_end ()
 Marks the end of the methods section.
 
void bytecode_start ()
 Marks the start of a bytecode section.
 
void bytecode_end ()
 Marks the end of a bytecode section.
 
void exceptions_start ()
 Marks the start of an exceptions section.
 
void exception_entry (uint16_t start_pc, uint16_t end_pc, uint16_t handler_pc, uint16_t catch_type)
 
void exceptions_end ()
 Marks the end of a bytecode section.
 
void aaload ()
 
void aastore ()
 
void aconst_null ()
 
void aload (uint16_t index)
 
void anewarray (uint16_t class_index)
 
void areturn ()
 
void arraylength ()
 
void astore (uint16_t index)
 
void athrow ()
 
void baload ()
 
void bastore ()
 
void bipush (int8_t byte_val)
 
void caload ()
 
void castore ()
 
void checkcast (uint16_t class_index)
 
void d2f ()
 
void d2i ()
 
void d2l ()
 
void dadd ()
 
void daload ()
 
void dastore ()
 
void dcmpg ()
 
void dcmpl ()
 
void dconst_0 ()
 
void dconst_1 ()
 
void ddiv ()
 
void dload (uint16_t index)
 
void dmul ()
 
void dneg ()
 
void j_drem ()
 
void dreturn ()
 
void dstore (uint16_t index)
 
void dsub ()
 
void dup ()
 
void dup_x1 ()
 
void dup_x2 ()
 
void dup2 ()
 
void dup2_x1 ()
 
void dup2_x2 ()
 
void f2d ()
 
void f2i ()
 
void f2l ()
 
void fadd ()
 
void faload ()
 
void fastore ()
 
void fcmpg ()
 
void fcmpl ()
 
void fconst_0 ()
 
void fconst_1 ()
 
void fconst_2 ()
 
void fdiv ()
 
void fload (uint16_t index)
 
void fmul ()
 
void fneg ()
 
void frem ()
 
void freturn ()
 
void fstore (uint16_t index)
 
void fsub ()
 
void getfield (uint16_t index)
 
void getstatic (uint16_t index)
 
void goto_inst (size_t branch_target)
 
void goto_w_inst (size_t branch_target)
 
void i2b ()
 
void i2c ()
 
void i2d ()
 
void i2f ()
 
void i2l ()
 
void i2s ()
 
void iadd ()
 
void iaload ()
 
void iand ()
 
void iastore ()
 
void iconst_m1 ()
 
void iconst_0 ()
 
void iconst_1 ()
 
void iconst_2 ()
 
void iconst_3 ()
 
void iconst_4 ()
 
void iconst_5 ()
 
void idiv ()
 
void if_acmpeq (size_t branch_target)
 
void if_acmpne (size_t branch_target)
 
void if_icmpeq (size_t branch_target)
 
void if_icmpne (size_t branch_target)
 
void if_icmplt (size_t branch_target)
 
void if_icmpge (size_t branch_target)
 
void if_icmpgt (size_t branch_target)
 
void if_icmple (size_t branch_target)
 
void ifeq (size_t branch_target)
 
void ifne (size_t branch_target)
 
void iflt (size_t branch_target)
 
void ifge (size_t branch_target)
 
void ifgt (size_t branch_target)
 
void ifle (size_t branch_target)
 
void ifnonnull (size_t branch_target)
 
void ifnull (size_t branch_target)
 
void iinc (uint16_t index, int16_t constant_val)
 
void iload (uint16_t index)
 
void imul ()
 
void ineg ()
 
void instanceof (uint16_t index)
 
void invokedynamic (uint16_t index)
 
void invokeinterface (uint16_t index, uint8_t count)
 
void invokespecial (uint16_t index)
 
void invokestatic (uint16_t index)
 
void invokevirtual (uint16_t index)
 
void ior ()
 
void irem ()
 
void ireturn ()
 
void ishl ()
 
void ishr ()
 
void istore (uint16_t index)
 
void isub ()
 
void iushr ()
 
void ixor ()
 
void jsr_inst (size_t branch_target)
 
void jsr_w_inst (size_t branch_target)
 
void l2d ()
 
void l2f ()
 
void l2i ()
 
void ladd ()
 
void laload ()
 
void land ()
 
void lastore ()
 
void lcmp ()
 
void lconst_0 ()
 
void lconst_1 ()
 
void ldc (uint16_t index)
 
void ldc_w (uint16_t index)
 
void ldc2_w (uint16_t index)
 
void j_ldiv ()
 
void lload (uint16_t index)
 
void lmul ()
 
void lneg ()
 
void lor ()
 
void lrem ()
 
void lreturn ()
 
void lshl ()
 
void lshr ()
 
void lstore (uint16_t index)
 
void lsub ()
 
void lushr ()
 
void lxor ()
 
void monitorenter ()
 
void monitorexit ()
 
void multianewarray (uint16_t index, uint8_t dimensions)
 
void new_inst (uint16_t index)
 
void newarray (uint8_t atype)
 
void nop ()
 
void pop_inst ()
 
void pop2 ()
 
void putfield (uint16_t index)
 
void putstatic (uint16_t index)
 
void ret_inst (uint16_t index)
 
void return_inst ()
 
void saload ()
 
void sastore ()
 
void sipush (uint16_t value)
 
void swap ()
 
void breakpoint ()
 
void impdep1 ()
 
void impdep2 ()
 
void impdep2_dup ()
 
static void emit_class_header ()
 
static void emit_class_footer (uint16_t this_class, uint8_t this_class_flags, uint16_t super_class)
 
void code_attribute_start (uint16_t name_index, uint16_t max_stack, uint16_t max_locals)
 
void code_attribute_end ()
 

Variables

static uint8_t outputBuffer [BUFFER_SIZE]
 Output buffer where the JVM bytecode is stored.
 
static size_t outputIndex = 0
 Current index of the output buffer.
 
static size_t cp_count_offset = 0
 Do not modify.
 
static uint16_t constant_pool_counter = 0
 Keeps track of the size of the constant pool.
 
static size_t interfaces_count_offset = 0
 Do not modify.
 
static uint16_t interfaces_counter = 0
 Keeps track of how many interfaces there are.
 
static size_t attributes_count_offset = 0
 Do not modify.
 
static uint16_t attributes_counter = 0
 Tracks how many attributes there are.
 
size_t attribute_start_offset = 0
 
static size_t fields_count_offset = 0
 
static uint16_t fields_counter = 0
 Counts the amount of fields in the class.
 
static size_t methods_count_offset = 0
 
static uint16_t methods_counter = 0
 Counts the amount of methods in the class.
 
static size_t bytecode_length_offset = 0
 
static size_t bytecode_offset = 0
 
static size_t exception_table_length_offset = 0
 
static uint16_t exception_counter = 0
 

Macro Definition Documentation

◆ ACC_ABSTRACT

#define ACC_ABSTRACT   0x0400

Class is abstract (cannot be instantiated).

◆ ACC_FINAL

#define ACC_FINAL   0x0010

Class or method is final (cannot be subclassed or overridden).

◆ ACC_INTERFACE

#define ACC_INTERFACE   0x0200

Class is an interface (cannot have instance fields or non-abstract methods).

◆ ACC_NATIVE

#define ACC_NATIVE   0x0100

Method is native (implemented in a language other than Java, such as C or Assembly).

◆ ACC_PRIVATE

#define ACC_PRIVATE   0x0002

Class or method is private (accessible only within the defining class).

◆ ACC_PROTECTED

#define ACC_PROTECTED   0x0004

Class or method is protected (accessible within the same package and subclasses).

◆ ACC_PUBLIC

#define ACC_PUBLIC   0x0001

Class or method is public (accessible from anywhere).

◆ ACC_STATIC

#define ACC_STATIC   0x0008

Class, method, or field is static (belongs to the class rather than instances).

◆ ACC_STRICT

#define ACC_STRICT   0x0800

Method is strict (follows strict floating-point calculations).

◆ ACC_SUPER

#define ACC_SUPER   0x0020

Class uses the "super" keyword for method calls.

◆ ACC_SYNCHRONIZED

#define ACC_SYNCHRONIZED   0x0020

Method is synchronized (can only be executed by one thread at a time).

◆ BUFFER_SIZE

#define BUFFER_SIZE   65536

The size of the buffer for bytecode, may be overidden if needed.

◆ J_CLASS_BEGIN

#define J_CLASS_BEGIN   {}

Readability macro to mark where class generation starts.

◆ J_CLASS_END

#define J_CLASS_END   {}

Readability macro to mark where class generation ends.

◆ u1

#define u1 (   v)    (uint8_t)(v)

Creates a byte from the given value.

Parameters
vThe value to make the byte out of

◆ u2

#define u2 (   v)
Value:
{ \
(uint8_t)(((v) >> 8) & 0xFF), \
(uint8_t)((v) & 0xFF) \
}

Creates 2 bytes from the given value.

Parameters
vThe value to make the bytes out of

◆ u4

#define u4 (   v)
Value:
{ \
(uint8_t)((v) >> 24), \
(uint8_t)(((v) >> 16) & 0xFF), \
(uint8_t)(((v) >> 8) & 0xFF), \
(uint8_t)((v) & 0xFF) \
}

Creates 4 bytes from the given value.

Parameters
vThe value to make the bytes out of

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

The magic numbers for primitive types in java.

Enumerator
T_BOOLEAN 
T_CHAR 
T_FLOAT 
T_DOUBLE 
T_BYTE 
T_SHORT 
T_INT 
T_LONG 

Function Documentation

◆ aaload()

void aaload ( )

◆ aastore()

void aastore ( )

◆ aconst_null()

void aconst_null ( )

◆ aload()

void aload ( uint16_t  index)

◆ anewarray()

void anewarray ( uint16_t  class_index)

◆ areturn()

void areturn ( )

◆ arraylength()

void arraylength ( )

◆ astore()

void astore ( uint16_t  index)

◆ athrow()

void athrow ( )

◆ attribute_end()

void attribute_end ( )

Marks the end of an attribute.

◆ attribute_start()

void attribute_start ( uint16_t  attribute_name_index)

Marks the start of a new attribute.

Parameters
attribute_name_indexConstant pool index of the name of the attribute

◆ attributes_end()

void attributes_end ( )

Marks the start of the attributes section.

◆ attributes_start()

void attributes_start ( )

Marks the start of the list of attributes the class has.

◆ baload()

void baload ( )

◆ bastore()

void bastore ( )

◆ bipush()

void bipush ( int8_t  byte_val)

◆ breakpoint()

void breakpoint ( )

◆ bytecode_end()

void bytecode_end ( )

Marks the end of a bytecode section.

◆ bytecode_start()

void bytecode_start ( )

Marks the start of a bytecode section.

◆ caload()

void caload ( )

◆ castore()

void castore ( )

◆ checkcast()

void checkcast ( uint16_t  class_index)

◆ code_attribute_end()

void code_attribute_end ( )

◆ code_attribute_start()

void code_attribute_start ( uint16_t  name_index,
uint16_t  max_stack,
uint16_t  max_locals 
)

◆ constant_class()

void constant_class ( uint16_t  name_index)

Creates a constant class reference.

Parameters
name_indexThe index of the UTF-8 which is the class name (java/lang/Object)

◆ constant_double()

void constant_double ( uint64_t  value)

Creates a constant double.

Parameters
valueThe 64 bit value to add to the constant pool

◆ constant_fieldref()

void constant_fieldref ( uint16_t  class_index,
uint16_t  name_and_type_index 
)

Builds a reference to a field.

Parameters
class_indexConstant pool index of the class from which the field is from
name_and_type_indexConstant pool index of the name and type of the field

◆ constant_float()

void constant_float ( uint32_t  value)

Creates a constant float.

Parameters
valueThe float to add to the constant pool

◆ constant_integer()

void constant_integer ( uint32_t  value)

Creates a constant integer.

Parameters
valueThe integer to add to the constant pool

◆ constant_interfacemethodref()

void constant_interfacemethodref ( uint16_t  class_index,
uint16_t  name_and_type_index 
)

Builds a reference to a method from an interface.

Parameters
class_indexConstant pool index of the class from which the field is from
name_and_type_indexConstant pool index of the name and type of the field

◆ constant_long()

void constant_long ( uint64_t  value)

Creates a constant long.

Parameters
valueThe 64 bit value to add to the constant pool

◆ constant_methodref()

void constant_methodref ( uint16_t  class_index,
uint16_t  name_and_type_index 
)

Builds a reference to a method.

Parameters
class_indexConstant pool index of the class from which the field is from
name_and_type_indexConstant pool index of the name and type of the field

◆ constant_nameandtype()

void constant_nameandtype ( uint16_t  name_index,
uint16_t  descriptor_index 
)

Builds a name and type.

Parameters
name_indexConstant pool index of the name
descriptor_indexConstant pool index of the descriptor, a return type and params

◆ constant_pool_end()

void constant_pool_end ( )

Marks the end of the constant pool.

◆ constant_pool_start()

void constant_pool_start ( )

Begins the constant pool.

◆ constant_string()

void constant_string ( uint16_t  string_index)

Creates a constant string from a constant UTF-8.

Parameters
string_indexConstant pool index of the UTF-8

◆ constant_utf8()

void constant_utf8 ( const char *  string)

Converts a char* to a constant UTF-8 string.

Parameters
stringThe string to convert

◆ current_offset()

static size_t current_offset ( )
static

Returns the current buffer position that will be emitted to.

◆ d2f()

void d2f ( )

◆ d2i()

void d2i ( )

◆ d2l()

void d2l ( )

◆ dadd()

void dadd ( )

◆ daload()

void daload ( )

◆ dastore()

void dastore ( )

◆ dcmpg()

void dcmpg ( )

◆ dcmpl()

void dcmpl ( )

◆ dconst_0()

void dconst_0 ( )

◆ dconst_1()

void dconst_1 ( )

◆ ddiv()

void ddiv ( )

◆ dload()

void dload ( uint16_t  index)

◆ dmul()

void dmul ( )

◆ dneg()

void dneg ( )

◆ dreturn()

void dreturn ( )

◆ dstore()

void dstore ( uint16_t  index)

◆ dsub()

void dsub ( )

◆ dup()

void dup ( )

◆ dup2()

void dup2 ( )

◆ dup2_x1()

void dup2_x1 ( )

◆ dup2_x2()

void dup2_x2 ( )

◆ dup_x1()

void dup_x1 ( )

◆ dup_x2()

void dup_x2 ( )

◆ emit_byte()

static void emit_byte ( uint8_t  b)
static

Helper function. Do not use unless you know what you're doing.

◆ emit_class_footer()

static void emit_class_footer ( uint16_t  this_class,
uint8_t  this_class_flags,
uint16_t  super_class 
)
static

◆ emit_class_header()

static void emit_class_header ( )
static

◆ emit_u1()

static void emit_u1 ( uint8_t  v)
static

Writes a byte to the buffer.

Parameters
vThe value to place in the buffer

◆ emit_u2()

static void emit_u2 ( uint16_t  v)
static

Takes a uint16_t and splits it into 2 bytes (0x1024 -> { 0x10, 0x24 }), which it then writes into the buffer.

Parameters
vThe two values to place in the buffer

◆ emit_u4()

static void emit_u4 ( uint32_t  v)
static

Splits a uint32_t into 4 bytes (0x12345678 -> { 0x12, 0x34, 0x56, 0x78 }) and writes them into the buffer.

Parameters
vThe values to place into the buffer

◆ end_field_info()

void end_field_info ( )

Ends the current fields attributes section and the field itself.

◆ end_method_info()

void end_method_info ( )

Ends the current methods attributes section and the method itself.

◆ exception_entry()

void exception_entry ( uint16_t  start_pc,
uint16_t  end_pc,
uint16_t  handler_pc,
uint16_t  catch_type 
)

◆ exceptions_end()

void exceptions_end ( )

Marks the end of a bytecode section.

◆ exceptions_start()

void exceptions_start ( )

Marks the start of an exceptions section.

◆ f2d()

void f2d ( )

◆ f2i()

void f2i ( )

◆ f2l()

void f2l ( )

◆ fadd()

void fadd ( )

◆ faload()

void faload ( )

◆ fastore()

void fastore ( )

◆ fcmpg()

void fcmpg ( )

◆ fcmpl()

void fcmpl ( )

◆ fconst_0()

void fconst_0 ( )

◆ fconst_1()

void fconst_1 ( )

◆ fconst_2()

void fconst_2 ( )

◆ fdiv()

void fdiv ( )

◆ field_info()

void field_info ( uint16_t  access_flags,
uint16_t  name_index,
uint16_t  descriptor_index 
)

Creates a new field and begins it's attributes section.

Parameters
access_flagsThe JVM flags for the field
name_indexConstant pool index of the name of the field
descriptor_indexThe constant pool index of the decriptor for the field

◆ fields_end()

void fields_end ( )

Marks the end of the fields section.

◆ fields_start()

void fields_start ( )

Marks the start of the fields section.

◆ fload()

void fload ( uint16_t  index)

◆ fmul()

void fmul ( )

◆ fneg()

void fneg ( )

◆ frem()

void frem ( )

◆ freturn()

void freturn ( )

◆ fstore()

void fstore ( uint16_t  index)

◆ fsub()

void fsub ( )

◆ getfield()

void getfield ( uint16_t  index)

◆ getstatic()

void getstatic ( uint16_t  index)

◆ goto_inst()

void goto_inst ( size_t  branch_target)

◆ goto_w_inst()

void goto_w_inst ( size_t  branch_target)

◆ i2b()

void i2b ( )

◆ i2c()

void i2c ( )

◆ i2d()

void i2d ( )

◆ i2f()

void i2f ( )

◆ i2l()

void i2l ( )

◆ i2s()

void i2s ( )

◆ iadd()

void iadd ( )

◆ iaload()

void iaload ( )

◆ iand()

void iand ( )

◆ iastore()

void iastore ( )

◆ iconst_0()

void iconst_0 ( )

◆ iconst_1()

void iconst_1 ( )

◆ iconst_2()

void iconst_2 ( )

◆ iconst_3()

void iconst_3 ( )

◆ iconst_4()

void iconst_4 ( )

◆ iconst_5()

void iconst_5 ( )

◆ iconst_m1()

void iconst_m1 ( )

◆ idiv()

void idiv ( )

◆ if_acmpeq()

void if_acmpeq ( size_t  branch_target)

◆ if_acmpne()

void if_acmpne ( size_t  branch_target)

◆ if_icmpeq()

void if_icmpeq ( size_t  branch_target)

◆ if_icmpge()

void if_icmpge ( size_t  branch_target)

◆ if_icmpgt()

void if_icmpgt ( size_t  branch_target)

◆ if_icmple()

void if_icmple ( size_t  branch_target)

◆ if_icmplt()

void if_icmplt ( size_t  branch_target)

◆ if_icmpne()

void if_icmpne ( size_t  branch_target)

◆ ifeq()

void ifeq ( size_t  branch_target)

◆ ifge()

void ifge ( size_t  branch_target)

◆ ifgt()

void ifgt ( size_t  branch_target)

◆ ifle()

void ifle ( size_t  branch_target)

◆ iflt()

void iflt ( size_t  branch_target)

◆ ifne()

void ifne ( size_t  branch_target)

◆ ifnonnull()

void ifnonnull ( size_t  branch_target)

◆ ifnull()

void ifnull ( size_t  branch_target)

◆ iinc()

void iinc ( uint16_t  index,
int16_t  constant_val 
)

◆ iload()

void iload ( uint16_t  index)

◆ impdep1()

void impdep1 ( )

◆ impdep2()

void impdep2 ( )

◆ impdep2_dup()

void impdep2_dup ( )

◆ imul()

void imul ( )

◆ increment_cp_counter()

static void increment_cp_counter ( )
static

Helper function. Do not use unless you know what you are doing.

◆ ineg()

void ineg ( )

◆ instanceof()

void instanceof ( uint16_t  index)

◆ interface_entry()

void interface_entry ( uint16_t  interface_val)

Adds a new interface to the list.

Parameters
interface_valNo idea

◆ interfaces_end()

void interfaces_end ( )

Marks the end of the list of interfaces.

◆ interfaces_start()

void interfaces_start ( )

Marks the start of the list of interfaces the class is using.

◆ invokedynamic()

void invokedynamic ( uint16_t  index)

◆ invokeinterface()

void invokeinterface ( uint16_t  index,
uint8_t  count 
)

◆ invokespecial()

void invokespecial ( uint16_t  index)

◆ invokestatic()

void invokestatic ( uint16_t  index)

◆ invokevirtual()

void invokevirtual ( uint16_t  index)

◆ ior()

void ior ( )

◆ irem()

void irem ( )

◆ ireturn()

void ireturn ( )

◆ ishl()

void ishl ( )

◆ ishr()

void ishr ( )

◆ istore()

void istore ( uint16_t  index)

◆ isub()

void isub ( )

◆ iushr()

void iushr ( )

◆ ixor()

void ixor ( )

◆ j_drem()

void j_drem ( )

◆ j_ldiv()

void j_ldiv ( )

◆ jsr_inst()

void jsr_inst ( size_t  branch_target)

◆ jsr_w_inst()

void jsr_w_inst ( size_t  branch_target)

◆ l2d()

void l2d ( )

◆ l2f()

void l2f ( )

◆ l2i()

void l2i ( )

◆ ladd()

void ladd ( )

◆ laload()

void laload ( )

◆ land()

void land ( )

◆ lastore()

void lastore ( )

◆ lcmp()

void lcmp ( )

◆ lconst_0()

void lconst_0 ( )

◆ lconst_1()

void lconst_1 ( )

◆ ldc()

void ldc ( uint16_t  index)

◆ ldc2_w()

void ldc2_w ( uint16_t  index)

◆ ldc_w()

void ldc_w ( uint16_t  index)

◆ lload()

void lload ( uint16_t  index)

◆ lmul()

void lmul ( )

◆ lneg()

void lneg ( )

◆ lor()

void lor ( )

◆ lrem()

void lrem ( )

◆ lreturn()

void lreturn ( )

◆ lshl()

void lshl ( )

◆ lshr()

void lshr ( )

◆ lstore()

void lstore ( uint16_t  index)

◆ lsub()

void lsub ( )

◆ lushr()

void lushr ( )

◆ lxor()

void lxor ( )

◆ method_info()

void method_info ( uint16_t  access_flags,
uint16_t  name_index,
uint16_t  descriptor_index 
)

Creates a new method and begins it's attributes section.

Parameters
access_flagsThe JVM flags for the method
name_indexConstant pool index of the name of the method
descriptor_indexThe constant pool index of the decriptor for the method

◆ methods_end()

void methods_end ( )

Marks the end of the methods section.

◆ methods_start()

void methods_start ( )

Marks the start of the methods section.

◆ monitorenter()

void monitorenter ( )

◆ monitorexit()

void monitorexit ( )

◆ multianewarray()

void multianewarray ( uint16_t  index,
uint8_t  dimensions 
)

◆ new_inst()

void new_inst ( uint16_t  index)

◆ newarray()

void newarray ( uint8_t  atype)

◆ nop()

void nop ( )

◆ patch_u2()

static void patch_u2 ( size_t  pos,
uint16_t  v 
)
static

Places 2 bytes in the given position in the buffer (0x1024 -> (0x10 -> pos) & (0x24 -> pos + 1))

Parameters
posWhere in the buffer to place the bytes
vThe two bytes to place

◆ patch_u4()

static void patch_u4 ( size_t  pos,
uint32_t  v 
)
static

Places 4 bytes in the given position in the buffer (0x12345678 -> (0x12 -> pos) & (0x34 -> pos + 1) & (0x56 -> pos + 2) & (0x78 -> pos + 3))

Parameters
posThe 4 bytes to place in the buffer

◆ pop2()

void pop2 ( )

◆ pop_inst()

void pop_inst ( )

◆ putfield()

void putfield ( uint16_t  index)

◆ putstatic()

void putstatic ( uint16_t  index)

◆ ret_inst()

void ret_inst ( uint16_t  index)

◆ return_inst()

void return_inst ( )

◆ saload()

void saload ( )

◆ sastore()

void sastore ( )

◆ sipush()

void sipush ( uint16_t  value)

◆ swap()

void swap ( )

Variable Documentation

◆ attribute_start_offset

size_t attribute_start_offset = 0

◆ attributes_count_offset

size_t attributes_count_offset = 0
static

Do not modify.

◆ attributes_counter

uint16_t attributes_counter = 0
static

Tracks how many attributes there are.

◆ bytecode_length_offset

size_t bytecode_length_offset = 0
static

◆ bytecode_offset

size_t bytecode_offset = 0
static

◆ constant_pool_counter

uint16_t constant_pool_counter = 0
static

Keeps track of the size of the constant pool.

◆ cp_count_offset

size_t cp_count_offset = 0
static

Do not modify.

◆ exception_counter

uint16_t exception_counter = 0
static

◆ exception_table_length_offset

size_t exception_table_length_offset = 0
static

◆ fields_count_offset

size_t fields_count_offset = 0
static

◆ fields_counter

uint16_t fields_counter = 0
static

Counts the amount of fields in the class.

◆ interfaces_count_offset

size_t interfaces_count_offset = 0
static

Do not modify.

◆ interfaces_counter

uint16_t interfaces_counter = 0
static

Keeps track of how many interfaces there are.

◆ methods_count_offset

size_t methods_count_offset = 0
static

◆ methods_counter

uint16_t methods_counter = 0
static

Counts the amount of methods in the class.

◆ outputBuffer

uint8_t outputBuffer[BUFFER_SIZE]
static

Output buffer where the JVM bytecode is stored.

◆ outputIndex

size_t outputIndex = 0
static

Current index of the output buffer.