tags:

views:

139

answers:

2

How does JVM classfile verifier perform class verification ?

Could anyone please tell me the steps ?

+3  A: 

See section 4.9 of the VM Spec. The process is spelled out in detail.

Eddie
+6  A: 

There are four passes:

  1. Basic Format Check (When Class is Loaded) - (magic number, check constant pool).

  2. Additional Verification (When Linking) - Check final modifiers, check for direct subclasses, valid fields, check constant pool.

  3. Bytecode Verification (When Linking) - Check the code array - operand stack is ok, local variables, correct method invocation, field assignment etc...

  4. Virtual Pass (Code Invoked) - ensure referenced classes/methods exist and have the correct descriptors.

Full gory details here, see section 4.9.1 The Verification Process

http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html

Jon