1 /*
   2  * Copyright (c) 1998, 2013, 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 public interface ArrayType extends ReferenceType {
  42 
  43     /**
  44      * Creates a new instance of this array class in the target VM.
  45      * The array is created with the given length and each component
  46      * is initialized to is standard default value.
  47      *
  48      * @param length the number of components in the new array
  49      * @return the newly created {@link ArrayReference} mirroring
  50      * the new object in the target VM.
  51      *
  52      * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
  53      */
  54     ArrayReference newInstance(int length);
  55 
  56     /**
  57      * Gets the JNI signature of the components of this
  58      * array class. The signature
  59      * describes the declared type of the components. If the components
  60      * are objects, their actual type in a particular run-time context
  61      * may be a subclass of the declared class.
  62      *
  63      * @return a string containing the JNI signature of array components.
  64      */
  65     String componentSignature();
  66 
  67     /**
  68      * Returns a text representation of the component
  69      * type of this array.
  70      *
  71      * @return a text representation of the component type.
  72      */
  73     String componentTypeName();
  74 
  75     /**
  76      * Returns the component type of this array,
  77      * as specified in the array declaration.
  78      * <P>
  79      * Note: The component type of a array will always be
  80      * created or loaded before the array - see
  81      * <cite>The Java&trade; Virtual Machine Specification</cite>,
  82      * section 5.3.3 - Creating Array Classes.
  83      * However, although the component type will be loaded it may
  84      * not yet be prepared, in which case the type will be returned
  85      * but attempts to perform some operations on the returned type
  86      * (e.g. {@link ReferenceType#fields() fields()}) will throw
  87      * a {@link ClassNotPreparedException}.
  88      * Use {@link ReferenceType#isPrepared()} to determine if
  89      * a reference type is prepared.
  90      *
  91      * @see Type
  92      * @see Field#type() Field.type() - for usage examples
  93      * @return the {@link Type} of this array's components.
  94      */
  95     Type componentType() throws ClassNotLoadedException;
  96 }