arrayreferenceimpl.c

来自「This is a resource based on j2me embedde」· C语言 代码 · 共 595 行 · 第 1/2 页

C
595
字号
                    writeFloatComponents(env, out, array, index, length);                    break;                        case JDWP_TAG(DOUBLE):                    writeDoubleComponents(env, out, array, index, length);                    break;                        case JDWP_TAG(INT):                    writeIntComponents(env, out, array, index, length);                    break;                        case JDWP_TAG(LONG):                    writeLongComponents(env, out, array, index, length);                    break;                        case JDWP_TAG(SHORT):                    writeShortComponents(env, out, array, index, length);                    break;                        case JDWP_TAG(BOOLEAN):                    writeBooleanComponents(env, out, array, index, length);                    break;                        default:                    outStream_setError(out, JDWP_ERROR(INVALID_TAG));                    break;            }        }        jvmtiDeallocate(signature);    err:;    } END_WITH_LOCAL_REFS(env);    if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {        outStream_setError(out, JDWP_ERROR(INTERNAL));        JNI_FUNC_PTR(env,ExceptionClear)(env);    }     return JNI_TRUE;}static jdwpError readBooleanComponents(JNIEnv *env, PacketInputStream *in,                    jarray array, int index, int length){    int i;    jboolean component;    for (i = 0; (i < length) && !inStream_error(in); i++) {        component = inStream_readBoolean(in);        JNI_FUNC_PTR(env,SetBooleanArrayRegion)(env, array, index + i, 1, &component);    }    return inStream_error(in);}static jdwpError readByteComponents(JNIEnv *env, PacketInputStream *in,                    jarray array, int index, int length){    int i;    jbyte component;    for (i = 0; (i < length) && !inStream_error(in); i++) {        component = inStream_readByte(in);        JNI_FUNC_PTR(env,SetByteArrayRegion)(env, array, index + i, 1, &component);    }    return inStream_error(in);}static jdwpError readCharComponents(JNIEnv *env, PacketInputStream *in,                    jarray array, int index, int length){    int i;    jchar component;    for (i = 0; (i < length) && !inStream_error(in); i++) {        component = inStream_readChar(in);        JNI_FUNC_PTR(env,SetCharArrayRegion)(env, array, index + i, 1, &component);    }    return inStream_error(in);}static jdwpError readShortComponents(JNIEnv *env, PacketInputStream *in,                    jarray array, int index, int length){    int i;    jshort component;    for (i = 0; (i < length) && !inStream_error(in); i++) {        component = inStream_readShort(in);        JNI_FUNC_PTR(env,SetShortArrayRegion)(env, array, index + i, 1, &component);    }    return inStream_error(in);}static jdwpError readIntComponents(JNIEnv *env, PacketInputStream *in,                    jarray array, int index, int length){    int i;    jint component;    for (i = 0; (i < length) && !inStream_error(in); i++) {        component = inStream_readInt(in);        JNI_FUNC_PTR(env,SetIntArrayRegion)(env, array, index + i, 1, &component);    }    return inStream_error(in);}static jdwpError readLongComponents(JNIEnv *env, PacketInputStream *in,                    jarray array, int index, int length){    int i;    jlong component;    for (i = 0; (i < length) && !inStream_error(in); i++) {        component = inStream_readLong(in);        JNI_FUNC_PTR(env,SetLongArrayRegion)(env, array, index + i, 1, &component);    }    return inStream_error(in);}static jdwpError readFloatComponents(JNIEnv *env, PacketInputStream *in,                    jarray array, int index, int length){    int i;    jfloat component;    for (i = 0; (i < length) && !inStream_error(in); i++) {        component = inStream_readFloat(in);        JNI_FUNC_PTR(env,SetFloatArrayRegion)(env, array, index + i, 1, &component);    }    return inStream_error(in);}static jdwpError readDoubleComponents(JNIEnv *env, PacketInputStream *in,                    jarray array, int index, int length){    int i;    jdouble component;    for (i = 0; (i < length) && !inStream_error(in); i++) {        component = inStream_readDouble(in);        JNI_FUNC_PTR(env,SetDoubleArrayRegion)(env, array, index + i, 1, &component);    }    return inStream_error(in);}static jdwpError readObjectComponents(JNIEnv *env, PacketInputStream *in,                    jarray array, int index, int length)                   /* char *componentSignature) */{    int i;    for (i = 0; i < length; i++) {        jobject object = inStream_readObjectRef(env, in);        JNI_FUNC_PTR(env,SetObjectArrayElement)(env, array, index + i, object);        if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {            /* caller will clear */            break;        }    }    return JDWP_ERROR(NONE);}static jboolean setValues(PacketInputStream *in, PacketOutputStream *out){    JNIEnv *env = getEnv();    jdwpError serror = JDWP_ERROR(NONE);    int arrayLength;    jarray array;    jint index;    jint length;        array = inStream_readArrayRef(env, in);    if (inStream_error(in)) {        return JNI_TRUE;    }    index = inStream_readInt(in);    if (inStream_error(in)) {        return JNI_TRUE;    }    length = inStream_readInt(in);    if (inStream_error(in)) {        return JNI_TRUE;    }        arrayLength = JNI_FUNC_PTR(env,GetArrayLength)(env, array);    if ((index < 0) || (index > arrayLength - 1)) {        outStream_setError(out, JDWP_ERROR(INVALID_INDEX));        return JNI_TRUE;    }    if ((length < 0) || (length + index > arrayLength)) {        outStream_setError(out, JDWP_ERROR(INVALID_LENGTH));        return JNI_TRUE;    }    WITH_LOCAL_REFS(env, 1)  {        jclass arrayClass;        char *signature = NULL;        char *componentSignature;        jvmtiError error;                arrayClass = JNI_FUNC_PTR(env,GetObjectClass)(env, array);        error = classSignature(arrayClass, &signature, NULL);        if (error != JVMTI_ERROR_NONE) {            goto err;        }        componentSignature = &signature[1];        switch (componentSignature[0]) {            case JDWP_TAG(OBJECT):            case JDWP_TAG(ARRAY):                serror = readObjectComponents(env, in, array, index, length);                break;            case JDWP_TAG(BYTE):                serror = readByteComponents(env, in, array, index, length);                break;            case JDWP_TAG(CHAR):                serror = readCharComponents(env, in, array, index, length);                break;            case JDWP_TAG(FLOAT):                serror = readFloatComponents(env, in, array, index, length);                break;            case JDWP_TAG(DOUBLE):                serror = readDoubleComponents(env, in, array, index, length);                break;            case JDWP_TAG(INT):                serror = readIntComponents(env, in, array, index, length);                break;            case JDWP_TAG(LONG):                serror = readLongComponents(env, in, array, index, length);                break;            case JDWP_TAG(SHORT):                serror = readShortComponents(env, in, array, index, length);                break;            case JDWP_TAG(BOOLEAN):                serror = readBooleanComponents(env, in, array, index, length);                break;            default:                {                    ERROR_MESSAGE(("Invalid array component signature: %s",                                        componentSignature));                    EXIT_ERROR(AGENT_ERROR_INVALID_OBJECT,NULL);                }                break;        }        jvmtiDeallocate(signature);    err:;    } END_WITH_LOCAL_REFS(env);    if (JNI_FUNC_PTR(env,ExceptionOccurred)(env)) {        /*         * TO DO: Check exception type         */        serror = JDWP_ERROR(TYPE_MISMATCH);        JNI_FUNC_PTR(env,ExceptionClear)(env);    }    outStream_setError(out, serror);    return JNI_TRUE;}void *ArrayReference_Cmds[] = { (void *)0x3    ,(void *)length    ,(void *)getValues    ,(void *)setValues};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?