jdk/src/share/back/ReferenceTypeImpl.c
author ohair
Fri, 22 Aug 2008 12:24:27 -0700
changeset 1090 c5805b1672a6
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6732421: Removed old javavm and Classic VM files from the jdk7 sources Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2005 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include "util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "ReferenceTypeImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "inStream.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "outStream.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
signature(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    char *signature = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    clazz = inStream_readClassRef(getEnv(), in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    error = classSignature(clazz, &signature, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    (void)outStream_writeString(out, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    jvmtiDeallocate(signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
signatureWithGeneric(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
  /* Returns both the signature and the generic signature */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    char *signature = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    char *genericSignature = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    clazz = inStream_readClassRef(getEnv(), in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    error = classSignature(clazz, &signature, &genericSignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    (void)outStream_writeString(out, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    writeGenericSignature(out, genericSignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    jvmtiDeallocate(signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    if (genericSignature != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
      jvmtiDeallocate(genericSignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
getClassLoader(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    jobject loader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    clazz = inStream_readClassRef(env, in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    error = classLoader(clazz, &loader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    (void)outStream_writeObjectRef(env, out, loader);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
modifiers(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    jint modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    clazz = inStream_readClassRef(getEnv(), in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    error = JVMTI_FUNC_PTR(gdata->jvmti,GetClassModifiers)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                (gdata->jvmti, clazz, &modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    (void)outStream_writeInt(out, modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
writeMethodInfo(PacketOutputStream *out, jclass clazz, jmethodID method,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                int outputGenerics)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    char *name = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    char *signature = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    char *genericSignature = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    jint modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    jboolean isSynthetic;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    error = isMethodSynthetic(method, &isSynthetic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    error = methodModifiers(method, &modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    error = methodSignature(method, &name, &signature, &genericSignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    if (isSynthetic) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        modifiers |= MOD_SYNTHETIC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    (void)outStream_writeMethodID(out, method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    (void)outStream_writeString(out, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    (void)outStream_writeString(out, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    if (outputGenerics == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        writeGenericSignature(out, genericSignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    (void)outStream_writeInt(out, modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    jvmtiDeallocate(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    jvmtiDeallocate(signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    if (genericSignature != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
      jvmtiDeallocate(genericSignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
methods1(PacketInputStream *in, PacketOutputStream *out,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
         int outputGenerics)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    jint methodCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    jmethodID *methods = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    clazz = inStream_readClassRef(getEnv(), in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    error = JVMTI_FUNC_PTR(gdata->jvmti,GetClassMethods)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                (gdata->jvmti, clazz, &methodCount, &methods);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    (void)outStream_writeInt(out, methodCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    for (i = 0; (i < methodCount) && !outStream_error(out); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        writeMethodInfo(out, clazz, methods[i], outputGenerics);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /* Free methods array */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    if ( methods != NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        jvmtiDeallocate(methods);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
methods(PacketInputStream *in, PacketOutputStream *out,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
         int outputGenerics)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    return methods1(in, out, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
methodsWithGeneric(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    return methods1(in, out, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
instances(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    jint maxInstances;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    if (gdata->vmDead) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        outStream_setError(out, JDWP_ERROR(VM_DEAD));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    clazz = inStream_readClassRef(env, in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    maxInstances = inStream_readInt(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    WITH_LOCAL_REFS(env, 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        jvmtiError   error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        ObjectBatch  batch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        error = classInstances(clazz, &batch, maxInstances);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            int kk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            jbyte typeKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            (void)outStream_writeInt(out, batch.count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            if (batch.count > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                 * They are all instances of this class and will all have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                 * the same typeKey, so just compute it once.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                typeKey = specificTypeKey(env, batch.objects[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                for (kk = 0; kk < batch.count; kk++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                  jobject inst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                  inst = batch.objects[kk];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                  (void)outStream_writeByte(out, typeKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                  (void)outStream_writeObjectRef(env, out, inst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            jvmtiDeallocate(batch.objects);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    } END_WITH_LOCAL_REFS(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
getClassVersion(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    jint majorVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    jint minorVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    clazz = inStream_readClassRef(getEnv(), in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    error = JVMTI_FUNC_PTR(gdata->jvmti, GetClassVersionNumbers)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                (gdata->jvmti, clazz, &minorVersion, &majorVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    (void)outStream_writeInt(out, majorVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    (void)outStream_writeInt(out, minorVersion);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
getConstantPool(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    jint cpCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    jint cpByteCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    unsigned char* cpBytesPtr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    clazz = inStream_readClassRef(getEnv(), in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    /* Initialize assuming no bytecodes and no error */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    error         = JVMTI_ERROR_NONE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    cpCount       = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    cpByteCount   = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    cpBytesPtr    = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    error = JVMTI_FUNC_PTR(gdata->jvmti,GetConstantPool)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                (gdata->jvmti, clazz, &cpCount, &cpByteCount, &cpBytesPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        (void)outStream_writeInt(out, cpCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        (void)outStream_writeByteArray(out, cpByteCount, (jbyte *)cpBytesPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        jvmtiDeallocate(cpBytesPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
writeFieldInfo(PacketOutputStream *out, jclass clazz, jfieldID fieldID,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
               int outputGenerics)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    char *name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    char *signature = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    char *genericSignature = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    jint modifiers;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    jboolean isSynthetic;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    error = isFieldSynthetic(clazz, fieldID, &isSynthetic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    error = fieldModifiers(clazz, fieldID, &modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    error = fieldSignature(clazz, fieldID, &name, &signature, &genericSignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    if (isSynthetic) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        modifiers |= MOD_SYNTHETIC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    (void)outStream_writeFieldID(out, fieldID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    (void)outStream_writeString(out, name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    (void)outStream_writeString(out, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
    if (outputGenerics == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        writeGenericSignature(out, genericSignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    (void)outStream_writeInt(out, modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    jvmtiDeallocate(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    jvmtiDeallocate(signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    if (genericSignature != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
      jvmtiDeallocate(genericSignature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
fields1(PacketInputStream *in, PacketOutputStream *out, int outputGenerics)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    jint fieldCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    jfieldID *fields = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    clazz = inStream_readClassRef(getEnv(), in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    error = JVMTI_FUNC_PTR(gdata->jvmti,GetClassFields)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                (gdata->jvmti, clazz, &fieldCount, &fields);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    (void)outStream_writeInt(out, fieldCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    for (i = 0; (i < fieldCount) && !outStream_error(out); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        writeFieldInfo(out, clazz, fields[i], outputGenerics);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    /* Free fields array */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    if ( fields != NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        jvmtiDeallocate(fields);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
fields(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    return fields1(in, out, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
fieldsWithGeneric(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    return fields1(in, out, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
getValues(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    sharedGetFieldValues(in, out, JNI_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
sourceFile(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    char *fileName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    clazz = inStream_readClassRef(getEnv(), in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    error = JVMTI_FUNC_PTR(gdata->jvmti,GetSourceFileName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                (gdata->jvmti, clazz, &fileName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    (void)outStream_writeString(out, fileName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    jvmtiDeallocate(fileName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
sourceDebugExtension(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    char *extension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    clazz = inStream_readClassRef(getEnv(), in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    error = getSourceDebugExtension(clazz, &extension);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    (void)outStream_writeString(out, extension);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    jvmtiDeallocate(extension);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
nestedTypes(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    clazz = inStream_readClassRef(env, in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    WITH_LOCAL_REFS(env, 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        jint count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        jclass *nested;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        error = allNestedClasses(clazz, &nested, &count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            (void)outStream_writeInt(out, count);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
            for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
                (void)outStream_writeByte(out, referenceTypeTag(nested[i]));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                (void)outStream_writeObjectRef(env, out, nested[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            if ( nested != NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
                jvmtiDeallocate(nested);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    } END_WITH_LOCAL_REFS(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
getClassStatus(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    jint status;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    clazz = inStream_readClassRef(getEnv(), in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    status = classStatus(clazz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    (void)outStream_writeInt(out, map2jdwpClassStatus(status));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
interfaces(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    clazz = inStream_readClassRef(env, in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    WITH_LOCAL_REFS(env, 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        jint interfaceCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        jclass *interfaces;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        error = allInterfaces(clazz, &interfaces, &interfaceCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            outStream_setError(out, map2jdwpError(error));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
            int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
            (void)outStream_writeInt(out, interfaceCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            for (i = 0; i < interfaceCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                (void)outStream_writeObjectRef(env, out, interfaces[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            if ( interfaces != NULL ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                jvmtiDeallocate(interfaces);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    } END_WITH_LOCAL_REFS(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
classObject(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    clazz = inStream_readClassRef(env, in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * In our implementation, the reference type id is the same as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * class object id, so we bounce it right back.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    (void)outStream_writeObjectRef(env, out, clazz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
void *ReferenceType_Cmds[] = { (void *)18
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    ,(void *)signature
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    ,(void *)getClassLoader
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    ,(void *)modifiers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    ,(void *)fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    ,(void *)methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    ,(void *)getValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    ,(void *)sourceFile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    ,(void *)nestedTypes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    ,(void *)getClassStatus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    ,(void *)interfaces
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    ,(void *)classObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    ,(void *)sourceDebugExtension
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    ,(void *)signatureWithGeneric
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    ,(void *)fieldsWithGeneric
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    ,(void *)methodsWithGeneric
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    ,(void *)instances
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    ,(void *)getClassVersion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    ,(void *)getConstantPool
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
};