The availability of a line number for a location will depend on the level of debugging information available from the target VM.
Several mirror interfaces have locations. Each such mirror
extends a Locatable interface.
The source information for a Location is dependent on the
stratum which is used. A stratum is a source code
level within a sequence of translations. For example,
say the baz program is written in the programming language
"Foo" then translated to the language "Bar" and finally
translated into the Java programming language. The
Java programming language stratum is named
"Java", let's say the other strata are named
"Foo" and "Bar". A given location (as viewed by the
sourceName() and lineNumber() methods)
might be at line 14 of "baz.foo" in the "Foo"
stratum, line 23 of "baz.bar" in the "Bar"
stratum and line 71 of the "Java" stratum.
Note that while the Java programming language may have
only one source file for a reference type, this restriction
does not apply to other strata - thus each Location should
be consulted to determine its source path.
Queries which do not specify a stratum
(sourceName(), sourcePath() and
lineNumber()) use the VM's default stratum
(VirtualMachine#getDefaultStratum()).
If the specified stratum (whether explicitly specified
by a method parameter or implicitly as the VM's default)
is null or is not available in the declaring
type, the declaring type's default stratum is used
(declaringType().defaultStratum()). Note that in the normal case, of code
that originates as Java programming language source, there
will be only one stratum ("Java") and it will be
returned as the default. To determine the available strata
use ReferenceType#availableStrata().
EventRequestManager, StackFrame, BreakpointEvent, ExceptionEvent, Locatable
| Modifier and Type | Method and Description |
|---|---|
| public long | Returns: the long representing the position within the method or -1 if location is within a native method.Gets the code position within this location's method. |
| public ReferenceType | Returns: theReferenceType containing this Location.Gets the type to which this Location belongs. |
| public boolean | |
| public int | |
| public int | Returns: an int specifying the line in the source, returns -1 if the information is not available; specifically, always returns -1 for native methods.Gets the line number of this Location. |
| public int | Returns: an int specifying the line in the source, returns -1 if the information is not available; specifically, always returns -1 for native methods.The stratum to retrieve information from
or stratum)null for the declaring type's
default stratum.The line number of this Location. |
| public Method | |
| public String | Returns: a string specifying the sourceGets an identifying name for the source corresponding to this location. |
| public String | Returns: a string specifying the sourceThe stratum to retrieve information from
or stratum)null for the declaring type's
default stratum.Gets an identifying name for the source corresponding to this location. |
| public String | Returns: a string specifying the sourceGets the path to the source corresponding to this location. |
| public String | Returns: a string specifying the sourceThe stratum to retrieve information from
or stratum)null for the declaring type's
default stratum.Gets the path to the source corresponding to this location. |
| codeIndex | back to summary |
|---|---|
| public long codeIndex() Gets the code position within this location's method.
| |
| declaringType | back to summary |
|---|---|
| public ReferenceType declaringType() Gets the type to which this Location belongs. Normally
the declaring type is a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Compares the specified Object with this Location for equality.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Returns the hash code value for this Location.
| |
| lineNumber | back to summary |
|---|---|
| public int lineNumber() Gets the line number of this Location.
This method is equivalent to
| |
| lineNumber | back to summary |
|---|---|
| public int lineNumber(String stratum) The line number of this Location. The line number is
relative to the source specified by
Returned line number is for the specified stratum
(see the
| |
| method | back to summary |
|---|---|
| public Method method() Gets the method containing this Location. | |
| sourceName | back to summary |
|---|---|
| public String sourceName() throws AbsentInformationException Gets an identifying name for the source corresponding to this location.
This method is equivalent to
| |
| sourceName | back to summary |
|---|---|
| public String sourceName(String stratum) throws AbsentInformationException Gets an identifying name for the source corresponding to this location. Interpretation of this string is the responsibility of the source repository mechanism.
Returned name is for the specified stratum
(see the
The returned string is the unqualified name of the source
file for this Location. For example,
| |
| sourcePath | back to summary |
|---|---|
| public String sourcePath() throws AbsentInformationException Gets the path to the source corresponding to this location.
This method is equivalent to
| |
| sourcePath | back to summary |
|---|---|
| public String sourcePath(String stratum) throws AbsentInformationException Gets the path to the source corresponding to this location. Interpretation of this string is the responsibility of the source repository mechanism.
Returned path is for the specified stratum
(see the
In the reference implementation, for strata which
do not explicitly specify source path (the Java
programming language stratum never does), the returned
string is the package name of
| |