jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassType.java
author clanger
Fri, 16 Jun 2017 14:09:31 +0200
changeset 45564 0149773a140c
parent 45001 9526cc76a8ea
permissions -rw-r--r--
8181417: Code cleanups in com.sun.jdi Reviewed-by: alanb, stuefe, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
45001
9526cc76a8ea 8179538: Update jdk.jdi to be HTML-5 friendly
ksrini
parents: 34894
diff changeset
     2
 * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.jdi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * A mirror of a class in the target VM. A ClassType is a refinement
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * of {@link ReferenceType} that applies to true classes in the JLS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * sense of the definition (not an interface, not an array type). Any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * {@link ObjectReference} that mirrors an instance of such a class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * will have a ClassType as its type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @see ObjectReference
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @author Robert Field
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @author Gordon Hirsch
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @author James McIlree
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @since  1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
public interface ClassType extends ReferenceType {
45564
0149773a140c 8181417: Code cleanups in com.sun.jdi
clanger
parents: 45001
diff changeset
    45
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     * Gets the superclass of this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     * @return a {@link ClassType} that mirrors the superclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
     * of this class in the target VM. If no such class exists,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * returns null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    ClassType superclass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * Gets the interfaces directly implemented by this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * Only the interfaces that are declared with the "implements"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * keyword in this class are included.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @return a List of {@link InterfaceType} objects each mirroring
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * a direct interface this ClassType in the target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * If none exist, returns a zero length List.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @throws ClassNotPreparedException if this class not yet been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * prepared.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    List<InterfaceType> interfaces();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Gets the interfaces directly and indirectly implemented
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * by this class. Interfaces returned by {@link ClassType#interfaces}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * are returned as well all superinterfaces.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * @return a List of {@link InterfaceType} objects each mirroring
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * an interface of this ClassType in the target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * If none exist, returns a zero length List.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @throws ClassNotPreparedException if this class not yet been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * prepared.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    List<InterfaceType> allInterfaces();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Gets the currently loaded, direct subclasses of this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * No ordering of this list is guaranteed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @return a List of {@link ClassType} objects each mirroring a loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * subclass of this class in the target VM. If no such classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * exist, this method returns a zero-length list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    List<ClassType> subclasses();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * Determine if this class was declared as an enum.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @return <code>true</code> if this class was declared as an enum; false
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    boolean isEnum();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * Assigns a value to a static field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * The {@link Field} must be valid for this ClassType; that is,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * it must be from the mirrored object's class or a superclass of that class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * The field must not be final.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Object values must be assignment compatible with the field type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * (This implies that the field type must be loaded through the
24195
705325a63a58 8042123: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents: 24127
diff changeset
   106
     * enclosing class' class loader). Primitive values must be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * either assignment compatible with the field type or must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * convertible to the field type without loss of information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * See JLS section 5.2 for more information on assignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param field the field to set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param value the value to be assigned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @throws java.lang.IllegalArgumentException if the field is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * not static, the field is final, or the field does not exist
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * in this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @throws ClassNotLoadedException if the field type has not yet been loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * through the appropriate class loader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @throws InvalidTypeException if the value's type does not match
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * the field's declared type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    void setValue(Field field, Value value)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        throws InvalidTypeException, ClassNotLoadedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /** Perform method invocation with only the invoking thread resumed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    static final int INVOKE_SINGLE_THREADED = 0x1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * Invokes the specified static {@link Method} in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * target VM. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * specified method can be defined in this class,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * or in a superclass.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * The method must be a static method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * but not a static initializer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Use {@link ClassType#newInstance} to create a new object and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * run its constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * The method invocation will occur in the specified thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Method invocation can occur only if the specified thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * has been suspended by an event which occurred in that thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * Method invocation is not supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * when the target VM has been suspended through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * {@link VirtualMachine#suspend} or when the specified thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * is suspended through {@link ThreadReference#suspend}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * The specified method is invoked with the arguments in the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * argument list.  The method invocation is synchronous; this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * does not return until the invoked method returns in the target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * If the invoked method throws an exception, this method will throw
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * an {@link InvocationException} which contains a mirror to the exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * object thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Object arguments must be assignment compatible with the argument type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * (This implies that the argument type must be loaded through the
24195
705325a63a58 8042123: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents: 24127
diff changeset
   156
     * enclosing class' class loader). Primitive arguments must be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * either assignment compatible with the argument type or must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * convertible to the argument type without loss of information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * If the method being called accepts a variable number of arguments,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * then the last argument type is an array of some component type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * The argument in the matching position can be omitted, or can be null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * an array of the same component type, or an argument of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * component type followed by any number of other arguments of the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * type. If the argument is omitted, then a 0 length array of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * component type is passed.  The component type can be a primitive type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Autoboxing is not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *
9266
121fb370f179 7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents: 5506
diff changeset
   168
     * See Section 5.2 of
121fb370f179 7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents: 5506
diff changeset
   169
     * <cite>The Java&trade; Language Specification</cite>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * for more information on assignment compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * By default, all threads in the target VM are resumed while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * the method is being invoked if they were previously
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * suspended by an event or by {@link VirtualMachine#suspend} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * {@link ThreadReference#suspend}. This is done to prevent the deadlocks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * that will occur if any of the threads own monitors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * that will be needed by the invoked method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * Note, however, that this implicit resume acts exactly like
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * {@link ThreadReference#resume}, so if the thread's suspend
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * count is greater than 1, it will remain in a suspended state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * during the invocation and thus a deadlock could still occur.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * By default, when the invocation completes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * all threads in the target VM are suspended, regardless their state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * before the invocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * It is possible that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * breakpoints or other events might occur during the invocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * This can cause deadlocks as described above. It can also cause a deadlock
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * if invokeMethod is called from the client's event handler thread.  In this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * case, this thread will be waiting for the invokeMethod to complete and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * won't read the EventSet that comes in for the new event.  If this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * new EventSet is SUSPEND_ALL, then a deadlock will occur because no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * one will resume the EventSet.  To avoid this, all EventRequests should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * be disabled before doing the invokeMethod, or the invokeMethod should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * not be done from the client's event handler thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * The resumption of other threads during the invocation can be prevented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * by specifying the {@link #INVOKE_SINGLE_THREADED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * bit flag in the <code>options</code> argument; however,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * there is no protection against or recovery from the deadlocks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * described above, so this option should be used with great caution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * Only the specified thread will be resumed (as described for all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * threads above). Upon completion of a single threaded invoke, the invoking thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * will be suspended once again. Note that any threads started during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * the single threaded invocation will not be suspended when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * invocation completes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * If the target VM is disconnected during the invoke (for example, through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * {@link VirtualMachine#dispose}) the method invocation continues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @param thread the thread in which to invoke.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @param method the {@link Method} to invoke.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @param arguments the list of {@link Value} arguments bound to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * invoked method. Values from the list are assigned to arguments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * in the order they appear in the method signature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @param options the integer bit flag options.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @return a {@link Value} mirror of the invoked method's return value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * @throws java.lang.IllegalArgumentException if the method is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * a member of this class or a superclass, if the size of the argument list
24195
705325a63a58 8042123: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents: 24127
diff changeset
   219
     * does not match the number of declared arguments for the method, or
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * if the method is an initializer, constructor or static intializer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * @throws ClassNotLoadedException if any argument type has not yet been loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * through the appropriate class loader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @throws IncompatibleThreadStateException if the specified thread has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * been suspended by an event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @throws InvocationException if the method invocation resulted in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * an exception in the target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @throws InvalidTypeException If the arguments do not meet this requirement --
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *         Object arguments must be assignment compatible with the argument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *         type.  This implies that the argument type must be
24195
705325a63a58 8042123: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents: 24127
diff changeset
   230
     *         loaded through the enclosing class' class loader.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     *         Primitive arguments must be either assignment compatible with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     *         argument type or must be convertible to the argument type without loss
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     *         of information. See JLS section 5.2 for more information on assignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *         compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @throws VMCannotBeModifiedException if the VirtualMachine is read-only - see {@link VirtualMachine#canBeModified()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    Value invokeMethod(ThreadReference thread, Method method,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                       List<? extends Value> arguments, int options)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                                   throws InvalidTypeException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                                          ClassNotLoadedException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                                          IncompatibleThreadStateException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                                          InvocationException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * Constructs a new instance of this type, using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * the given constructor {@link Method} in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * target VM. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * specified constructor must be defined in this class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * Instance creation will occur in the specified thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * Instance creation can occur only if the specified thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * has been suspended by an event which occurred in that thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * Instance creation is not supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * when the target VM has been suspended through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * {@link VirtualMachine#suspend} or when the specified thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * is suspended through {@link ThreadReference#suspend}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * The specified constructor is invoked with the arguments in the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * argument list.  The invocation is synchronous; this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * does not return until the constructor returns in the target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * If the invoked method throws an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * exception, this method will throw an {@link InvocationException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * which contains a mirror to the exception object thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * Object arguments must be assignment compatible with the argument type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * (This implies that the argument type must be loaded through the
24195
705325a63a58 8042123: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents: 24127
diff changeset
   267
     * enclosing class' class loader). Primitive arguments must be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * either assignment compatible with the argument type or must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * convertible to the argument type without loss of information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * If the method being called accepts a variable number of arguments,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * then the last argument type is an array of some component type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * The argument in the matching position can be omitted, or can be null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * an array of the same component type, or an argument of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * component type, followed by any number of other arguments of the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * type. If the argument is omitted, then a 0 length array of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * component type is passed.  The component type can be a primitive type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * Autoboxing is not supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *
9266
121fb370f179 7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents: 5506
diff changeset
   279
     * See section 5.2 of
121fb370f179 7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents: 5506
diff changeset
   280
     * <cite>The Java&trade; Language Specification</cite>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * for more information on assignment compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * By default, all threads in the target VM are resumed while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * the method is being invoked if they were previously
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * suspended by an event or by {@link VirtualMachine#suspend} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * {@link ThreadReference#suspend}. This is done to prevent the deadlocks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * that will occur if any of the threads own monitors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * that will be needed by the invoked method. It is possible that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * breakpoints or other events might occur during the invocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * Note, however, that this implicit resume acts exactly like
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * {@link ThreadReference#resume}, so if the thread's suspend
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * count is greater than 1, it will remain in a suspended state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * during the invocation. By default, when the invocation completes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * all threads in the target VM are suspended, regardless their state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * before the invocation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * The resumption of other threads during the invocation can be prevented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * by specifying the {@link #INVOKE_SINGLE_THREADED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * bit flag in the <code>options</code> argument; however,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * there is no protection against or recovery from the deadlocks
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * described above, so this option should be used with great caution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Only the specified thread will be resumed (as described for all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * threads above). Upon completion of a single threaded invoke, the invoking thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * will be suspended once again. Note that any threads started during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * the single threaded invocation will not be suspended when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * invocation completes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * If the target VM is disconnected during the invoke (for example, through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * {@link VirtualMachine#dispose}) the method invocation continues.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * @param thread the thread in which to invoke.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * @param method the constructor {@link Method} to invoke.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @param arguments the list of {@link Value} arguments bound to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * invoked constructor. Values from the list are assigned to arguments
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * in the order they appear in the constructor signature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @param options the integer bit flag options.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @return an {@link ObjectReference} mirror of the newly created
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @throws java.lang.IllegalArgumentException if the method is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * a member of this class, if the size of the argument list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * does not match the number of declared arguments for the constructor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * or if the method is not a constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @throws ClassNotLoadedException if any argument type has not yet been loaded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * through the appropriate class loader.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @throws IncompatibleThreadStateException if the specified thread has not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * been suspended by an event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @throws InvocationException if the method invocation resulted in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * an exception in the target VM.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @throws InvalidTypeException If the arguments do not meet this requirement --
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *         Object arguments must be assignment compatible with the argument
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *         type.  This implies that the argument type must be
24195
705325a63a58 8042123: Support default and static interface methods in JDI, JDWP and JDB
jbachorik
parents: 24127
diff changeset
   332
     *         loaded through the enclosing class' class loader.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *         Primitive arguments must be either assignment compatible with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *         argument type or must be convertible to the argument type without loss
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *         of information. See JLS section 5.2 for more information on assignment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     *         compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * @throws VMCannotBeModifiedException if the VirtualMachine is read-only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * - see {@link VirtualMachine#canBeModified()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    ObjectReference newInstance(ThreadReference thread, Method method,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                                List<? extends Value> arguments, int options)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                                   throws InvalidTypeException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                                          ClassNotLoadedException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                                          IncompatibleThreadStateException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                                          InvocationException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * Returns a the single non-abstract {@link Method} visible from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * this class that has the given name and signature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * See {@link ReferenceType#methodsByName(java.lang.String, java.lang.String)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * for information on signature format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * The returned method (if non-null) is a component of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * {@link ClassType}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @see ReferenceType#visibleMethods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * @see ReferenceType#methodsByName(java.lang.String name)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @see ReferenceType#methodsByName(java.lang.String name, java.lang.String signature)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @param name the name of the method to find.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * @param signature the signature of the method to find
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @return the {@link Method} that matches the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * name and signature or <code>null</code> if there is no match.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * @throws ClassNotPreparedException if methods are not yet available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * because the class has not yet been prepared.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    Method concreteMethodByName(String name, String signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
}