The Getting Loaded applet, included below, simulates a Java virtual machine loading a class file. This applet accompanies Chapter 6, "The Java Class File," of Inside the Java 2 Virtual Machine. The class file being loaded in the simulation was generated by the // On CD-ROM in file classfile/ex1/Act.java class Act { public static void doMathForever() { int i = 0; for (;;) { i += 1; i *= 2; } } } The Getting Loaded applet allows you to drive the class load simulation one step at a time. For each step along the way you can read about the next chunk of bytes that is about to be consumed and interpreted by the Java virtual machine. Just press the Step button to cause the virtual machine to consume the next chunk. Pressing Back will undo the previous step, and pressing Reset will return the simulation to its original state, allowing you to start over from the beginning. The Java virtual machine is shown at the bottom left consuming the stream of bytes that makes up the class file Many items in the class file refer to constant pool entries. To make it easier for you to look up constant pool entries as you step through the simulation, a list of the contents of
Each chunk of bytes is fully explained in the text area. Because there is a lot of detail in the text area, you may wish to skim through all the steps first to get the general idea, then look back for more details. Happy clicking. Click here to view a page of links to the source code of the Getting Loaded applet. |
Copyright © 1996-1999 Bill Venners. All Rights Reserved. |