Class LocalVariableInfo

java.lang.Object
org.apache.bcel.verifier.statics.LocalVariableInfo

public class LocalVariableInfo extends Object
A utility class holding the information about the name and the type of a local variable in a given slot (== index). This information often changes in course of byte code offsets.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Hashtable<String,String>
    The names database.
    private final Hashtable<String,Type>
    The types database.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    add(int offset, String name, Type t)
    Adds information about name and type for a given offset.
    void
    add(String name, int startPc, int length, Type type)
    Adds some information about this local variable (slot).
    getName(int offset)
    Returns the name of the local variable that uses this local variable slot at the given bytecode offset.
    getType(int offset)
    Returns the type of the local variable that uses this local variable slot at the given bytecode offset.
    private void
    setName(int offset, String name)
    Adds a name of a local variable and a certain slot to our 'names' (Hashtable) database.
    private void
    setType(int offset, Type t)
    Adds a type of a local variable and a certain slot to our 'types' (Hashtable) database.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • types

      private final Hashtable<String,Type> types
      The types database. KEY: String representing the offset integer.
    • names

      private final Hashtable<String,String> names
      The names database. KEY: String representing the offset integer.
  • Constructor Details

    • LocalVariableInfo

      public LocalVariableInfo()
  • Method Details

    • add

      private void add(int offset, String name, Type t) throws LocalVariableInfoInconsistentException
      Adds information about name and type for a given offset.
      Throws:
      LocalVariableInfoInconsistentException - if the new information conflicts with already gathered information.
    • add

      public void add(String name, int startPc, int length, Type type) throws LocalVariableInfoInconsistentException
      Adds some information about this local variable (slot).
      Parameters:
      name - variable name
      startPc - Range in which the variable is valid.
      length - length of ...
      type - variable type
      Throws:
      LocalVariableInfoInconsistentException - if the new information conflicts with already gathered information.
    • getName

      public String getName(int offset)
      Returns the name of the local variable that uses this local variable slot at the given bytecode offset. Care for legal bytecode offsets yourself, otherwise the return value might be wrong. May return 'null' if nothing is known about the type of this local variable slot at the given bytecode offset.
      Parameters:
      offset - bytecode offset.
      Returns:
      the name of the local variable that uses this local variable slot at the given bytecode offset.
    • getType

      public Type getType(int offset)
      Returns the type of the local variable that uses this local variable slot at the given bytecode offset. Care for legal bytecode offsets yourself, otherwise the return value might be wrong. May return 'null' if nothing is known about the type of this local variable slot at the given bytecode offset.
      Parameters:
      offset - bytecode offset.
      Returns:
      the type of the local variable that uses this local variable slot at the given bytecode offset.
    • setName

      private void setName(int offset, String name)
      Adds a name of a local variable and a certain slot to our 'names' (Hashtable) database.
    • setType

      private void setType(int offset, Type t)
      Adds a type of a local variable and a certain slot to our 'types' (Hashtable) database.