APIdia Launch Partner
Top Description Methods
com.sun.jdi

public Interface Method

extends TypeComponent, Locatable, Comparable<Method>
Known Direct Implementers
com.sun.tools.jdi.MethodImpl
Imports
java.util.List

A static or instance method in the target VM. See TypeComponent for general information about Field and Method mirrors.
Authors
Robert Field, Gordon Hirsch, James McIlree
Since
1.3
See Also
ObjectReference, ReferenceType

Method Summary

Modifier and TypeMethod and Description
public List<Location>

Returns:

a List of all source line Location objects.
allLineLocations
()

Returns a list containing a Location object for each executable source line in this method.

public List<Location>

Returns:

a List of all source line Location objects.
allLineLocations
(String
The stratum to retrieve information from or null for the ReferenceType#defaultStratum()
stratum
,
String
Return locations only within this source file or null to return locations.
sourceName
)

Returns a list containing a Location object for each executable source line in this method.

public List<LocalVariable>

Returns:

the list of LocalVariable arguments. If there are no arguments, a zero-length list is returned.
arguments
()

Returns a list containing each LocalVariable that is declared as an argument of this method.

public List<String>

Returns:

a List of String, one List element for each parameter of this method. Each element represents the type of a formal parameter as specified at compile-time. If the formal parameter was declared with an ellipsis, then it is represented as an array of the type before the ellipsis.
argumentTypeNames
()

Returns a list containing a text representation of the type of each formal parameter of this method.

public List<Type>

Returns:

return a List of Type, one List element for each parameter of this method. Each element represents the type of a formal parameter as specified at compile-time. If the formal parameter was declared with an ellipsis, then it is represented as an array of the type before the ellipsis.
argumentTypes
()

Returns a list containing the type of each formal parameter of this method.

public byte[]

Returns:

the array of bytecodes; abstract and native methods will return a zero-length array.
bytecodes
()

Returns an array containing the bytecodes for this method.

public boolean

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).
equals
(Object obj)

Compares the specified Object with this method for equality.

public int

Returns:

the integer hash code.
hashCode
()

Returns the hash code value for this Method.

public boolean

Returns:

true if the method is declared abstract; false otherwise.
isAbstract
()

Determine if this method is abstract.

public boolean

Returns:

true if the method is a bridge method, false otherwise.
isBridge
()

Determine if this method is a bridge method.

public boolean

Returns:

true if the method is a constructor; false otherwise.
isConstructor
()

Determine if this method is a constructor.

public default boolean

Returns:

true if the method is declared default; false otherwise.
isDefault
()

Determine if this method is a default method

public boolean

Returns:

true if the method is declared native; false otherwise.
isNative
()

Determine if this method is native.

public boolean

Returns:

true if this method has been made obsolete by a VirtualMachine#redefineClasses operation.
isObsolete
()

Determine if this method is obsolete.

public boolean

Returns:

true if the method is a static initializer; false otherwise.
isStaticInitializer
()

Determine if this method is a static initializer.

public boolean

Returns:

true if the method is declared synchronized; false otherwise.
isSynchronized
()

Determine if this method is synchronized.

public boolean

Returns:

true if the method accepts a variable number of arguments, false otherwise.
isVarArgs
()

Determine if this method accepts a variable number of arguments.

public Location

Returns:

the Location of this mirror, or null if this is an abstract method; native methods will return a Location object whose codeIndex is -1.
location
()

Redeclares com.sun.jdi.Locatable.location.

Returns the Location of this method, if there is executable code associated with it.

public Location

Returns:

the Location corresponding to the given code index or null if the specified code index is not a valid code index for this method (native and abstract methods will always return null).
locationOfCodeIndex
(long codeIndex)

Returns a Location for the given code index.

public List<Location>

Returns:

a List of Location objects that map to the given line number.
locationsOfLine
(int
the line number
lineNumber
)

Returns a List containing all Location objects that map to the given line number.

public List<Location>

Returns:

a List of Location objects that map to the given line number.
locationsOfLine
(String
the stratum to use for comparing line number and source name, or null to use the default stratum
stratum
,
String
the source name containing the line number, or null to match all source names
sourceName
,
int
the line number
lineNumber
)

Returns a List containing all Location objects that map to the given line number and source name.

public Type

Returns:

the return Type of this method.
returnType
()

Returns the return type, as specified in the declaration of this method.

public String

Returns:

a String containing the return type name.
returnTypeName
()

Returns a text representation of the return type, as specified in the declaration of this method.

public List<LocalVariable>

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.
variables
()

