Overview | Package | Class | Use | Tree | Index | Help
| Java Debug Interface
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.jdi
Interface Method

All Superinterfaces:
  Accessible, Comparable, Locatable, Mirror, TypeComponent

public interface Method
extends TypeComponent, Locatable, Comparable

A static or instance method in the target VM. See `TypeComponent` for general information about Field and Method mirrors.

Since:
  1.3
See Also:
  `ObjectReference`, `ReferenceType`

Method Summary
`List` | `allLineLocations()` Returns the beginning `Location` objects for each executable source line in this method.
`List` | `arguments()` Returns a list containing each `LocalVariable` that is declared as an argument of this method.
`List` | `argumentTypeNames()` Returns a text representation of all declared argument types of this method.
`List` | `argumentTypes()` Returns the list containing the type of each argument.
`byte[]` | `bytecodes()` Returns an array containing the bytecodes for this method.
`boolean` | `equals(Object obj)` Compares the specified Object with this method for equality.
`int` | `hashCode()` Returns the hash code value for this Method.
`boolean` | `isAbstract()` Determine if this method is abstract.
`boolean` | `isConstructor()` Determine if this method is a constructor.
`boolean` | `isNative()` Determine if this method is native.
`boolean` | `isStaticInitializer()` Determine if this method is a static initializer.
`boolean` | `isSynchronized()` Determine if this method is synchronized.
`Location` | `locationOfCodeIndex(long codeIndex)` Returns a `Location` for the given code index.
`List` | `locationsOfLine(int lineNumber)` Returns a list containing each `Location` that maps to the given line.
`Type` | `returnType()` Returns the return type of the this `Method`.
`String` | `returnTypeName()` Returns a text representation of the declared return type of this method.
`List` | `variables()` Returns a list containing each `LocalVariable` declared in this method.
`List` | `variablesByName(String name)` Returns a list containing each `LocalVariable` of a given name in this method.

Methods inherited from interface com.sun.jdi.TypeComponent
`declaringType, isFinal, isStatic, isSynthetic, name, signature`

Methods inherited from interface com.sun.jdi.Mirror
`toString, virtualMachine`

Methods inherited from interface com.sun.jdi.Accessible
`isPackagePrivate, isPrivate, isProtected, isPublic, modifiers`

Methods inherited from interface com.sun.jdi.Locatable
`location`

Methods inherited from interface java.lang.Comparable
`compareTo`

Method Detail

### returnTypeName

    public String returnTypeName()

  Returns a text representation of the declared return type of this method.
  Returns:
    a string containing the return type name.

### returnType

    public Type returnType()
                    throws ClassNotLoadedException

  Returns the return type of the this `Method`. For methods returning primitive values, an appropriate `PrimitiveType` is always returned. For methods returning object values, the appropriate `ReferenceType` is returned if it has been loaded through the enclosing type's (that is, the type returned by `TypeComponent#enclosingType`) class loader.
  Returns:
    the return `Type` of this method.
  Throws:
    `ClassNotLoadedException` - if the type has not yet been loaded through the appropriate class loader.

### argumentTypeNames

    public List argumentTypeNames()

  Returns a text representation of all declared argument types of this method. This list is always available even if argument variables are unavailable due to absent debug information.
  Returns:
    a List of strings containing the return type name.

### argumentTypes

    public List argumentTypes()
                       throws ClassNotLoadedException

  Returns the list containing the type of each argument. For primitive arguments, an appropriate `PrimitiveType` is always returned. For object arguments, the appropriate `ReferenceType` is returned if it has been loaded through the enclosing type's (that is, the type returned by `TypeComponent#enclosingType`) class loader.
  Returns:
    the list of argument types for this method.
  Throws:
    `ClassNotLoadedException` - if the type has not yet been loaded through the appropriate class loader.

### isAbstract

    public boolean isAbstract()

  Determine if this method is abstract.
  Returns:
    `true` if the method is declared abstract; false otherwise.

### isSynchronized

    public boolean isSynchronized()

  Determine if this method is synchronized.
  Returns:
    `true` if the method is declared synchronized; false otherwise.

