Section 4.8 of The Java Virtual Machine Specification contains a large set of rules that programs must follow if they want to run in the machine. It is the job of the verification algorithm to prove that each and every one of these rules has been followed. These rules were designed to be verifiable by just examining each class, without resorting to running the class. The verification algorithm works by asking a set of questions about the class file. These questions fall into five general categories.
These questions can be answered statically, that is, from looking at the bytecodes without executing the program. This enables the virtual machine to stop a badly behaving program before it starts. It also permits faster execution, because the virtual machine doesn't have to check some kinds of errors as the program runs. If the program has passed verification, then these errors cannot occur. |