Class Pass2Verifier

java.lang.Object
org.apache.bcel.verifier.PassVerifier
org.apache.bcel.verifier.statics.Pass2Verifier
All Implemented Interfaces:
Constants

public final class Pass2Verifier extends PassVerifier implements Constants
This PassVerifier verifies a class file according to pass 2 as described in The Java Virtual Machine Specification, 2nd edition. More detailed information is to be found at the do_verify() method's documentation.
See Also:
  • Field Details

    • localVariablesInfos

      private LocalVariablesInfo[] localVariablesInfos
      The LocalVariableInfo instances used by Pass3bVerifier. localVariablesInfos[i] denotes the information for the local variables of method number i in the JavaClass this verifier operates on.
    • verifier

      private final Verifier verifier
      The Verifier that created this.
  • Constructor Details

    • Pass2Verifier

      public Pass2Verifier(Verifier verifier)
      Should only be instantiated by a Verifier.
      See Also:
  • Method Details

    • tostring

      private static String tostring(Node n)
      This method is here to save typing work and improve code readability.
    • validClassMethodName

      private static boolean validClassMethodName(String name)
      This method returns true if and only if the supplied String represents a valid method name that may be referenced by ConstantMethodref objects.
    • validClassName

      private static boolean validClassName(String name)
      This method returns true if and only if the supplied String represents a valid Java class name.
    • validFieldName

      private static boolean validFieldName(String name)
      This method returns true if and only if the supplied String represents a valid Java field name.
    • validInterfaceMethodName

      private static boolean validInterfaceMethodName(String name)
      This method returns true if and only if the supplied String represents a valid Java interface method name that may be referenced by ConstantInterfaceMethodref objects.
    • validJavaIdentifier

      private static boolean validJavaIdentifier(String name)
      This method returns true if and only if the supplied String represents a valid Java identifier (so-called simple or unqualified name).
    • validJavaLangMethodName

      private static boolean validJavaLangMethodName(String name)
      This method returns true if and only if the supplied String represents a valid Java programming language method name stored as a simple (non-qualified) name. Conforming to: The Java Virtual Machine Specification, Second Edition, �2.7, �2.7.1, �2.2.
    • validMethodName

      private static boolean validMethodName(String name, boolean allowStaticInit)
      This method returns true if and only if the supplied String represents a valid method name. This is basically the same as a valid identifier name in the Java programming language, but the special name for the instance initialization method is allowed and the special name for the class/interface initialization method may be allowed.
    • constantPoolEntriesSatisfyStaticConstraints

      private void constantPoolEntriesSatisfyStaticConstraints()
      Ensures that the constant pool entries satisfy the static constraints as described in The Java Virtual Machine Specification, 2nd Edition.
      Throws:
      ClassConstraintException - otherwise.
    • do_verify

      public VerificationResult do_verify()
      Pass 2 is the pass where static properties of the class file are checked without looking into "Code" arrays of methods. This verification pass is usually invoked when a class is resolved; and it may be possible that this verification pass has to load in other classes such as superclasses or implemented interfaces. Therefore, Pass 1 is run on them.
      Note that most referenced classes are not loaded in for verification or for an existance check by this pass; only the syntactical correctness of their names and descriptors (a.k.a. signatures) is checked.
      Very few checks that conceptually belong here are delayed until pass 3a in JustIce. JustIce does not only check for syntactical correctness but also for semantical sanity - therefore it needs access to the "Code" array of methods in a few cases. Please see the pass 3a documentation, too.
      Specified by:
      do_verify in class PassVerifier
      Returns:
      The VerificationResult
      See Also:
    • everyClassHasAnAccessibleSuperclass

      private void everyClassHasAnAccessibleSuperclass()
      Ensures that every class has a super class and that final classes are not subclassed. This means, the class this Pass2Verifier operates on has proper super classes (transitively) up to Object. The reason for really loading (and Pass1-verifying) all of those classes here is that we need them in Pass2 anyway to verify no final methods are overridden (that could be declared anywhere in the ancestor hierarchy).
      Throws:
      ClassConstraintException - otherwise.
    • fieldAndMethodRefsAreValid

      private void fieldAndMethodRefsAreValid()
      Ensures that the ConstantCP-subclassed entries of the constant pool are valid. According to "Yellin: Low Level Security in Java", this method does not verify the existence of referenced entities (such as classes) but only the formal correctness (such as well-formed signatures). The visitXXX() methods throw ClassConstraintException instances otherwise. Precondition: index-style cross referencing in the constant pool must be valid. Simply invoke constant_pool_entries_satisfy_static_constraints() before.
      Throws:
      ClassConstraintException - otherwise.
      See Also:
    • finalMethodsAreNotOverridden

      private void finalMethodsAreNotOverridden()
      Ensures that final methods are not overridden. Precondition to run this method: constant_pool_entries_satisfy_static_constraints() and every_class_has_an_accessible_superclass() have to be invoked before (in that order).
      Throws:
      ClassConstraintException - otherwise.
      See Also:
    • getLocalVariablesInfo

      public LocalVariablesInfo getLocalVariablesInfo(int methodNr)
      Returns a LocalVariablesInfo object containing information about the usage of the local variables in the Code attribute of the said method or null if the class file this Pass2Verifier operates on could not be pass-2-verified correctly. The method number method_nr is the method you get using Repository.lookupClass(myOwner.getClassname()).getMethods()[method_nr];. You should not add own information. Leave that to JustIce.