9.2. Bytecode Verification by Gary Cornell, Cay S. Horstmann

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

9.2. Bytecode Verification

When a class loader presents the bytecodes of a newly loaded Java platform class to the virtual machine, these bytecodes are first inspected by a verifier. The verifier checks that the instructions cannot perform actions that are obviously damaging. All classes except for system classes are verified.

Here are some of the checks that the verifier carries out:

• Variables are initialized before they are used.

• Method calls match the types of object references.

• Rules for accessing private data and methods are not violated.

• Local variable accesses fall within the runtime stack.

• The runtime stack does not overflow.

If any of these checks fails, the class is considered corrupted and will not be loaded.

Note

If you ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required