HADOOP-13504. Refactor jni_common to conform to C89 restrictions imposed by Visual Studio 2010. Contributed by Sammi Chen

This commit is contained in:
Kai Zheng 2016-08-19 11:18:15 +08:00
parent c5c3e81b49
commit dbcaf999d9
1 changed files with 10 additions and 5 deletions

View File

@ -43,21 +43,26 @@ void setCoder(JNIEnv* env, jobject thiz, IsalCoder* pCoder) {
} }
IsalCoder* getCoder(JNIEnv* env, jobject thiz) { IsalCoder* getCoder(JNIEnv* env, jobject thiz) {
jclass clazz = (*env)->GetObjectClass(env, thiz); jclass clazz;
jmethodID mid;
jboolean verbose;
jfieldID fid;
IsalCoder* pCoder;
jmethodID mid = (*env)->GetMethodID(env, clazz, "allowVerboseDump", "()Z"); clazz = (*env)->GetObjectClass(env, thiz);
mid = (*env)->GetMethodID(env, clazz, "allowVerboseDump", "()Z");
if (mid == NULL) { if (mid == NULL) {
THROW(env, "java/lang/UnsatisfiedLinkError", THROW(env, "java/lang/UnsatisfiedLinkError",
"Method allowVerboseDump not found"); "Method allowVerboseDump not found");
} }
jboolean verbose = (*env)->CallBooleanMethod(env, thiz, mid); verbose = (*env)->CallBooleanMethod(env, thiz, mid);
jfieldID fid = (*env)->GetFieldID(env, clazz, "nativeCoder", "J"); fid = (*env)->GetFieldID(env, clazz, "nativeCoder", "J");
if (fid == NULL) { if (fid == NULL) {
THROW(env, "java/lang/UnsatisfiedLinkError", THROW(env, "java/lang/UnsatisfiedLinkError",
"Field nativeCoder not found"); "Field nativeCoder not found");
} }
IsalCoder* pCoder = (IsalCoder*)(*env)->GetLongField(env, thiz, fid); pCoder = (IsalCoder*)(*env)->GetLongField(env, thiz, fid);
pCoder->verbose = (verbose == JNI_TRUE) ? 1 : 0; pCoder->verbose = (verbose == JNI_TRUE) ? 1 : 0;
return pCoder; return pCoder;