Java Bytecode

Just reading about Java Bytecode manipulation in Ted Neward’s article on The Server Side, something I haven’t really made any investigations into before. Having done a little assembly in my past, it seems fairly straight forward. I guess the key points are:

  • javap is a bytecode disassembler
  • constants are defined in the constant-pool
  • opcodes manipulate operands from the execution stack
  • the execution stack is populated with operands
  • categories of opcodes:
    • stack manipulation
    • branching and control flow
    • arithmetic
    • object model instructions (creating arrays of objects, setting fields, invoking methods, casting)
    • block synchronization
  • exceptions are handled by an exception table that handles ranges of bytecode
  • there are 212 current opcodes, with room for 46 more (all documented in JVM specification)
  • Bill Venners book "Inside the Java Virtual Machine" would be a great place to start if I wanted to look into this further.