Path: blob/master/src/jdk.jdi/share/classes/com/sun/jdi/ArrayReference.java
41159 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* Provides access to an array object and its components in the target VM.31* Each array component is mirrored by a {@link Value} object.32* The array components, in aggregate, are placed in {@link java.util.List}33* objects instead of arrays for consistency with the rest of the API and34* for interoperability with other APIs.35*36* @author Robert Field37* @author Gordon Hirsch38* @author James McIlree39* @since 1.340*/41public interface ArrayReference extends ObjectReference {4243/**44* Returns the number of components in this array.45*46* @return the integer count of components in this array.47*/48int length();4950/**51* Returns an array component value.52*53* @param index the index of the component to retrieve54* @return the {@link Value} at the given index.55* @throws java.lang.IndexOutOfBoundsException if56* <CODE><I>index</I></CODE> is outside the range of this array,57* that is, if either of the following are true:58* <PRE>59* <I>index</I> < 060* <I>index</I> >= {@link #length() length()} </PRE>61*/62Value getValue(int index);6364/**65* Returns all of the components in this array.66*67* @return a list of {@link Value} objects, one for each array68* component ordered by array index. For zero length arrays,69* an empty list is returned.70*/71List<Value> getValues();7273/**74* Returns a range of array components.75*76* @param index the index of the first component to retrieve77* @param length the number of components to retrieve, or -1 to78* retrieve all components to the end of this array.79* @return a list of {@link Value} objects, one for each requested80* array component ordered by array index. When there are81* no elements in the specified range (e.g.82* <CODE><I>length</I></CODE> is zero) an empty list is returned83*84* @throws java.lang.IndexOutOfBoundsException if the range85* specified with <CODE><I>index</I></CODE> and86* <CODE><I>length</I></CODE> is not within the range of the array,87* that is, if either of the following are true:88* <PRE>89* <I>index</I> < 090* <I>index</I> > {@link #length() length()} </PRE>91* or if <CODE><I>length</I> != -1</CODE> and92* either of the following are true:93* <PRE>94* <I>length</I> < 095* <I>index</I> + <I>length</I> > {@link #length() length()}</PRE>96*/97List<Value> getValues(int index, int length);9899/**100* Replaces an array component with another value.101* <p>102* Object values must be assignment compatible with the component type103* (This implies that the component type must be loaded through the104* declaring class's class loader). Primitive values must be105* either assignment compatible with the component type or must be106* convertible to the component type without loss of information.107* See JLS section 5.2 for more information on assignment108* compatibility.109*110* @param value the new value111* @param index the index of the component to set112* @throws java.lang.IndexOutOfBoundsException if113* <CODE><I>index</I></CODE> is outside the range of this array,114* that is, if either of the following are true:115* <PRE>116* <I>index</I> < 0117* <I>index</I> >= {@link #length() length()} </PRE>118* @throws InvalidTypeException if the type of <CODE><I>value</I></CODE>119* is not compatible with the declared type of array components.120* @throws ClassNotLoadedException if the array component type121* has not yet been loaded122* through the appropriate class loader.123* @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.124*125* @see ArrayType#componentType()126*/127void setValue(int index, Value value)128throws InvalidTypeException,129ClassNotLoadedException;130131/**132* Replaces all array components with other values. If the given133* list is larger in size than the array, the values at the134* end of the list are ignored.135* <p>136* Object values must be assignment compatible with the element type137* (This implies that the component type must be loaded through the138* enclosing class's class loader). Primitive values must be139* either assignment compatible with the component type or must be140* convertible to the component type without loss of information.141* See JLS section 5.2 for more information on assignment142* compatibility.143*144* @param values a list of {@link Value} objects to be placed145* in this array. If <CODE><I>values</I>.size()</CODE> is146* less that the length of the array, the first147* <CODE><I>values</I>.size()</CODE> elements are set.148* @throws InvalidTypeException if any of the149* new <CODE><I>values</I></CODE>150* is not compatible with the declared type of array components.151* @throws ClassNotLoadedException if the array component152* type has not yet been loaded153* through the appropriate class loader.154* @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.155*156* @see ArrayType#componentType()157*/158void setValues(List<? extends Value> values)159throws InvalidTypeException,160ClassNotLoadedException;161162/**163* Replaces a range of array components with other values.164* <p>165* Object values must be assignment compatible with the component type166* (This implies that the component type must be loaded through the167* enclosing class's class loader). Primitive values must be168* either assignment compatible with the component type or must be169* convertible to the component type without loss of information.170* See JLS section 5.2 for more information on assignment171* compatibility.172*173* @param index the index of the first component to set.174* @param values a list of {@link Value} objects to be placed175* in this array.176* @param srcIndex the index of the first source value to use.177* @param length the number of components to set, or -1 to set178* all components to the end of this array or the end of179* <CODE><I>values</I></CODE> (whichever comes first).180* @throws InvalidTypeException if any element of181* <CODE><I>values</I></CODE>182* is not compatible with the declared type of array components.183* @throws java.lang.IndexOutOfBoundsException if the184* array range specified with185* <CODE><I>index</I></CODE> and <CODE><I>length</I></CODE>186* is not within the range of the array,187* or if the source range specified with188* <CODE><I>srcIndex</I></CODE> and <CODE><I>length</I></CODE>189* is not within <CODE><I>values</I></CODE>,190* that is, if any of the following are true:191* <PRE>192* <I>index</I> < 0193* <I>index</I> > {@link #length() length()}194* <I>srcIndex</I> < 0195* <I>srcIndex</I> > <I>values</I>.size() </PRE>196* or if <CODE><I>length</I> != -1</CODE> and any of the197* following are true:198* <PRE>199* <I>length</I> < 0200* <I>index</I> + <I>length</I> > {@link #length() length()}201* <I>srcIndex</I> + <I>length</I> > <I>values</I>.size() </PRE>202* @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.203* @see ArrayType#componentType()204*/205void setValues(int index, List<? extends Value> values, int srcIndex, int length)206throws InvalidTypeException,207ClassNotLoadedException;208}209210211