Returns a list containing each LocalVariable declared in this method.

public List<LocalVariable>

Returns:

the list of LocalVariable objects of the given name. If there are no matching local variables, a zero-length list is returned.
variablesByName
(String name)

Returns a list containing each LocalVariable of a given name in this method.

Inherited from com.sun.jdi.TypeComponent:
declaringTypegenericSignatureisFinalisStaticisSyntheticnamesignature
Inherited from java.lang.Comparable:
compareTo

Method Detail

allLineLocationsback to summary
public List<Location> allLineLocations() throws AbsentInformationException

Returns a list containing a Location object for each executable source line in this method.

This method is equivalent to allLineLocations(vm.getDefaultStratum(),null) - see allLineLocations(String, String) for more information.

Returns:List<Location>

a List of all source line Location objects.

Exceptions
AbsentInformationException:
if there is no line number information for this (non-native, non-abstract) method.
allLineLocationsback to summary
public List<Location> allLineLocations(String stratum, String sourceName) throws AbsentInformationException

Returns a list containing a Location object 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.

Returned list is for the specified stratum (see Location for a description of strata).

Parameters
stratum:String

The stratum to retrieve information from or null for the ReferenceType#defaultStratum()

sourceName:String

Return locations only within this source file or null to return locations.

Returns:List<Location>

a List of all source line Location objects.

Exceptions
AbsentInformationException:
if there is no line number information for this (non-native, non-abstract) method. Or if sourceName is non-null and source name information is not present.
Since
1.4
argumentsback to summary
public List<LocalVariable> arguments() throws AbsentInformationException

Returns a list containing each LocalVariable that is declared as an argument of this method. If local variable information is not available, values of actual arguments to method invocations can be obtained by using the method StackFrame#getArgumentValues()

Returns:List<LocalVariable>

the list of LocalVariable arguments. If there are no arguments, a zero-length list is returned.

Exceptions
AbsentInformationException:
if there is no variable information for this method. Generally, local variable information is not available for native or abstract methods (that is, their argument name information is not available), thus they will throw this exception.
argumentTypeNamesback to summary
public List<String> argumentTypeNames()

Returns a list containing a text representation of the type of each formal parameter of this method.

This list is always available even if the types have not yet been created or loaded.

Returns:List<String>

a List of String, one List element for each parameter of this method. Each element represents the type of a formal parameter as specified at compile-time. If the formal parameter was declared with an ellipsis, then it is represented as an array of the type before the ellipsis.

argumentTypesback to summary
public List<Type> argumentTypes() throws ClassNotLoadedException

Returns a list containing the type of each formal parameter of this method.

Note

if there is any parameter whose type is a reference type (class, interface, or array) and it has not been created or loaded by the declaring type's class loader - that is, declaringType() .classLoader(), then ClassNotLoadedException will be thrown. Also, a reference type may have been loaded but not yet prepared, in which case the list will be returned but attempts to perform some operations on the type (e.g. fields()) will throw a ClassNotPreparedException. Use ReferenceType#isPrepared() to determine if a reference type is prepared.

Returns:List<Type>

return a List of Type, one List element for each parameter of this method. Each element represents the type of a formal parameter as specified at compile-time. If the formal parameter was declared with an ellipsis, then it is represented as an array of the type before the ellipsis.

Exceptions
ClassNotLoadedException:
if the type has not yet been loaded through the appropriate class loader.
See Also
Type
bytecodesback to summary
public byte[] bytecodes()

Returns an array containing the bytecodes for this method.

Not all target virtual machines support this operation. Use VirtualMachine#canGetBytecodes() to determine if the operation is supported.

Returns:byte[]

the array of bytecodes; abstract and native methods will return a zero-length array.

Exceptions
UnsupportedOperationException:
if the target virtual machine does not support the retrieval of bytecodes.
equalsback to summary
public boolean equals(Object obj)

Compares the specified Object with this method for equality.

Returns:boolean

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).

hashCodeback to summary
public int hashCode()

Returns the hash code value for this Method.

Returns:int

the integer hash code.

isAbstractback to summary
public boolean isAbstract()

Determine if this method is abstract.

Returns:boolean

true if the method is declared abstract; false otherwise.

isBridgeback to summary
public boolean isBridge()

Determine if this method is a bridge method. Bridge methods are defined in The Java Language Specification.

Returns:boolean

true if the method is a bridge method, false otherwise.

Since
1.5
isConstructorback to summary
public boolean isConstructor()

Determine if this method is a constructor.

Returns:boolean

true if the method is a constructor; false otherwise.

