Class ByteCatchList

All Implemented Interfaces:
ToHuman

public final class ByteCatchList extends FixedSizeList
List of catch entries, that is, the elements of an "exception table," which is part of a standard Code attribute.
  • Field Details

    • EMPTY

      public static final ByteCatchList EMPTY
      non-null; convenient zero-entry instance
  • Constructor Details

    • ByteCatchList

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

    • byteLength

      public int byteLength()
      Gets the total length of this structure in bytes, when included in a Code attribute. The returned value includes the two bytes for exception_table_length.
      Returns:
      >= 2; the total length, in bytes
    • get

      public ByteCatchList.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, ByteCatchList.Item item)
      Sets the item at the given index.
      Parameters:
      n - >= 0, < size(); which entry to set
      item - non-null; the item
    • set

      public void set(int n, int startPc, int endPc, int handlerPc, CstType exceptionClass)
      Sets the item at the given index.
      Parameters:
      n - >= 0, < size(); which entry to set
      startPc - >= 0; the start pc (inclusive) of the handler's range
      endPc - >= startPc; the end pc (exclusive) of the handler's range
      handlerPc - >= 0; the pc of the exception handler
      exceptionClass - null-ok; the exception class or null to catch all exceptions with this handler
    • listFor

      public ByteCatchList listFor(int pc)
      Gets the list of items active at the given address. The result is automatically made immutable.
      Parameters:
      pc - which address
      Returns:
      non-null; list of exception handlers active at pc
    • toTargetList

      public IntList toTargetList(int noException)
      Returns a target list corresponding to this instance. The result is a list of all the exception handler addresses, with the given noException address appended if appropriate. The result is automatically made immutable.
      Parameters:
      noException - >= -1; the no-exception address to append, or -1 not to append anything
      Returns:
      non-null; list of exception targets, with noException appended if necessary
    • toRopCatchList

      public TypeList toRopCatchList()
      Returns a rop-style catches list equivalent to this one.
      Returns:
      non-null; the converted instance