Saturday, April 21, 2012

Java Bytecode: Lesson 2

Each of the Java bytecodes fall into a few categories, here they are, along with examples:

  • Loading and Storing (aload_0, astore_0)

  • Logic and Arithmetic (dcmpg, iadd)

  • Type Conversion (i2d)

  • Object Creation and Manipulation (new, putfield)

  • Stack Management (swap)

  • Control Transfer (goto)

  • Method Invoking and Returning (invokestatic, areturn)

  • And of course, nothing (nop)

Most bytecodes are also prefixed by the initial object type:

  • Integer (i)

  • Long (l)

  • Short (s)

  • Byte (b)

  • Character (c)

  • Float (f)

  • Double (d)

  • Reference (a)

- Wikipedia article on Java bytecode.

For further information on each specific bytecode, you can look at this Wikipedia article.

Next time I will dissect the bytecode of such a simple program in any language, the "Hello world" example.

No comments:

Post a Comment