In a recent question asked recently my simple minded answer highlighted many of my misconceptions about Java, the JVM, and how the code gets compiled and run. This has created
Suggested reading: the JVM spec.
You might also want to play with BCEL - there are other libraries around for manipulating bytecode, but that's probably the best known one.