8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup
Rename CHECK_EXCEPTION macros with JNU prefix; use the defensive do {...} while (0) macro definition Reviewed-by: chegar, mchung, ksrini, lancea, alanb
This commit is contained in:
parent
6261c40dca
commit
c4f2b88d81
@ -279,14 +279,37 @@ JNU_NotifyAll(JNIEnv *env, jobject object);
|
|||||||
#define JNU_IsNull(env,obj) ((obj) == NULL)
|
#define JNU_IsNull(env,obj) ((obj) == NULL)
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Miscellaneous utilities used by the class libraries to check for exceptions
|
* Miscellaneous utilities used by the class libraries to return from
|
||||||
|
* a function if a value is NULL or an exception is pending.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CHECK_NULL(x) if ((x) == NULL) return;
|
#define CHECK_NULL(x) \
|
||||||
#define CHECK_NULL_RETURN(x, y) if ((x) == NULL) return (y);
|
do { \
|
||||||
|
if ((x) == NULL) { \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
} while (0) \
|
||||||
|
|
||||||
#define CHECK_EXCEPTION(env) if ((*env)->ExceptionCheck(env)) return;
|
#define CHECK_NULL_RETURN(x, y) \
|
||||||
#define CHECK_EXCEPTION_RETURN(env, y) if ((*env)->ExceptionCheck(env)) return (y);
|
do { \
|
||||||
|
if ((x) == NULL) { \
|
||||||
|
return (y); \
|
||||||
|
} \
|
||||||
|
} while (0) \
|
||||||
|
|
||||||
|
#define JNU_CHECK_EXCEPTION(env) \
|
||||||
|
do { \
|
||||||
|
if ((*env)->ExceptionCheck(env)) { \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
} while (0) \
|
||||||
|
|
||||||
|
#define JNU_CHECK_EXCEPTION_RETURN(env, y) \
|
||||||
|
do { \
|
||||||
|
if ((*env)->ExceptionCheck(env)) { \
|
||||||
|
return (y); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Debugging utilities
|
* Debugging utilities
|
||||||
|
@ -60,15 +60,15 @@ Java_sun_misc_Version_getJvmVersionInfo(JNIEnv *env, jclass cls)
|
|||||||
|
|
||||||
(*func_p)(env, &info, sizeof(info));
|
(*func_p)(env, &info, sizeof(info));
|
||||||
setStaticIntField(env, cls, "jvm_major_version", JVM_VERSION_MAJOR(info.jvm_version));
|
setStaticIntField(env, cls, "jvm_major_version", JVM_VERSION_MAJOR(info.jvm_version));
|
||||||
CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
||||||
setStaticIntField(env, cls, "jvm_minor_version", JVM_VERSION_MINOR(info.jvm_version));
|
setStaticIntField(env, cls, "jvm_minor_version", JVM_VERSION_MINOR(info.jvm_version));
|
||||||
CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
||||||
setStaticIntField(env, cls, "jvm_micro_version", JVM_VERSION_MICRO(info.jvm_version));
|
setStaticIntField(env, cls, "jvm_micro_version", JVM_VERSION_MICRO(info.jvm_version));
|
||||||
CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
||||||
setStaticIntField(env, cls, "jvm_build_number", JVM_VERSION_BUILD(info.jvm_version));
|
setStaticIntField(env, cls, "jvm_build_number", JVM_VERSION_BUILD(info.jvm_version));
|
||||||
CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
||||||
setStaticIntField(env, cls, "jvm_update_version", info.update_version);
|
setStaticIntField(env, cls, "jvm_update_version", info.update_version);
|
||||||
CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE);
|
||||||
jvm_special_version = info.special_update_version;
|
jvm_special_version = info.special_update_version;
|
||||||
|
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
@ -91,15 +91,15 @@ Java_sun_misc_Version_getJdkVersionInfo(JNIEnv *env, jclass cls)
|
|||||||
|
|
||||||
JDK_GetVersionInfo0(&info, sizeof(info));
|
JDK_GetVersionInfo0(&info, sizeof(info));
|
||||||
setStaticIntField(env, cls, "jdk_major_version", JDK_VERSION_MAJOR(info.jdk_version));
|
setStaticIntField(env, cls, "jdk_major_version", JDK_VERSION_MAJOR(info.jdk_version));
|
||||||
CHECK_EXCEPTION(env);
|
JNU_CHECK_EXCEPTION(env);
|
||||||
setStaticIntField(env, cls, "jdk_minor_version", JDK_VERSION_MINOR(info.jdk_version));
|
setStaticIntField(env, cls, "jdk_minor_version", JDK_VERSION_MINOR(info.jdk_version));
|
||||||
CHECK_EXCEPTION(env);
|
JNU_CHECK_EXCEPTION(env);
|
||||||
setStaticIntField(env, cls, "jdk_micro_version", JDK_VERSION_MICRO(info.jdk_version));
|
setStaticIntField(env, cls, "jdk_micro_version", JDK_VERSION_MICRO(info.jdk_version));
|
||||||
CHECK_EXCEPTION(env);
|
JNU_CHECK_EXCEPTION(env);
|
||||||
setStaticIntField(env, cls, "jdk_build_number", JDK_VERSION_BUILD(info.jdk_version));
|
setStaticIntField(env, cls, "jdk_build_number", JDK_VERSION_BUILD(info.jdk_version));
|
||||||
CHECK_EXCEPTION(env);
|
JNU_CHECK_EXCEPTION(env);
|
||||||
setStaticIntField(env, cls, "jdk_update_version", info.update_version);
|
setStaticIntField(env, cls, "jdk_update_version", info.update_version);
|
||||||
CHECK_EXCEPTION(env);
|
JNU_CHECK_EXCEPTION(env);
|
||||||
jdk_special_version = info.special_update_version;
|
jdk_special_version = info.special_update_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user