### isNative

    public boolean isNative()

  Determine if this method is native.
  Returns:
    `true` if the method is declared native; false otherwise.

### isConstructor

    public boolean isConstructor()

  Determine if this method is a constructor.
  Returns:
    `true` if the method is a constructor; false otherwise.

### isStaticInitializer

    public boolean isStaticInitializer()

  Determine if this method is a static initializer.
  Returns:
    `true` if the method is a static initializer; false otherwise.

### allLineLocations

    public List allLineLocations()
                          throws AbsentInformationException

  Returns the beginning `Location` objects for each executable source line in this method. Each location maps a source line to a range of code indices. The beginning of the range can be determined through `Location.codeIndex()`. The returned list is ordered by code index (from low to high). The returned list may contain multiple locations for a particular line number, if the compiler and/or VM has mapped that line to two or more disjoint code index ranges.

  If the method is native or abstract, an empty list is returned.

  Returns:
    a List of all source line `Location` objects.
  Throws:
    `AbsentInformationException` - if there is no line number information for this (non-native, non-abstract) method.

### locationsOfLine

    public List locationsOfLine(int lineNumber)
                         throws AbsentInformationException

  Returns a list containing each `Location` that maps to the given line. The returned list will contain a location for each disjoint range of code indices that have been assigned to the given line by the compiler and/or VM. Each returned location corresponds to the beginning of this range.
  Parameters:
    `lineNumber` - the line number
  Returns:
    a List of `Location` objects that map to the given line number.
  Throws:
    `AbsentInformationException` - if there is no line number information for this method.
    `InvalidLineNumberException` - if there is no executable code in this method associated with the given line.

### locationOfCodeIndex

    public Location locationOfCodeIndex(long codeIndex)

  Returns a `Location` for the given code index.
  Returns:
    the `Location` correspoding to the the given code index.
  Throws:
    `InvalidCodeIndexException` - if there is no valid location at the specified code index

### variables

    public List variables()
                   throws AbsentInformationException

  Returns a list containing each `LocalVariable` declared in this method. The list includes any variable declared in any scope within the method. It may contain multiple variables of the same name declared within disjoint scopes. Arguments are considered local variables and will be present in the returned list.
  Returns:
    the list of `LocalVariable` objects which mirror local variables declared in this method in the target VM. If there are no local variables, a zero-length list is returned.
  Throws:
    `AbsentInformationException` - if there is no variable information for this method.
    `NativeMethodException` - if this operation is attempted for a native method.

### variablesByName

    public List variablesByName(String name)
                         throws AbsentInformationException

  Returns a list containing each `LocalVariable` of a given name in this method. Multiple variables can be returned if the same variable name is used in disjoint scopes within the method.
  Returns:
    the list of `LocalVariable` objects of the given name. If there are no matching local variables, a zero-length list is returned.
  Throws:
    `AbsentInformationException` - if there is no variable information for this method.
    `NativeMethodException` - if this operation is attempted for a native method.

### arguments

    public List arguments()
                   throws AbsentInformationException

  Returns a list containing each `LocalVariable` that is declared as an argument of this method.
  Returns:
    the list of `LocalVariable` arguments. If there are no arguments, a zero-length list is returned.
  Throws:
    `AbsentInformationException` - if there is no variable information for this method.
    `NativeMethodException` - if this operation is attempted for a native method.

### bytecodes

    public byte[] bytecodes()

  Returns an array containing the bytecodes for this method.

  Not all target VMs support this query. See VirtualMachine#canGetBytecodes to determine if the operation is supported.

  Returns:
    the array of bytecodes.
  Throws:
    `java.lang.UnsupportedOperationException` - if the target VM does not support the retrieval of bytecodes.

### equals

    public boolean equals(Object obj)

  Compares the specified Object with this method for equality.
  Overrides:
    `equals` in class `Object`
  Returns:
    true if the Object is a method and if both mirror the same method (declared in the same class or interface, in the same VM).

### hashCode

    public int hashCode()

  Returns the hash code value for this Method.
  Overrides:
    `hashCode` in class `Object`
  Returns:
    the integer hash code

Overview | Package | Class | Use | Tree | Index | Help
| Java Debug Interface
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD