From dbcaf999d9ea7a7c6c090903d1982e5b61200c8b Mon Sep 17 00:00:00 2001 From: Kai Zheng Date: Fri, 19 Aug 2016 11:18:15 +0800 Subject: [PATCH] HADOOP-13504. Refactor jni_common to conform to C89 restrictions imposed by Visual Studio 2010. Contributed by Sammi Chen --- .../org/apache/hadoop/io/erasurecode/jni_common.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/jni_common.c b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/jni_common.c index 17e05dbe23..2b1d9eac0c 100644 --- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/jni_common.c +++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/erasurecode/jni_common.c @@ -43,21 +43,26 @@ void setCoder(JNIEnv* env, jobject thiz, IsalCoder* pCoder) { } 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) { THROW(env, "java/lang/UnsatisfiedLinkError", "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) { THROW(env, "java/lang/UnsatisfiedLinkError", "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; return pCoder;