/* * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.sun.jdi; import java.util.List; /** * A point within the executing code of the target VM. * Locations are used to identify the current position of * a suspended thread (analogous to an instruction pointer or * program counter register in native programs). They are also used * to identify the position at which to set a breakpoint. *
* 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 {@link Locatable} interface. *
* Strata *
* 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
*
* This method is equivalent to
*
* Returned name is for the specified stratum
* (see the {@link Location class comment} for a
* description of strata).
*
* The returned string is the unqualified name of the source
* file for this Location. For example,
*
* This method is equivalent to
*
* Returned path is for the specified stratum
* (see the {@link Location class comment} for a
* description of strata).
*
* 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 {@link #declaringType()}
* converted to a platform dependent path followed by the
* unqualified name of the source file for this Location
* ({@link #sourceName sourceName(stratum)}).
* For example, on a
* Windows platform,
* This method is equivalent to
*
* Returned line number is for the specified stratum
* (see the {@link Location class comment} for a
* description of strata).
*
* @param stratum The stratum to retrieve information from
* or "Java"
, let's say the other strata are named
* "Foo" and "Bar". A given location (as viewed by the
* {@link #sourceName()} and {@link #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
* ({@link #sourceName()}, {@link #sourcePath()} and
* {@link #lineNumber()}) use the VM's default stratum
* ({@link 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
* ({@link #declaringType()}.{@link ReferenceType#defaultStratum()
* 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 {@link ReferenceType#availableStrata()}.
*
* @see com.sun.jdi.request.EventRequestManager
* @see StackFrame
* @see com.sun.jdi.event.BreakpointEvent
* @see com.sun.jdi.event.ExceptionEvent
* @see Locatable
*
* @author Robert Field
* @author Gordon Hirsch
* @author James McIlree
* @since 1.3
*/
public interface Location extends Mirror, ComparablesourceName(vm.getDefaultStratum())
-
* see {@link #sourceName(String)}
* for more information.
*
* @return a string specifying the source
* @throws AbsentInformationException if the source name is not
* known
*/
String sourceName() throws AbsentInformationException;
/**
* Gets an identifing name for the source corresponding to
* this location. Interpretation of this string is the
* responsibility of the source repository mechanism.
* java.lang.Thread
would return
* "Thread.java"
.
*
* @param stratum The stratum to retrieve information from
* or null
for the declaring type's
* default stratum.
*
* @return a string specifying the source
*
* @throws AbsentInformationException if the source name is not
* known
*
* @since 1.4
*/
String sourceName(String stratum)
throws AbsentInformationException;
/**
* Gets the path to the source corresponding to this
* location.
* sourcePath(vm.getDefaultStratum())
-
* see {@link #sourcePath(String)}
* for more information.
*
* @return a string specifying the source
*
* @throws AbsentInformationException if the source name is not
* known
*/
String sourcePath() throws AbsentInformationException;
/**
* Gets the path to the source corresponding to this
* location. Interpretation of this string is the
* responsibility of the source repository mechanism.
* java.lang.Thread
* would return
* "java\lang\Thread.java"
.
*
* @param stratum The stratum to retrieve information from
* or null
for the declaring type's
* default stratum.
*
* @return a string specifying the source
*
* @throws AbsentInformationException if the source name is not
* known
*
* @since 1.4
*/
String sourcePath(String stratum)
throws AbsentInformationException;
/**
* Gets the line number of this Location.
* lineNumber(vm.getDefaultStratum())
-
* see {@link #lineNumber(String)}
* for more information.
*
* @return an int specifying the line in the source, returns
* -1 if the information is not available; specifically, always
* returns -1 for native methods.
*/
int lineNumber();
/**
* The line number of this Location. The line number is
* relative to the source specified by
* {@link #sourceName(String) sourceName(stratum)}.
* null
for the declaring type's
* default stratum.
*
* @return an int specifying the line in the source, returns
* -1 if the information is not available; specifically, always
* returns -1 for native methods.
*
* @since 1.4
*/
int lineNumber(String stratum);
/**
* Compares the specified Object with this Location for equality.
*
* @return true if the Object is a Location and if it refers to
* the same point in the same VM as this Location.
*/
boolean equals(Object obj);
/**
* Returns the hash code value for this Location.
*
* @return the integer hash code
*/
int hashCode();
}