jawa.util.bytecode module¶
Utilities for reading & writing JVM method bytecode.
-
class
jawa.util.bytecode.
Instruction
[source]¶ Bases:
jawa.util.bytecode.Instruction
Represents a single JVM instruction, consisting of an opcode and its potential operands.
-
details
¶ Extended opcode information.
-
name
¶ Alias for mnemonic.
-
size_on_disk
(start_pos=0)[source]¶ Returns the size of this instruction and its operands when packed. start_pos is required for the tableswitch and lookupswitch instruction as the padding depends on alignment.
-
wide
¶ True
if this instruction needs to be prefixed by the WIDE opcode.
-
-
class
jawa.util.bytecode.
Operand
(op_type, value)¶ Bases:
tuple
-
op_type
¶ Alias for field number 0
-
value
¶ Alias for field number 1
-
-
class
jawa.util.bytecode.
OperandFmts
[source]¶ Bases:
enum.Enum
An enumeration.
-
BYTE
= <Struct object>¶
-
INTEGER
= <Struct object>¶
-
SHORT
= <Struct object>¶
-
UBYTE
= <Struct object>¶
-
USHORT
= <Struct object>¶
-
-
class
jawa.util.bytecode.
OperandTypes
[source]¶ Bases:
enum.IntEnum
Constants used to determine the “type” of operand on an opcode, such as a BRANCH [offset] or a LITERAL [value].
-
BRANCH
= 40¶
-
CONSTANT_INDEX
= 30¶
-
LITERAL
= 10¶
-
LOCAL_INDEX
= 20¶
-
PADDING
= 50¶
-
-
jawa.util.bytecode.
load_bytecode_definitions
(*, path=None) → dict[source]¶ Load bytecode definitions from JSON file.
If no path is provided the default bytecode.json will be loaded.
Parameters: path – Either None or a path to a JSON file to load containing bytecode definitions.