jdk/src/share/back/ClassTypeImpl.c
author jmasa
Fri, 08 Apr 2011 14:53:16 -0700
changeset 9180 987b51bab2e2
parent 5506 202f599c92aa
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1998, 2005, 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
#include "util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "ClassTypeImpl.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
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
superclass(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    clazz = inStream_readClassRef(env, 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
    WITH_LOCAL_REFS(env, 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        jclass superclass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        superclass = JNI_FUNC_PTR(env,GetSuperclass)(env,clazz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        (void)outStream_writeObjectRef(env, out, superclass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    } END_WITH_LOCAL_REFS(env);
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 jdwpError
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
readStaticFieldValue(JNIEnv *env, PacketInputStream *in, jclass clazz,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                     jfieldID field, char *signature)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    jvalue value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    jdwpError serror = JDWP_ERROR(NONE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    switch (signature[0]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        case JDWP_TAG(ARRAY):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        case JDWP_TAG(OBJECT):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
            value.l = inStream_readObjectRef(env, in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
            JNI_FUNC_PTR(env,SetStaticObjectField)(env, clazz, field, value.l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        case JDWP_TAG(BYTE):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            value.b = inStream_readByte(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            JNI_FUNC_PTR(env,SetStaticByteField)(env, clazz, field, value.b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        case JDWP_TAG(CHAR):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
            value.c = inStream_readChar(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            JNI_FUNC_PTR(env,SetStaticCharField)(env, clazz, field, value.c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        case JDWP_TAG(FLOAT):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            value.f = inStream_readFloat(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
            JNI_FUNC_PTR(env,SetStaticFloatField)(env, clazz, field, value.f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        case JDWP_TAG(DOUBLE):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            value.d = inStream_readDouble(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            JNI_FUNC_PTR(env,SetStaticDoubleField)(env, clazz, field, value.d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        case JDWP_TAG(INT):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            value.i = inStream_readInt(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            JNI_FUNC_PTR(env,SetStaticIntField)(env, clazz, field, value.i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        case JDWP_TAG(LONG):
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            value.j = inStream_readLong(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            JNI_FUNC_PTR(env,SetStaticLongField)(env, clazz, field, value.j);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        case JDWP_TAG(SHORT):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            value.s = inStream_readShort(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            JNI_FUNC_PTR(env,SetStaticShortField)(env, clazz, field, value.s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        case JDWP_TAG(BOOLEAN):
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            value.z = inStream_readBoolean(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            JNI_FUNC_PTR(env,SetStaticBooleanField)(env, clazz, field, value.z);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        serror = JDWP_ERROR(INTERNAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    return serror;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
setValues(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    JNIEnv *env;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    jint count;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    jclass clazz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    env = getEnv();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    clazz = inStream_readClassRef(env, in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    count = inStream_readInt(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    WITH_LOCAL_REFS(env, count) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        for (i = 0; i < count; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            jfieldID field;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            char *signature = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            jvmtiError error;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            jdwpError serror;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            field = inStream_readFieldID(in);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            if (inStream_error(in)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                break;
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 = fieldSignature(clazz, field, NULL, &signature, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            if (error != JVMTI_ERROR_NONE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            serror = readStaticFieldValue(env, in, clazz, field, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            jvmtiDeallocate(signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            if ( serror != JDWP_ERROR(NONE) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    } END_WITH_LOCAL_REFS(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
static jboolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
invokeStatic(PacketInputStream *in, PacketOutputStream *out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    return sharedInvoke(in, out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
void *ClassType_Cmds[] = { (void *)0x4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    ,(void *)superclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    ,(void *)setValues
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    ,(void *)invokeStatic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    ,(void *)invokeStatic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
};