Could someone list major tasks that the bytecode verifier has to perform to guarantee correctness of the program? Is there a standard, minimal set of responsibilities defined in JVM specification? I was also wondering whether verifications spans across other phases such as loading and initializing.
Java – Responsibilities of JVM bytecode verifier
javajvm
Related Topic
- Java – How to tell if I’m running in 64-bit JVM or 32-bit JVM (from within a program)
- Java – JVM option -Xss – What does it do exactly
- Java – the difference between JVM, JDK, JRE & OpenJDK
- Java – What are the -Xms and -Xmx parameters when starting JVM
- Java – goto in Java bytecode
- Android – Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6
Best Answer
This is specified in the JVM Specification: Chapter 4.10. Verification of class Files .
The bulk of the page describes the various aspects of type safety. To check that the program is type-safe the verifier needs to figure out what types of operands reside in the operand stack at each program point, and make sure that they match the type expected by the respective instruction.
Other things it verifies include, but is not limited to the following:
As a final step the verifier also performs a data-flow analysis, which makes sure that no instruction reference any uninitialized local variables.