org.apache.bcel.verifier.statics
Class Pass3aVerifier

java.lang.Object
  extended by org.apache.bcel.verifier.PassVerifier
      extended by org.apache.bcel.verifier.statics.Pass3aVerifier

public final class Pass3aVerifier
extends PassVerifier

This PassVerifier verifies a class file according to pass 3, static part as described in The Java Virtual Machine Specification, 2nd edition. More detailed information is to be found at the do_verify() method's documentation.

Version:
$Id: Pass3aVerifier.java 386056 2006-03-15 11:31:56Z tcurdt $
Author:
Enver Haase
See Also:
do_verify()

Nested Class Summary
private  class Pass3aVerifier.InstOperandConstraintVisitor
          This visitor class does the actual checking for the instruction operand's constraints.
 
Field Summary
(package private)  Code code
          The one and only Code object used by an instance of this class.
(package private)  InstructionList instructionList
          The one and only InstructionList object used by an instance of this class.
private  int method_no
          The method number to verify.
private  Verifier myOwner
          The Verifier that created this.
 
Constructor Summary
Pass3aVerifier(Verifier owner, int method_no)
          Should only be instantiated by a Verifier.
 
Method Summary
private static boolean contains(int[] ints, int i)
          A small utility method returning if a given int i is in the given int[] ints.
private  void delayedPass2Checks()
          These are the checks that could be done in pass 2 but are delayed to pass 3 for performance reasons.
 VerificationResult do_verify()
          Pass 3a is the verification of static constraints of JVM code (such as legal targets of branch instructions).
 int getMethodNo()
          Returns the method number as supplied when instantiating.
private  void pass3StaticInstructionChecks()
          These are the checks if constraints are satisfied which are described in the Java Virtual Machine Specification, Second Edition as Static Constraints on the instructions of Java Virtual Machine Code (chapter 4.8.1).
private  void pass3StaticInstructionOperandsChecks()
          These are the checks for the satisfaction of constraints which are described in the Java Virtual Machine Specification, Second Edition as Static Constraints on the operands of instructions of Java Virtual Machine Code (chapter 4.8.1).
 
Methods inherited from class org.apache.bcel.verifier.PassVerifier
addMessage, getMessages, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myOwner

private Verifier myOwner
The Verifier that created this.


method_no

private int method_no
The method number to verify. This is the index in the array returned by JavaClass.getMethods().


instructionList

InstructionList instructionList
The one and only InstructionList object used by an instance of this class. It's here for performance reasons by do_verify() and its callees.


code

Code code
The one and only Code object used by an instance of this class. It's here for performance reasons by do_verify() and its callees.

Constructor Detail

Pass3aVerifier

public Pass3aVerifier(Verifier owner,
                      int method_no)
Should only be instantiated by a Verifier.

Method Detail

do_verify

public VerificationResult do_verify()
Pass 3a is the verification of static constraints of JVM code (such as legal targets of branch instructions). This is the part of pass 3 where you do not need data flow analysis. JustIce also delays the checks for a correct exception table of a Code attribute and correct line number entries in a LineNumberTable attribute of a Code attribute (which conceptually belong to pass 2) to this pass. Also, most of the check for valid local variable entries in a LocalVariableTable attribute of a Code attribute is delayed until this pass. All these checks need access to the code array of the Code attribute.

Specified by:
do_verify in class PassVerifier
Throws:
InvalidMethodException - if the method to verify does not exist.

delayedPass2Checks

private void delayedPass2Checks()
These are the checks that could be done in pass 2 but are delayed to pass 3 for performance reasons. Also, these checks need access to the code array of the Code attribute of a Method so it's okay to perform them here. Also see the description of the do_verify() method.

Throws:
ClassConstraintException - if the verification fails.
See Also:
do_verify()

pass3StaticInstructionChecks

private void pass3StaticInstructionChecks()
These are the checks if constraints are satisfied which are described in the Java Virtual Machine Specification, Second Edition as Static Constraints on the instructions of Java Virtual Machine Code (chapter 4.8.1).

Throws:
StaticCodeConstraintException - if the verification fails.

pass3StaticInstructionOperandsChecks

private void pass3StaticInstructionOperandsChecks()
These are the checks for the satisfaction of constraints which are described in the Java Virtual Machine Specification, Second Edition as Static Constraints on the operands of instructions of Java Virtual Machine Code (chapter 4.8.1). BCEL parses the code array to create an InstructionList and therefore has to check some of these constraints. Additional checks are also implemented here.

Throws:
StaticCodeConstraintException - if the verification fails.

contains

private static boolean contains(int[] ints,
                                int i)
A small utility method returning if a given int i is in the given int[] ints.


getMethodNo

public int getMethodNo()
Returns the method number as supplied when instantiating.