1 /*
   2  * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.jdi;
  27 
  28 import java.util.List;
  29 
  30 /**
  31  * Provides access to the class of an array and the type of
  32  * its components in the target VM.
  33  *
  34  * @see ArrayReference
  35  *
  36  * @author Robert Field
  37  * @author Gordon Hirsch
  38  * @author James McIlree
  39  * @since  1.3
  40  */
  41 @jdk.Supported
  42 public interface ArrayType extends ReferenceType {
  43 
  44     /**
  45      * Creates a new instance of this array class in the target VM.
  46      * The array is created with the given length and each component
  47      * is initialized to is standard default value.
  48      *
  49      * @param length the number of components in the new array
  50      * @return the newly created {@link ArrayReference} mirroring
  51      * the new object in the target VM.
  52      *
  53      * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
  54      */
  55     ArrayReference newInstance(int length);
  56 
  57     /**
  58      * Gets the JNI signature of the components of this
  59      * array class. The signature
  60      * describes the declared type of the components. If the components
  61      * are objects, their actual type in a particular run-time context
  62      * may be a subclass of the declared class.
  63      *
  64      * @return a string containing the JNI signature of array components.
  65      */
  66     String componentSignature();
  67 
  68     /**
  69      * Returns a text representation of the component
  70      * type of this array.
  71      *
  72      * @return a text representation of the component type.
  73      */
  74     String componentTypeName();
  75 
  76     /**
  77      * Returns the component type of this array,
  78      * as specified in the array declaration.
  79      * <P>
  80      * Note: The component type of a array will always be
  81      * created or loaded before the array - see
  82      * <cite>The Java&trade; Virtual Machine Specification</cite>,
  83      * section 5.3.3 - Creating Array Classes.
  84      * However, although the component type will be loaded it may
  85      * not yet be prepared, in which case the type will be returned
  86      * but attempts to perform some operations on the returned type
  87      * (e.g. {@link ReferenceType#fields() fields()}) will throw
  88      * a {@link ClassNotPreparedException}.
  89      * Use {@link ReferenceType#isPrepared()} to determine if
  90      * a reference type is prepared.
  91      *
  92      * @see Type
  93      * @see Field#type() Field.type() - for usage examples
  94      * @return the {@link Type} of this array's components.
  95      */
  96     Type componentType() throws ClassNotLoadedException;
  97 }