Class LocalVariableList

All Implemented Interfaces:
ToHuman

public final class LocalVariableList extends FixedSizeList
List of "local variable" entries, which are the contents of LocalVariableTable and LocalVariableTypeTable attributes, as well as combinations of the two.
  • Field Details

  • Constructor Details

    • LocalVariableList

      public LocalVariableList(int count)
      Constructs an instance.
      Parameters:
      count - the number of elements to be in the list
  • Method Details

    • concat

      public static LocalVariableList concat(LocalVariableList list1, LocalVariableList list2)
      Returns an instance which is the concatenation of the two given instances. The result is immutable.
      Parameters:
      list1 - non-null; first instance
      list2 - non-null; second instance
      Returns:
      non-null; combined instance
    • mergeDescriptorsAndSignatures

      public static LocalVariableList mergeDescriptorsAndSignatures(LocalVariableList descriptorList, LocalVariableList signatureList)
      Returns an instance which is the result of merging the two given instances, where one instance should have only type descriptors and the other only type signatures. The merged result is identical to the one with descriptors, except that any element whose {name, index, start, length} matches an element in the signature list gets augmented with the corresponding signature. The result is immutable.
      Parameters:
      descriptorList - non-null; list with descriptors
      signatureList - non-null; list with signatures
      Returns:
      non-null; the merged result
    • get

      public LocalVariableList.Item get(int n)
      Gets the indicated item.
      Parameters:
      n - >= 0; which item
      Returns:
      null-ok; the indicated item
    • set

      public void set(int n, LocalVariableList.Item item)
      Sets the item at the given index.
      Parameters:
      n - >= 0, < size(); which element
      item - non-null; the item
    • set

      public void set(int n, int startPc, int length, CstString name, CstString descriptor, CstString signature, int index)
      Sets the item at the given index.

      Note: At least one of descriptor or signature must be passed as non-null.

      Parameters:
      n - >= 0, < size(); which element
      startPc - >= 0; the start pc of this variable's scope
      length - >= 0; the length (in bytecodes) of this variable's scope
      name - non-null; the variable's name
      descriptor - null-ok; the variable's type descriptor
      signature - null-ok; the variable's type signature
      index - >= 0; the variable's local index
    • itemToLocal

      Gets the local variable information in this instance which matches the given LocalVariableList.Item in all respects but the type descriptor and signature, if any.
      Parameters:
      item - non-null; local variable information to match
      Returns:
      null-ok; the corresponding local variable information stored in this instance, or null if there is no matching information
    • pcAndIndexToLocal

      public LocalVariableList.Item pcAndIndexToLocal(int pc, int index)
      Gets the local variable information associated with a given address and local index, if any. Note: In standard classfiles, a variable's start point is listed as the address of the instruction just past the one that sets the variable.
      Parameters:
      pc - >= 0; the address to look up
      index - >= 0; the local variable index
      Returns:
      null-ok; the associated local variable information, or null if none is known