com.bluemarsh.jswat.breakpoint
Class MethodBreakpoint

java.lang.Object
  |
  +--com.bluemarsh.jswat.breakpoint.DefaultBreakpoint
        |
        +--com.bluemarsh.jswat.breakpoint.ResolvableBreakpoint
              |
              +--com.bluemarsh.jswat.breakpoint.MethodBreakpoint
All Implemented Interfaces:
Breakpoint, java.util.EventListener, LocatableBreakpoint, java.io.Serializable, VMEventListener

public class MethodBreakpoint
extends ResolvableBreakpoint
implements LocatableBreakpoint, VMEventListener

Class MethodBreakpoint implements the Breakpoint interface. Its properties include a class and a method name, and an argument list specifying where the breakpoint should stop.

Author:
Nathan Fiedler
See Also:
Serialized Form

Field Summary
protected static Category logCategory
          Reporting category.
protected  java.util.List methodArgs
          List of method arguments (if any are given), where each element is a String object reprepsenting the argument type in the JNI-style signature.
protected  java.lang.String methodId
          Name of the method this breakpoint is set at.
 
Fields inherited from class com.bluemarsh.jswat.breakpoint.ResolvableBreakpoint
eventRequest, prepareRequest, referenceSpec
 
Fields inherited from class com.bluemarsh.jswat.breakpoint.DefaultBreakpoint
breakpointGroup, conditionList, deleteOnExpire, expireCount, isEnabled, monitorList, propertyList, skipCount, stoppedCount, suspendPolicy
 
Fields inherited from interface com.bluemarsh.jswat.event.VMEventListener
PRIORITY_BREAKPOINT, PRIORITY_DEFAULT, PRIORITY_HIGH, PRIORITY_HIGHEST, PRIORITY_LOW, PRIORITY_LOWEST, PRIORITY_SESSION
 
Fields inherited from interface com.bluemarsh.jswat.breakpoint.Breakpoint
serialVersionUID
 
Method Summary
 boolean eventOccurred(com.sun.jdi.event.Event e)
          Invoked when a VM event has occurred.
protected  com.sun.jdi.Method findMatchingMethod(com.sun.jdi.ClassType classType)
          Attempt an unambiguous match of the method name and argument specification to a method.
 java.lang.String getClassName()
          Return the name of the class that this breakpoint is located in.
 int getLineNumber()
          Retrieve the line number associated with this breakpoint.
 com.sun.jdi.Location getLocation()
          Retrieve the location associated with this breakpoint.
protected  com.sun.jdi.ReferenceType getReferenceFromName(java.lang.String cname, com.sun.jdi.VirtualMachine vm)
          Find the ReferenceType object for a given class.
 BreakpointUI getUIAdapter()
          Returns the user interface widget for customizing this breakpoint.
 void init()
          Initialize the breakpoint so it may operate normally.
protected  boolean isJavaIdentifier(java.lang.String s)
          Determine if the given string is a valid Java identifier.
protected  java.lang.String normalizeArgTypeName(java.lang.String name, com.sun.jdi.VirtualMachine vm)
          Remove unneeded spaces and expand class names to fully qualified names, if necessary and possible.
protected  com.sun.jdi.request.EventRequest resolveReference(com.sun.jdi.ReferenceType refType)
          Resolve against the given ReferenceType.
 java.lang.String toString()
          Returns a String representation of this.
 java.lang.String toString(boolean terse)
          Returns a String representation of this.
 
Methods inherited from class com.bluemarsh.jswat.breakpoint.ResolvableBreakpoint
destroy, eventRequest, getReferenceTypeSpec, isResolved, reset, resolveAgainstEvent, resolveEagerly, setEnabled, setSuspendPolicy, unresolve
 
Methods inherited from class com.bluemarsh.jswat.breakpoint.DefaultBreakpoint
addCondition, addMonitor, conditions, deleteOnExpire, fireChange, getBreakpointGroup, getBreakpointManager, getExpireCount, getProperty, getSkipCount, getSuspendPolicy, hasExpired, incrementStoppedCount, isEnabled, isSkipping, monitors, performStop, removeCondition, removeMonitor, setBreakpointGroup, setExpireCount, setProperty, setSkipCount, shouldResume
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logCategory

protected static Category logCategory
Reporting category.

methodId

protected java.lang.String methodId
Name of the method this breakpoint is set at.

