Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/jdi/ArrayReference.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* 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*/41@jdk.Exported42public interface ArrayReference extends ObjectReference {4344/**45* Returns the number of components in this array.46*47* @return the integer count of components in this array.48*/49int length();5051/**52* Returns an array component value.53*54* @param index the index of the component to retrieve55* @return the {@link Value} at the given index.56* @throws java.lang.IndexOutOfBoundsException if57* <CODE><I>index</I></CODE> is outside the range of this array,58* that is, if either of the following are true:59* <PRE>60* <I>index</I> < 061* <I>index</I> >= {@link #length() length()} </PRE>62*/63Value getValue(int index);6465/**66* Returns all of the components in this array.67*68* @return a list of {@link Value} objects, one for each array69* component ordered by array index. For zero length arrays,70* an empty list is returned.71*/72List<Value> getValues();7374/**75* Returns a range of array components.76*77* @param index the index of the first component to retrieve78* @param length the number of components to retrieve, or -1 to79* retrieve all components to the end of this array.80* @return a list of {@link Value} objects, one for each requested81* array component ordered by array index. When there are82* no elements in the specified range (e.g.83* <CODE><I>length</I></CODE> is zero) an empty list is returned84*85* @throws java.lang.IndexOutOfBoundsException if the range86* specified with <CODE><I>index</I></CODE> and87* <CODE><I>length</I></CODE> is not within the range of the array,88* that is, if either of the following are true:89* <PRE>90* <I>index</I> < 091* <I>index</I> > {@link #length() length()} </PRE>92* or if <CODE><I>length</I> != -1</CODE> and93* either of the following are true:94* <PRE>95* <I>length</I> < 096* <I>index</I> + <I>length</I> > {@link #length() length()}</PRE>97*/98List<Value> getValues(int index, int length);99100/**101* Replaces an array component with another value.102* <p>103* Object values must be assignment compatible with the component type104* (This implies that the component type must be loaded through the105* declaring class's class loader). Primitive values must be106* either assignment compatible with the component type or must be107* convertible to the component type without loss of information.108* See JLS section 5.2 for more information on assignment109* compatibility.110*111* @param value the new value112* @param index the index of the component to set113* @throws java.lang.IndexOutOfBoundsException if114* <CODE><I>index</I></CODE> is outside the range of this array,115* that is, if either of the following are true:116* <PRE>117* <I>index</I> < 0118* <I>index</I> >= {@link #length() length()} </PRE>119* @throws InvalidTypeException if the type of <CODE><I>value</I></CODE>120* is not compatible with the declared type of array components.121* @throws ClassNotLoadedException if the array component type122* has not yet been loaded123* through the appropriate class loader.124* @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.125*126* @see ArrayType#componentType()127*/128void setValue(int index, Value value)129throws InvalidTypeException,130ClassNotLoadedException;131132/**133* Replaces all array components with other values. If the given134* list is larger in size than the array, the values at the135* end of the list are ignored.136* <p>137* Object values must be assignment compatible with the element type138* (This implies that the component type must be loaded through the139* enclosing class's class loader). Primitive values must be140* either assignment compatible with the component type or must be141* convertible to the component type without loss of information.142* See JLS section 5.2 for more information on assignment143* compatibility.144*145* @param values a list of {@link Value} objects to be placed146* in this array. If <CODE><I>values</I>.size()</CODE> is147* less that the length of the array, the first148* <CODE><I>values</I>.size()</CODE> elements are set.149* @throws InvalidTypeException if any of the150* new <CODE><I>values</I></CODE>151* is not compatible with the declared type of array components.152* @throws ClassNotLoadedException if the array component153* type has not yet been loaded154* through the appropriate class loader.155* @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.156*157* @see ArrayType#componentType()158*/159void setValues(List<? extends Value> values)160throws InvalidTypeException,161ClassNotLoadedException;162163/**164* Replaces a range of array components with other values.165* <p>166* Object values must be assignment compatible with the component type167* (This implies that the component type must be loaded through the168* enclosing class's class loader). Primitive values must be169* either assignment compatible with the component type or must be170* convertible to the component type without loss of information.171* See JLS section 5.2 for more information on assignment172* compatibility.173*174* @param index the index of the first component to set.175* @param values a list of {@link Value} objects to be placed176* in this array.177* @param srcIndex the index of the first source value to use.178* @param length the number of components to set, or -1 to set179* all components to the end of this array or the end of180* <CODE><I>values</I></CODE> (whichever comes first).181* @throws InvalidTypeException if any element of182* <CODE><I>values</I></CODE>183* is not compatible with the declared type of array components.184* @throws java.lang.IndexOutOfBoundsException if the185* array range specified with186* <CODE><I>index</I></CODE> and <CODE><I>length</I></CODE>187* is not within the range of the array,188* or if the source range specified with189* <CODE><I>srcIndex</I></CODE> and <CODE><I>length</I></CODE>190* is not within <CODE><I>values</I></CODE>,191* that is, if any of the following are true:192* <PRE>193* <I>index</I> < 0194* <I>index</I> > {@link #length() length()}195* <I>srcIndex</I> < 0196* <I>srcIndex</I> > <I>values</I>.size() </PRE>197* or if <CODE><I>length</I> != -1</CODE> and any of the198* following are true:199* <PRE>200* <I>length</I> < 0201* <I>index</I> + <I>length</I> > {@link #length() length()}202* <I>srcIndex</I> + <I>length</I> > <I>values</I>.size() </PRE>203* @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.204* @see ArrayType#componentType()205*/206void setValues(int index, List<? extends Value> values, int srcIndex, int length)207throws InvalidTypeException,208ClassNotLoadedException;209}210211212