Class 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:
    do_verify()
    • Field Detail

      • 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.
      • myOwner

        private final Verifier myOwner
        The Verifier that created this.
    • Constructor Detail

      • Pass2Verifier

        public Pass2Verifier​(Verifier owner)
        Should only be instantiated by a Verifier.
        See Also:
        Verifier
    • Method Detail

      • 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.
      • 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
        See Also:
        Pass3aVerifier
      • every_class_has_an_accessible_superclass

        private void every_class_has_an_accessible_superclass()
        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 java.lang.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.
      • constant_pool_entries_satisfy_static_constraints

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

        private void field_and_method_refs_are_valid()
        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:
        constant_pool_entries_satisfy_static_constraints()
      • validClassName

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

        private static boolean validMethodName​(java.lang.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.
      • validClassMethodName

        private static boolean validClassMethodName​(java.lang.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.
      • validJavaLangMethodName

        private static boolean validJavaLangMethodName​(java.lang.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.
      • validInterfaceMethodName

        private static boolean validInterfaceMethodName​(java.lang.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​(java.lang.String name)
        This method returns true if and only if the supplied String represents a valid Java identifier (so-called simple name).
      • validFieldName

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

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