Class Breakpoint


  • public final class Breakpoint
    extends Object
    Breakpoint location keyed by class, method, and pc, with mutable enablement, condition, and hit tracking.
    • Constructor Detail

      • Breakpoint

        public Breakpoint​(String className,
                          String methodName,
                          String methodDesc,
                          int pc)
        Creates an enabled breakpoint at the given location with no line number.
        Parameters:
        className - the class internal name
        methodName - the method name
        methodDesc - the method descriptor
        pc - the bytecode offset, or -1 for method entry
        Throws:
        IllegalArgumentException - if className, methodName, or methodDesc is null or empty
      • Breakpoint

        public Breakpoint​(String className,
                          String methodName,
                          String methodDesc,
                          int pc,
                          int lineNumber)
        Creates an enabled breakpoint at the given location.
        Parameters:
        className - the class internal name
        methodName - the method name
        methodDesc - the method descriptor
        pc - the bytecode offset, or -1 for method entry
        lineNumber - the source line, or -1 if unknown
        Throws:
        IllegalArgumentException - if className, methodName, or methodDesc is null or empty
    • Method Detail

      • methodEntry

        public static Breakpoint methodEntry​(String className,
                                             String methodName,
                                             String methodDesc)
        Creates a breakpoint that triggers on method entry.
        Parameters:
        className - the class internal name
        methodName - the method name
        methodDesc - the method descriptor
        Returns:
        the breakpoint
      • atLine

        public static Breakpoint atLine​(String className,
                                        String methodName,
                                        String methodDesc,
                                        int line)
        Creates a breakpoint carrying a source line number; matching still uses pc -1, i.e. method entry.
        Parameters:
        className - the class internal name
        methodName - the method name
        methodDesc - the method descriptor
        line - the source line number
        Returns:
        the breakpoint
        Throws:
        IllegalArgumentException - if line is negative
      • atPC

        public static Breakpoint atPC​(String className,
                                      String methodName,
                                      String methodDesc,
                                      int pc)
        Creates a breakpoint at a specific bytecode offset.
        Parameters:
        className - the class internal name
        methodName - the method name
        methodDesc - the method descriptor
        pc - the bytecode offset, or -1 for method entry
        Returns:
        the breakpoint
        Throws:
        IllegalArgumentException - if pc is less than -1
      • getClassName

        public String getClassName()
        Returns:
        the class name
      • getMethodName

        public String getMethodName()
        Returns:
        the method name
      • getMethodDesc

        public String getMethodDesc()
        Returns:
        the method desc
      • getPC

        public int getPC()
        Returns:
        the target bytecode offset, or -1 for method entry
      • getLineNumber

        public int getLineNumber()
        Returns:
        the line number
      • isEnabled

        public boolean isEnabled()
        Returns:
        whether enabled
      • setEnabled

        public void setEnabled​(boolean enabled)
        Enables or disables this breakpoint.
        Parameters:
        enabled - true to enable
      • getCondition

        public String getCondition()
        Returns:
        the condition
      • setCondition

        public void setCondition​(String condition)
        Sets an optional condition expression attached to this breakpoint.
        Parameters:
        condition - the condition, or null to clear
      • getHitCount

        public int getHitCount()
        Returns:
        the hit count
      • incrementHitCount

        public void incrementHitCount()
        Records one more hit of this breakpoint.
      • resetHitCount

        public void resetHitCount()
        Resets the hit counter to zero.
      • matches

        public boolean matches​(StackFrame frame)
        Tests whether this breakpoint matches the frame's current location.
        Parameters:
        frame - the frame to test, may be null
        Returns:
        true if the frame location matches
      • matches

        public boolean matches​(String className,
                               String methodName,
                               String methodDesc,
                               int pc)
        Tests whether this breakpoint matches the given location, treating a -1 pc as method entry (pc 0).
        Parameters:
        className - the class internal name
        methodName - the method name
        methodDesc - the method descriptor
        pc - the current program counter
        Returns:
        true if the location matches
      • getKey

        public String getKey()
        Returns:
        a unique map key combining class, method, descriptor, and pc
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object