Class ExceptionHandlerMap


  • public class ExceptionHandlerMap
    extends java.lang.Object
    This class provides a convenient way of determining the exception handlers for instructions in a method. Essentially, it's a a map of InstructionHandles to lists of CodeExceptionGen objects. This class also maps instructions which are the start of exception handlers to the CodeExceptionGen object representing the handler.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.IdentityHashMap<org.apache.bcel.generic.InstructionHandle,​java.util.List<org.apache.bcel.generic.CodeExceptionGen>> codeToHandlerMap  
      private TypeMerger merger  
      private java.util.IdentityHashMap<org.apache.bcel.generic.InstructionHandle,​org.apache.bcel.generic.CodeExceptionGen> startInstructionToHandlerMap  
    • Constructor Summary

      Constructors 
      Constructor Description
      ExceptionHandlerMap​(org.apache.bcel.generic.MethodGen methodGen, TypeMerger merger)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void addExceptionHandler​(org.apache.bcel.generic.CodeExceptionGen exceptionHandler)  
      private void addHandler​(org.apache.bcel.generic.InstructionHandle handle, org.apache.bcel.generic.CodeExceptionGen exceptionHandler)  
      private void build​(org.apache.bcel.generic.MethodGen methodGen)  
      org.apache.bcel.generic.CodeExceptionGen getHandlerForStartInstruction​(org.apache.bcel.generic.InstructionHandle start)
      If the given instruction is the start of an exception handler, get the CodeExceptionGen object representing the handler.
      java.util.List<org.apache.bcel.generic.CodeExceptionGen> getHandlerList​(org.apache.bcel.generic.InstructionHandle handle)
      Get the list of exception handlers (CodeExceptionGen objects) which are specified to handle exceptions for the instruction whose handle is given.
      static org.apache.bcel.generic.CodeExceptionGen merge​(TypeMerger m, org.apache.bcel.generic.CodeExceptionGen e1, org.apache.bcel.generic.CodeExceptionGen e2)  
      • Methods inherited from class java.lang.Object

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

      • codeToHandlerMap

        private final java.util.IdentityHashMap<org.apache.bcel.generic.InstructionHandle,​java.util.List<org.apache.bcel.generic.CodeExceptionGen>> codeToHandlerMap
      • startInstructionToHandlerMap

        private final java.util.IdentityHashMap<org.apache.bcel.generic.InstructionHandle,​org.apache.bcel.generic.CodeExceptionGen> startInstructionToHandlerMap
    • Constructor Detail

      • ExceptionHandlerMap

        public ExceptionHandlerMap​(org.apache.bcel.generic.MethodGen methodGen,
                                   TypeMerger merger)
        Constructor.
        Parameters:
        methodGen - the method to build the map for
    • Method Detail

      • getHandlerList

        public java.util.List<org.apache.bcel.generic.CodeExceptionGen> getHandlerList​(org.apache.bcel.generic.InstructionHandle handle)
        Get the list of exception handlers (CodeExceptionGen objects) which are specified to handle exceptions for the instruction whose handle is given. Note that the handlers in the returned list are in order of priority, as defined in the method's exception handler table.
        Parameters:
        handle - the handle of the instruction we want the exception handlers for
        Returns:
        the list of exception handlers, or null if there are no handlers registered for the instruction
      • getHandlerForStartInstruction

        public org.apache.bcel.generic.CodeExceptionGen getHandlerForStartInstruction​(org.apache.bcel.generic.InstructionHandle start)
        If the given instruction is the start of an exception handler, get the CodeExceptionGen object representing the handler.
        Parameters:
        start - the instruction
        Returns:
        the CodeExceptionGen object, or null if the instruction is not the start of an exception handler
      • build

        private void build​(org.apache.bcel.generic.MethodGen methodGen)
      • merge

        public static org.apache.bcel.generic.CodeExceptionGen merge​(@CheckForNull
                                                                     TypeMerger m,
                                                                     org.apache.bcel.generic.CodeExceptionGen e1,
                                                                     org.apache.bcel.generic.CodeExceptionGen e2)
      • addExceptionHandler

        private void addExceptionHandler​(org.apache.bcel.generic.CodeExceptionGen exceptionHandler)
      • addHandler

        private void addHandler​(org.apache.bcel.generic.InstructionHandle handle,
                                org.apache.bcel.generic.CodeExceptionGen exceptionHandler)