8029465: warnings from b118 for jdk.src.share.native.sun.management: JNI exception pending
authordsamersoff
Thu, 23 Oct 2014 04:57:00 -0700
changeset 27192 a16236cd61d7
parent 27191 45a3002de56f
child 27193 db6241373358
8029465: warnings from b118 for jdk.src.share.native.sun.management: JNI exception pending Summary: Added missed exception check Reviewed-by: dholmes, sspitsyn, fparain
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);