Chapter 9. Inside a Java class FileYour first Java program probably looked something like this: public class hello { public static void main(String argv[]) { System.out.println("Hello, world"); } } You ran it through the Java compiler > javac hello.java to create the file hello.class. Then you ran the program > java hello Hello, world > and exulted in having mastered another programming language. The hello.class file contains a Java virtual machine bytecode class that produces the intended effect of hello.java. The file hello.class is called a class file. The class file format is described in chapter 4 of The Java Virtual Machine Specification. All JVM implementations are required to treat this file in the same way. This is the heart of the "Write Once, Run Anywhere" promise of Java. The DumpClass program, provided with this book and detailed in appendix B.3, provides a byte-by-byte disassembly of a class file. This chapter examines the output of the DumpClass program on the hello.class file to explore the concepts of the class file in more depth. |