# HG changeset patch # User dsamersoff # Date 1414065420 25200 # Node ID a16236cd61d71201146a7ccdfe1516959a96a63a # Parent 45a3002de56f03e85d6f14d8fed66787195c5514 8029465: warnings from b118 for jdk.src.share.native.sun.management: JNI exception pending Summary: Added missed exception check Reviewed-by: dholmes, sspitsyn, fparain diff -r 45a3002de56f -r a16236cd61d7 jdk/src/java.management/share/native/libmanagement/DiagnosticCommandImpl.c --- a/jdk/src/java.management/share/native/libmanagement/DiagnosticCommandImpl.c Wed Oct 22 17:23:14 2014 +0200 +++ b/jdk/src/java.management/share/native/libmanagement/DiagnosticCommandImpl.c Thu Oct 23 04:57:00 2014 -0700 @@ -65,6 +65,11 @@ dcmd_arg_info_array); dcmdArgInfoCls = (*env)->FindClass(env, "sun/management/DiagnosticCommandArgumentInfo"); + if ((*env)->ExceptionCheck(env)) { + free(dcmd_arg_info_array); + return NULL; + } + result = (*env)->NewObjectArray(env, num_arg, dcmdArgInfoCls, NULL); if (result == NULL) { free(dcmd_arg_info_array); @@ -91,9 +96,16 @@ } free(dcmd_arg_info_array); arraysCls = (*env)->FindClass(env, "java/util/Arrays"); + if ((*env)->ExceptionCheck(env)) { + return NULL; + } mid = (*env)->GetStaticMethodID(env, arraysCls, "asList", "([Ljava/lang/Object;)Ljava/util/List;"); resultList = (*env)->CallStaticObjectMethod(env, arraysCls, mid, result); + if ((*env)->ExceptionCheck(env)) { + // Make sure we return NULL in case of OOM inside Java + return NULL; + } return resultList; } @@ -121,6 +133,10 @@ num_commands = (*env)->GetArrayLength(env, commands); dcmdInfoCls = (*env)->FindClass(env, "sun/management/DiagnosticCommandInfo"); + if ((*env)->ExceptionCheck(env)) { + return NULL; + } + result = (*env)->NewObjectArray(env, num_commands, dcmdInfoCls, NULL); if (result == NULL) { JNU_ThrowOutOfMemoryError(env, 0);