Class BreakpointManager


  • public final class BreakpointManager
    extends Object
    Thread-safe registry of breakpoints indexed by key and by owning method for fast location checks.
    • Constructor Detail

      • BreakpointManager

        public BreakpointManager()
        Creates an empty manager backed by concurrent maps.
    • Method Detail

      • addBreakpoint

        public void addBreakpoint​(Breakpoint bp)
        Registers a breakpoint, indexing it by key and by owning method.
        Parameters:
        bp - the breakpoint to add
        Throws:
        IllegalArgumentException - if bp is null
      • removeBreakpoint

        public boolean removeBreakpoint​(Breakpoint bp)
        Removes the given breakpoint.
        Parameters:
        bp - the breakpoint to remove
        Returns:
        true if it was registered and removed
      • removeBreakpoint

        public boolean removeBreakpoint​(String key)
        Removes the breakpoint with the given key, cleaning up the per-method index.
        Parameters:
        key - the breakpoint key
        Returns:
        true if a breakpoint was removed
      • removeAllBreakpoints

        public void removeAllBreakpoints()
        Removes every registered breakpoint.
      • enableBreakpoint

        public void enableBreakpoint​(String key)
        Enables the breakpoint with the given key, if present.
        Parameters:
        key - the breakpoint key
      • disableBreakpoint

        public void disableBreakpoint​(String key)
        Disables the breakpoint with the given key, if present.
        Parameters:
        key - the breakpoint key
      • enableAll

        public void enableAll()
        Enables every registered breakpoint.
      • disableAll

        public void disableAll()
        Disables every registered breakpoint.
      • getBreakpoint

        public Breakpoint getBreakpoint​(String key)
        Looks up a breakpoint by key.
        Parameters:
        key - the breakpoint key
        Returns:
        the breakpoint, or null if absent
      • getAllBreakpoints

        public List<Breakpoint> getAllBreakpoints()
        Returns:
        a copy of all registered breakpoints
      • getBreakpointsForMethod

        public List<Breakpoint> getBreakpointsForMethod​(String className,
                                                        String methodName,
                                                        String methodDesc)
        Lists the breakpoints registered for one method.
        Parameters:
        className - the class internal name
        methodName - the method name
        methodDesc - the method descriptor
        Returns:
        a copy of the method's breakpoints, empty if none
      • hasBreakpoints

        public boolean hasBreakpoints()
        Returns:
        true if any breakpoints are registered
      • getBreakpointCount

        public int getBreakpointCount()
        Returns:
        the number of registered breakpoints
      • checkBreakpoint

        public Breakpoint checkBreakpoint​(StackFrame frame)
        Finds an enabled breakpoint matching the frame's current location.
        Parameters:
        frame - the frame to test, may be null
        Returns:
        the matching breakpoint, or null
      • checkBreakpoint

        public Breakpoint checkBreakpoint​(String className,
                                          String methodName,
                                          String methodDesc,
                                          int pc)
        Finds an enabled breakpoint matching the given location.
        Parameters:
        className - the class internal name
        methodName - the method name
        methodDesc - the method descriptor
        pc - the current program counter
        Returns:
        the matching breakpoint, or null
      • methodKey

        public static String methodKey​(String className,
                                       String methodName,
                                       String methodDesc)
        Builds the per-method index key.
        Parameters:
        className - the class internal name
        methodName - the method name
        methodDesc - the method descriptor
        Returns:
        the combined method key
        Throws:
        IllegalArgumentException - if any component is null