methodArgs

protected java.util.List methodArgs
List of method arguments (if any are given), where each element is a String object reprepsenting the argument type in the JNI-style signature.
Method Detail

eventOccurred

public boolean eventOccurred(com.sun.jdi.event.Event e)
Invoked when a VM event has occurred.
Specified by:
eventOccurred in interface VMEventListener
Parameters:
e - VM event.
Returns:
true if debuggee VM should be resumed, false otherwise.

findMatchingMethod

protected com.sun.jdi.Method findMatchingMethod(com.sun.jdi.ClassType classType)
                                         throws AmbiguousClassSpecException,
                                                AmbiguousMethodException,
                                                java.lang.NoSuchMethodException
Attempt an unambiguous match of the method name and argument specification to a method. If no arguments are specified, the method must not be overloaded. Otherwise, the argument types must match exactly.
Parameters:
classType - Class to find matching method.
Returns:
Method if found, null otherwise.
Throws:
AmbiguousClassSpecException - Thrown if the given pattern matches more than one class.
AmbiguousMethodException - Thrown if the method is overloaded.
java.lang.NoSuchMethodException - Thrown if the method could not be found.

getClassName

public java.lang.String getClassName()
Return the name of the class that this breakpoint is located in. This could be a fully-qualified class name or a wild-carded name pattern containing a single asterisk (e.g. "*.cname").
Specified by:
getClassName in interface LocatableBreakpoint
Returns:
Class name if known, null if not.

getLineNumber

public int getLineNumber()
Retrieve the line number associated with this breakpoint. Not all breakpoints will have a particular line associated with them (such as method breakpoints). In such cases, this method will return -1.
Specified by:
getLineNumber in interface LocatableBreakpoint
Returns:
line number of breakpoint, if applicable; -1 if not.

getLocation

public com.sun.jdi.Location getLocation()
Retrieve the location associated with this breakpoint. The caller may want to call isResolved() before calling this method. An unresolved breakpoint will not have a location yet.
Specified by:
getLocation in interface LocatableBreakpoint
Returns:
location of breakpoint, or null if not resolved.

getReferenceFromName

protected com.sun.jdi.ReferenceType getReferenceFromName(java.lang.String cname,
                                                         com.sun.jdi.VirtualMachine vm)
                                                  throws AmbiguousClassSpecException
Find the ReferenceType object for a given class.
Parameters:
cname - Class identifier for which to get reference.
vm - Virtual machine from which to get reference.
Returns:
ReferenceType for this class, or null if none.
Throws:
AmbiguousClassSpecException - Thrown if the given pattern matches more than one class.

getUIAdapter

public BreakpointUI getUIAdapter()
Returns the user interface widget for customizing this breakpoint.
Overrides:
getUIAdapter in class DefaultBreakpoint
Returns:
Breakpoint user interface adapter.

init

public void init()
Initialize the breakpoint so it may operate normally.
Overrides:
init in class DefaultBreakpoint

isJavaIdentifier

protected boolean isJavaIdentifier(java.lang.String s)
Determine if the given string is a valid Java identifier.
Parameters:
s - String to validate.
Returns:
True if string is a valid Java identifier.

normalizeArgTypeName

protected java.lang.String normalizeArgTypeName(java.lang.String name,
                                                com.sun.jdi.VirtualMachine vm)
                                         throws AmbiguousClassSpecException
Remove unneeded spaces and expand class names to fully qualified names, if necessary and possible.
Parameters:
name - Name of class.
vm - Virtual machine to normalize against.
Returns:
Fully qualified name of class.
Throws:
AmbiguousClassSpecException - Thrown if the given pattern matches more than one class.

resolveReference

protected com.sun.jdi.request.EventRequest resolveReference(com.sun.jdi.ReferenceType refType)
                                                     throws ResolveException
Resolve against the given ReferenceType. If successful, return the new event request.
Overrides:
resolveReference in class ResolvableBreakpoint
Parameters:
refType - ReferenceType against which to resolve.
Returns:
event request, or null if not resolved.
Throws:
ResolveException - Thrown if breakpoint resolve fails.

toString

public java.lang.String toString(boolean terse)
Returns a String representation of this.
Parameters:
terse - true to keep the description terse.

toString

public java.lang.String toString()
Returns a String representation of this.
Overrides:
toString in class java.lang.Object