isDefaultback to summary
public default boolean isDefault()

Determine if this method is a default method

Returns:boolean

true if the method is declared default; false otherwise.

Since
1.8
isNativeback to summary
public boolean isNative()

Determine if this method is native.

Returns:boolean

true if the method is declared native; false otherwise.

isObsoleteback to summary
public boolean isObsolete()

Determine if this method is obsolete.

Returns:boolean

true if this method has been made obsolete by a VirtualMachine#redefineClasses operation.

Since
1.4
isStaticInitializerback to summary
public boolean isStaticInitializer()

Determine if this method is a static initializer.

Returns:boolean

true if the method is a static initializer; false otherwise.

isSynchronizedback to summary
public boolean isSynchronized()

Determine if this method is synchronized.

Returns:boolean

true if the method is declared synchronized; false otherwise.

isVarArgsback to summary
public boolean isVarArgs()

Determine if this method accepts a variable number of arguments.

Returns:boolean

true if the method accepts a variable number of arguments, false otherwise.

Since
1.5
locationback to summary
public Location location()

Redeclares com.sun.jdi.Locatable.location.

Returns the Location of this method, if there is executable code associated with it.

Returns:Location

the Location of this mirror, or null if this is an abstract method; native methods will return a Location object whose codeIndex is -1.

locationOfCodeIndexback to summary
public Location locationOfCodeIndex(long codeIndex)

Returns a Location for the given code index.

Returns:Location

the Location corresponding to the given code index or null if the specified code index is not a valid code index for this method (native and abstract methods will always return null).

locationsOfLineback to summary
public List<Location> locationsOfLine(int lineNumber) throws AbsentInformationException

Returns a List containing all Location objects that map to the given line number.

This method is equivalent to locationsOfLine(vm.getDefaultStratum(), null, lineNumber) - see locationsOfLine(java.lang.String, java.lang.String, int) for more information.

Parameters
lineNumber:int

the line number

Returns:List<Location>

a List of Location objects that map to the given line number.

Exceptions
AbsentInformationException:
if there is no line number information for this method.
locationsOfLineback to summary
public List<Location> locationsOfLine(String stratum, String sourceName, int lineNumber) throws AbsentInformationException

Returns a List containing all Location objects that map to the given line number and source name.

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. An empty list will be returned if there is no executable code at the specified line number; specifically, native and abstract methods will always return an empty list.

Returned list is for the specified stratum (see Location for a description of strata).

Parameters
stratum:String

the stratum to use for comparing line number and source name, or null to use the default stratum

sourceName:String

the source name containing the line number, or null to match all source names

lineNumber:int

the line number

Returns:List<Location>

a List of Location objects that map to the given line number.

Exceptions
AbsentInformationException:
if there is no line number information for this method. Or if sourceName is non-null and source name information is not present.
Since
1.4
returnTypeback to summary
public Type returnType() throws ClassNotLoadedException

Returns the return type, as specified in the declaration of this method.

Note

if the return type of this method is a reference type (class, interface, or array) and it has not been created or loaded by the declaring type's class loader - that is, declaringType() .classLoader(), then ClassNotLoadedException will be thrown. Also, a reference type may have been loaded but not yet prepared, in which case the type will be returned but attempts to perform some operations on the returned type (e.g. fields()) will throw a ClassNotPreparedException. Use ReferenceType#isPrepared() to determine if a reference type is prepared.

Returns:Type

the return Type of this method.

Exceptions
ClassNotLoadedException:
if the type has not yet been created or loaded through the appropriate class loader.
See Also
Type, Field.type() - for usage examples
returnTypeNameback to summary
public String returnTypeName()

Returns a text representation of the return type, as specified in the declaration of this method.

This type name is always available even if the type has not yet been created or loaded.

Returns:String

a String containing the return type name.

variablesback to summary
public List<LocalVariable> 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. If local variable information is not available, values of actual arguments to method invocations can be obtained by using the method StackFrame#getArgumentValues()

Returns:List<LocalVariable>

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.

Exceptions
AbsentInformationException:
if there is no variable information for this method. Generally, local variable information is not available for native or abstract methods (that is, their argument name information is not available), thus they will throw this exception.
variablesByNameback to summary
public List<LocalVariable> 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:List<LocalVariable>

the list of LocalVariable objects of the given name. If there are no matching local variables, a zero-length list is returned.

Exceptions
AbsentInformationException:
if there is no variable information for this method. Generally, local variable information is not available for native or abstract methods (that is, their argument name information is not available), thus they will throw this exception.