Class SimpleVerifier

All Implemented Interfaces:
Opcodes, Interpreter

public class SimpleVerifier extends BasicVerifier
An extended BasicVerifier that performs more precise verifications. This verifier computes exact class types, instead of using a single "object reference" type (as done in the BasicVerifier).
Author:
Eric Bruneton, Bing Ran
  • Constructor Details

    • SimpleVerifier

      public SimpleVerifier()
      Constructs a new SimpleVerifier.
    • SimpleVerifier

      public SimpleVerifier(Type currentClass, Type currentSuperClass, boolean isInterface)
      Constructs a new SimpleVerifier to verify a specific class. This class will not be loaded into the JVM since it may be incorrect.
      Parameters:
      currentClass - the class that is verified.
      currentSuperClass - the super class of the class that is verified.
      isInterface - if the class that is verified is an interface.
    • SimpleVerifier

      public SimpleVerifier(Type currentClass, Type currentSuperClass, List currentClassInterfaces, boolean isInterface)
      Constructs a new SimpleVerifier to verify a specific class. This class will not be loaded into the JVM since it may be incorrect.
      Parameters:
      currentClass - the class that is verified.
      currentSuperClass - the super class of the class that is verified.
      currentClassInterfaces - the interfaces implemented by the class that is verified.
      isInterface - if the class that is verified is an interface.
  • Method Details

    • setClassLoader

      public void setClassLoader(ClassLoader loader)
      Set the ClassLoader which will be used to load referenced classes. This is useful if you are verifying multiple interdependent classes.
      Parameters:
      loader - a ClassLoader to use
    • newValue

      public Value newValue(Type type)
      Description copied from interface: Interpreter
      Creates a new value that represents the given type. Called for method parameters (including this), exception handler variable and with null type for variables reserved by long and double types.
      Specified by:
      newValue in interface Interpreter
      Overrides:
      newValue in class BasicInterpreter
      Parameters:
      type - a primitive or reference type, or null to represent an uninitialized value.
      Returns:
      a value that represents the given type. The size of the returned value must be equal to the size of the given type.
    • isArrayValue

      protected boolean isArrayValue(Value value)
      Overrides:
      isArrayValue in class BasicVerifier
    • getElementValue

      protected Value getElementValue(Value objectArrayValue) throws AnalyzerException
      Overrides:
      getElementValue in class BasicVerifier
      Throws:
      AnalyzerException
    • isSubTypeOf

      protected boolean isSubTypeOf(Value value, Value expected)
      Overrides:
      isSubTypeOf in class BasicVerifier
    • merge

      public Value merge(Value v, Value w)
      Description copied from interface: Interpreter
      Merges two values. The merge operation must return a value that represents both values (for instance, if the two values are two types, the merged value must be a common super type of the two types. If the two values are integer intervals, the merged value must be an interval that contains the previous ones. Likewise for other types of values).
      Specified by:
      merge in interface Interpreter
      Overrides:
      merge in class BasicInterpreter
      Parameters:
      v - a value.
      w - another value.
      Returns:
      the merged value. If the merged value is equal to v, this method must return v.
    • isInterface

      protected boolean isInterface(Type t)
    • getSuperClass

      protected Type getSuperClass(Type t)
    • isAssignableFrom

      protected boolean isAssignableFrom(Type t, Type u)
    • getClass

      protected Class getClass(Type t)