Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/jdi/Location.java
38831 views
/*1* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.jdi;2627import java.util.List;2829/**30* A point within the executing code of the target VM.31* Locations are used to identify the current position of32* a suspended thread (analogous to an instruction pointer or33* program counter register in native programs). They are also used34* to identify the position at which to set a breakpoint.35* <p>36* The availability of a line number for a location will37* depend on the level of debugging information available from the38* target VM.39* <p>40* Several mirror interfaces have locations. Each such mirror41* extends a {@link Locatable} interface.42* <p>43* <a name="strata"><b>Strata</b></a>44* <p>45* The source information for a Location is dependent on the46* <i>stratum</i> which is used. A stratum is a source code47* level within a sequence of translations. For example,48* say the baz program is written in the programming language49* "Foo" then translated to the language "Bar" and finally50* translated into the Java programming language. The51* Java programming language stratum is named52* <code>"Java"</code>, let's say the other strata are named53* "Foo" and "Bar". A given location (as viewed by the54* {@link #sourceName()} and {@link #lineNumber()} methods)55* might be at line 14 of "baz.foo" in the <code>"Foo"</code>56* stratum, line 23 of "baz.bar" in the <code>"Bar"</code>57* stratum and line 71 of the <code>"Java"</code> stratum.58* Note that while the Java programming language may have59* only one source file for a reference type, this restriction60* does not apply to other strata - thus each Location should61* be consulted to determine its source path.62* Queries which do not specify a stratum63* ({@link #sourceName()}, {@link #sourcePath()} and64* {@link #lineNumber()}) use the VM's default stratum65* ({@link VirtualMachine#getDefaultStratum()}).66* If the specified stratum (whether explicitly specified67* by a method parameter or implicitly as the VM's default)68* is <code>null</code> or is not available in the declaring69* type, the declaring type's default stratum is used70* ({@link #declaringType()}.{@link ReferenceType#defaultStratum()71* defaultStratum()}). Note that in the normal case, of code72* that originates as Java programming language source, there73* will be only one stratum (<code>"Java"</code>) and it will be74* returned as the default. To determine the available strata75* use {@link ReferenceType#availableStrata()}.76*77* @see com.sun.jdi.request.EventRequestManager78* @see StackFrame79* @see com.sun.jdi.event.BreakpointEvent80* @see com.sun.jdi.event.ExceptionEvent81* @see Locatable82*83* @author Robert Field84* @author Gordon Hirsch85* @author James McIlree86* @since 1.387*/88@jdk.Exported89public interface Location extends Mirror, Comparable<Location> {9091/**92* Gets the type to which this Location belongs. Normally93* the declaring type is a {@link ClassType}, but executable94* locations also may exist within the static initializer of an95* {@link InterfaceType}.96*97* @return the {@link ReferenceType} containing this Location.98*/99ReferenceType declaringType();100101/**102* Gets the method containing this Location.103*104* @return the location's {@link Method}.105*/106Method method();107108/**109* Gets the code position within this location's method.110*111* @return the long representing the position within the method112* or -1 if location is within a native method.113*/114long codeIndex();115116/**117* Gets an identifing name for the source corresponding to118* this location.119* <P>120* This method is equivalent to121* <code>sourceName(vm.getDefaultStratum())</code> -122* see {@link #sourceName(String)}123* for more information.124*125* @return a string specifying the source126* @throws AbsentInformationException if the source name is not127* known128*/129String sourceName() throws AbsentInformationException;130131132/**133* Gets an identifing name for the source corresponding to134* this location. Interpretation of this string is the135* responsibility of the source repository mechanism.136* <P>137* Returned name is for the specified <i>stratum</i>138* (see the {@link Location class comment} for a139* description of strata).140* <P>141* The returned string is the unqualified name of the source142* file for this Location. For example,143* <CODE>java.lang.Thread</CODE> would return144* <CODE>"Thread.java"</CODE>.145*146* @param stratum The stratum to retrieve information from147* or <code>null</code> for the declaring type's148* default stratum.149*150* @return a string specifying the source151*152* @throws AbsentInformationException if the source name is not153* known154*155* @since 1.4156*/157String sourceName(String stratum)158throws AbsentInformationException;159160/**161* Gets the path to the source corresponding to this162* location.163* <P>164* This method is equivalent to165* <code>sourcePath(vm.getDefaultStratum())</code> -166* see {@link #sourcePath(String)}167* for more information.168*169* @return a string specifying the source170*171* @throws AbsentInformationException if the source name is not172* known173*/174String sourcePath() throws AbsentInformationException;175176177/**178* Gets the path to the source corresponding to this179* location. Interpretation of this string is the180* responsibility of the source repository mechanism.181* <P>182* Returned path is for the specified <i>stratum</i>183* (see the {@link Location class comment} for a184* description of strata).185* <P>186* In the reference implementation, for strata which187* do not explicitly specify source path (the Java188* programming language stratum never does), the returned189* string is the package name of {@link #declaringType()}190* converted to a platform dependent path followed by the191* unqualified name of the source file for this Location192* ({@link #sourceName sourceName(stratum)}).193* For example, on a194* Windows platform, <CODE>java.lang.Thread</CODE>195* would return196* <CODE>"java\lang\Thread.java"</CODE>.197*198* @param stratum The stratum to retrieve information from199* or <code>null</code> for the declaring type's200* default stratum.201*202* @return a string specifying the source203*204* @throws AbsentInformationException if the source name is not205* known206*207* @since 1.4208*/209String sourcePath(String stratum)210throws AbsentInformationException;211212/**213* Gets the line number of this Location.214* <P>215* This method is equivalent to216* <code>lineNumber(vm.getDefaultStratum())</code> -217* see {@link #lineNumber(String)}218* for more information.219*220* @return an int specifying the line in the source, returns221* -1 if the information is not available; specifically, always222* returns -1 for native methods.223*/224int lineNumber();225226/**227* The line number of this Location. The line number is228* relative to the source specified by229* {@link #sourceName(String) sourceName(stratum)}.230* <P>231* Returned line number is for the specified <i>stratum</i>232* (see the {@link Location class comment} for a233* description of strata).234*235* @param stratum The stratum to retrieve information from236* or <code>null</code> for the declaring type's237* default stratum.238*239* @return an int specifying the line in the source, returns240* -1 if the information is not available; specifically, always241* returns -1 for native methods.242*243* @since 1.4244*/245int lineNumber(String stratum);246247/**248* Compares the specified Object with this Location for equality.249*250* @return true if the Object is a Location and if it refers to251* the same point in the same VM as this Location.252*/253boolean equals(Object obj);254255/**256* Returns the hash code value for this Location.257*258* @return the integer hash code259*/260int hashCode();261}262263264