Interface ExceptionHandler

All Superinterfaces:
Comparable<ExceptionHandler>
All Known Implementing Classes:
BaseExceptionHandler, BuilderExceptionHandler, BuilderExceptionHandler, DexBackedCatchAllExceptionHandler, DexBackedExceptionHandler, DexBackedTypedExceptionHandler, ExceptionHandlerRewriter.RewrittenExceptionHandler, ImmutableExceptionHandler

public interface ExceptionHandler extends Comparable<ExceptionHandler>
This class represents an individual exception handler entry, in a try block.
  • Method Details

    • getExceptionType

      @Nullable String getExceptionType()
      Gets the type of exception that is handled by this handler.
      Returns:
      The type of exception that is handled by this handler, or null if this is a catch-all handler.
    • getExceptionTypeReference

      @Nullable TypeReference getExceptionTypeReference()
      Gets the type of exception that is handled by this handler.
      Returns:
      A TypeReference to the type of exception that is handled by this handler, or null if this is a catch-all handler.
    • getHandlerCodeAddress

      int getHandlerCodeAddress()
      Gets the code offset of the handler.
      Returns:
      The offset of the handler from the the beginning of the bytecode for the method. The offset will be in terms of 16-bit code units
    • hashCode

      int hashCode()
      Returns a hashcode for this ExceptionHandler. This hashCode is defined to be the following:
       
       String exceptionType = getExceptionType();
       int hashCode = exceptionType==null?0:exceptionType.hashCode();
       return hashCode*31 + getHandlerCodeAddress();
       
      Overrides:
      hashCode in class Object
      Returns:
      The hash code value for this ExceptionHandler
    • equals

      boolean equals(@Nullable Object o)
      Compares this ExceptionHandler to another ExceptionHandler for equality. This ExceptionHandler is equal to another ExceptionHandler if all of it's "fields" are equal. That is, if the return values of getExceptionType() and getHandlerCodeAddress() are both equal.
      Overrides:
      equals in class Object
      Parameters:
      o - The object to be compared for equality with this ExceptionHandler
      Returns:
      true if the specified object is equal to this ExceptionHandler
    • compareTo

      int compareTo(@Nonnull ExceptionHandler o)
      Compare this ExceptionHandler to another ExceptionHandler. The comparison is based on the comparison of the return values of getExceptionType() and getHandlerCodeAddress() in that order. A null value for getExceptionType() compares after a non-null value.
      Specified by:
      compareTo in interface Comparable<ExceptionHandler>
      Parameters:
      o - The ExceptionHandler to compare with this ExceptionHandler
      Returns:
      An integer representing the result of the comparison