diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:14 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:14 -0800 |
commit | 1c0fed63c71ddb230f3b304aac12caffbedf2f21 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /luni/src/main/native/java_io_ObjectInputStream.c | |
parent | 2fb02ef3025449e24e756a7f645ea6eab7a1fd4f (diff) | |
download | libcore-1c0fed63c71ddb230f3b304aac12caffbedf2f21.zip libcore-1c0fed63c71ddb230f3b304aac12caffbedf2f21.tar.gz libcore-1c0fed63c71ddb230f3b304aac12caffbedf2f21.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'luni/src/main/native/java_io_ObjectInputStream.c')
-rw-r--r-- | luni/src/main/native/java_io_ObjectInputStream.c | 287 |
1 files changed, 0 insertions, 287 deletions
diff --git a/luni/src/main/native/java_io_ObjectInputStream.c b/luni/src/main/native/java_io_ObjectInputStream.c deleted file mode 100644 index 3519055..0000000 --- a/luni/src/main/native/java_io_ObjectInputStream.c +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "JNIHelp.h" -#include "AndroidSystemNatives.h" - -static void java_setFieldBool (JNIEnv * env, jclass clazz, - jobject targetObject, - jclass declaringClass, - jstring fieldName, - jboolean newValue) { - const char *fieldNameInC; - jfieldID fid; - if(targetObject == NULL) { - return; - } - fieldNameInC = (*env)->GetStringUTFChars(env, fieldName, NULL); - fid = (*env)->GetFieldID(env, declaringClass, fieldNameInC, "Z"); - (*env)->ReleaseStringUTFChars(env, fieldName, fieldNameInC); - - /* - * Two options now. Maybe getFieldID caused an exception, - * or maybe it returned the real value - */ - if(fid != 0) { - (*env)->SetBooleanField(env, targetObject, fid, newValue); - } -} - -static void java_setFieldChar (JNIEnv * env, jclass clazz, - jobject targetObject, - jclass declaringClass, - jstring fieldName, - jchar newValue) { - const char *fieldNameInC; - jfieldID fid; - if(targetObject == NULL) { - return; - } - fieldNameInC = (*env)->GetStringUTFChars(env, fieldName, NULL); - fid = (*env)->GetFieldID(env, declaringClass, fieldNameInC, "C"); - (*env)->ReleaseStringUTFChars(env, fieldName, fieldNameInC); - - /* - * Two options now. Maybe getFieldID caused an exception, - * or maybe it returned the real value - */ - if(fid != 0) { - (*env)->SetCharField(env, targetObject, fid, newValue); - } -} - -static void java_setFieldInt (JNIEnv * env, jclass clazz, - jobject targetObject, - jclass declaringClass, - jstring fieldName, - jint newValue) { - const char *fieldNameInC; - jfieldID fid; - if(targetObject == NULL) { - return; - } - fieldNameInC = (*env)->GetStringUTFChars(env, fieldName, NULL); - fid = (*env)->GetFieldID(env, declaringClass, fieldNameInC, "I"); - (*env)->ReleaseStringUTFChars(env, fieldName, fieldNameInC); - - /* - * Two options now. Maybe getFieldID caused an exception, - * or maybe it returned the real value - */ - if(fid != 0) { - (*env)->SetIntField(env, targetObject, fid, newValue); - } -} - -static void java_setFieldFloat (JNIEnv * env, jclass clazz, - jobject targetObject, - jclass declaringClass, - jstring fieldName, - jfloat newValue) { - const char *fieldNameInC; - jfieldID fid; - if(targetObject == NULL) { - return; - } - fieldNameInC = (*env)->GetStringUTFChars(env, fieldName, NULL); - fid = (*env)->GetFieldID(env, declaringClass, fieldNameInC, "F"); - (*env)->ReleaseStringUTFChars(env, fieldName, fieldNameInC); - - /* - * Two options now. Maybe getFieldID caused an exception, - * or maybe it returned the real value - */ - if(fid != 0) { - (*env)->SetFloatField(env, targetObject, fid, newValue); - } -} - -static void java_setFieldDouble (JNIEnv * env, jclass clazz, - jobject targetObject, - jclass declaringClass, - jstring fieldName, - jdouble newValue) { - const char *fieldNameInC; - jfieldID fid; - if(targetObject == NULL) { - return; - } - fieldNameInC = (*env)->GetStringUTFChars(env, fieldName, NULL); - fid = (*env)->GetFieldID(env, declaringClass, fieldNameInC, "D"); - (*env)->ReleaseStringUTFChars(env, fieldName, fieldNameInC); - - /* - * Two options now. Maybe getFieldID caused an exception, - * or maybe it returned the real value - */ - if(fid != 0) { - (*env)->SetDoubleField(env, targetObject, fid, newValue); - } - -} - -static void java_setFieldShort (JNIEnv * env, jclass clazz, - jobject targetObject, - jclass declaringClass, - jstring fieldName, - jshort newValue) { - const char *fieldNameInC; - jfieldID fid; - if(targetObject == NULL) { - return; - } - fieldNameInC = (*env)->GetStringUTFChars(env, fieldName, NULL); - fid = (*env)->GetFieldID(env, declaringClass, fieldNameInC, "S"); - (*env)->ReleaseStringUTFChars(env, fieldName, fieldNameInC); - - /* - * Two options now. Maybe getFieldID caused an exception, - * or maybe it returned the real value - */ - if(fid != 0) { - (*env)->SetShortField(env, targetObject, fid, newValue); - } - -} - -static void java_setFieldLong (JNIEnv * env, jclass clazz, - jobject targetObject, - jclass declaringClass, - jstring fieldName, - jlong newValue) { - const char *fieldNameInC; - jfieldID fid; - if(targetObject == NULL) { - return; - } - fieldNameInC = (*env)->GetStringUTFChars(env, fieldName, NULL); - fid = (*env)->GetFieldID(env, declaringClass, fieldNameInC, "J"); - (*env)->ReleaseStringUTFChars(env, fieldName, fieldNameInC); - - /* - * Two options now. Maybe getFieldID caused an exception, - * or maybe it returned the real value - */ - if(fid != 0) { - (*env)->SetLongField(env, targetObject, fid, newValue); - } -} - -static jobject java_newInstance (JNIEnv * env, jclass clazz, - jclass instantiationClass, - jclass constructorClass) { - jmethodID mid = - (*env)->GetMethodID(env, constructorClass, "<init>", "()V"); - - if(mid == 0) { - /* Cant newInstance,No empty constructor... */ - return (jobject) 0; - } else { - /* Instantiate an object of a given class */ - return (jobject) (*env)->NewObject(env, instantiationClass, mid); - } - -} - -static void java_setFieldByte (JNIEnv * env, jclass clazz, - jobject targetObject, - jclass declaringClass, - jstring fieldName, - jbyte newValue){ - const char *fieldNameInC; - jfieldID fid; - if(targetObject == NULL) { - return; - } - fieldNameInC = (*env)->GetStringUTFChars(env, fieldName, NULL); - fid = (*env)->GetFieldID(env, declaringClass, fieldNameInC, "B"); - (*env)->ReleaseStringUTFChars(env, fieldName, fieldNameInC); - - /* Two options now. Maybe getFieldID caused an exception, or maybe it returned the real value */ - if(fid != 0) { - (*env)->SetByteField(env, targetObject, fid, newValue); - } -} - -static void java_setFieldObj (JNIEnv * env, jclass clazz, - jobject targetObject, - jclass declaringClass, - jstring fieldName, - jstring fieldTypeName, - jobject newValue) { - const char *fieldNameInC, *fieldTypeNameInC; - jfieldID fid; - if(targetObject == NULL) { - return; - } - fieldNameInC = (*env)->GetStringUTFChars(env, fieldName, NULL); - fieldTypeNameInC = (*env)->GetStringUTFChars(env, fieldTypeName, NULL); - fid = (*env)->GetFieldID(env, declaringClass, - fieldNameInC, fieldTypeNameInC); - (*env)->ReleaseStringUTFChars(env, fieldName, fieldNameInC); - (*env)->ReleaseStringUTFChars(env, fieldTypeName, fieldTypeNameInC); - - /* - * Two options now. Maybe getFieldID caused an exception, - * or maybe it returned the real value - */ - if(fid != 0) { - (*env)->SetObjectField(env, targetObject, fid, newValue); - } -} - -/* - * JNI registration - */ -static JNINativeMethod gMethods[] = { - /* name, signature, funcPtr */ - { "setField", - "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;J)V", - (void*) java_setFieldLong }, - { "setField", - "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;S)V", - (void*) java_setFieldShort }, - { "setField", - "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;D)V", - (void*) java_setFieldDouble }, - { "setField", - "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Z)V", - (void*) java_setFieldBool }, - { "setField", - "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;B)V", - (void*) java_setFieldByte }, - { "setField", - "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;F)V", - (void*) java_setFieldFloat }, - { "setField", - "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;C)V", - (void*) java_setFieldChar }, - { "setField", - "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;I)V", - (void*) java_setFieldInt }, - { "newInstance", - "(Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/Object;", - (void*) java_newInstance }, - { "objSetField", - "(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V", - (void*) java_setFieldObj } - -}; -int register_java_io_ObjectInputStream(JNIEnv* env) { - return jniRegisterNativeMethods(env, "java/io/ObjectInputStream", - gMethods, NELEM(gMethods)); -} |