changeset 11257:1af79934dc16

8139985: JNI exception pending in jdk/src/jdk/hprof/agent/share/native/libhprof Summary: Add missed exceptions check Reviewed-by: dsamersoff, sla Contributed-by: Jini Susan George <jini.george@oracle.com>
author dsamersoff
date Thu, 03 Dec 2015 10:10:13 +0530
parents 6ea3aea950d1
children a54fbc80b383
files src/share/demo/jvmti/hprof/hprof_class.c src/share/demo/jvmti/hprof/hprof_event.c src/share/demo/jvmti/hprof/hprof_util.c
diffstat 3 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/demo/jvmti/hprof/hprof_class.c	Thu Dec 10 12:21:26 2015 +0000
+++ b/src/share/demo/jvmti/hprof/hprof_class.c	Thu Dec 03 10:10:13 2015 +0530
@@ -529,6 +529,11 @@
     info = get_info(index);
     if (mnum >= info->method_count) {
         jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+        if ((*env)->ExceptionCheck(env)) {
+            (*env)->ExceptionClear(env);
+            HPROF_ERROR(JNI_TRUE,
+                        "Could not find the java/lang/IllegalArgumentException class");
+        }
         (*env)->ThrowNew(env, newExcCls, "Illegal mnum");
 
         return NULL;
@@ -542,6 +547,11 @@
         name  = (char *)string_get(info->method[mnum].name_index);
         if (name==NULL) {
             jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+            if ((*env)->ExceptionCheck(env)) {
+                (*env)->ExceptionClear(env);
+                HPROF_ERROR(JNI_TRUE,
+                            "Could not find the java/lang/IllegalArgumentException class");
+            }
             (*env)->ThrowNew(env, newExcCls, "Name not found");
 
             return NULL;
--- a/src/share/demo/jvmti/hprof/hprof_event.c	Thu Dec 10 12:21:26 2015 +0000
+++ b/src/share/demo/jvmti/hprof/hprof_event.c	Thu Dec 03 10:10:13 2015 +0530
@@ -197,6 +197,11 @@
     HPROF_ASSERT(thread!=NULL);
     if (cnum == 0 || cnum == gdata->tracker_cnum) {
         jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+        if ((*env)->ExceptionCheck(env)) {
+            (*env)->ExceptionClear(env);
+            HPROF_ERROR(JNI_TRUE,
+                        "Could not find the java/lang/IllegalArgumentException class");
+        }
         (*env)->ThrowNew(env, newExcCls, "Illegal cnum.");
 
         return;
@@ -258,6 +263,11 @@
 
     if (cnum == 0 || cnum == gdata->tracker_cnum) {
         jclass newExcCls = (*env)->FindClass(env, "java/lang/IllegalArgumentException");
+        if ((*env)->ExceptionCheck(env)) {
+            (*env)->ExceptionClear(env);
+            HPROF_ERROR(JNI_TRUE,
+                        "Could not find the java/lang/IllegalArgumentException class");
+        }
         (*env)->ThrowNew(env, newExcCls, "Illegal cnum.");
 
         return;
--- a/src/share/demo/jvmti/hprof/hprof_util.c	Thu Dec 10 12:21:26 2015 +0000
+++ b/src/share/demo/jvmti/hprof/hprof_util.c	Thu Dec 03 10:10:13 2015 +0530
@@ -374,7 +374,10 @@
 
     HPROF_ASSERT(env!=NULL);
     HPROF_ASSERT(object!=NULL);
-    gref = JNI_FUNC_PTR(env,NewWeakGlobalRef)(env, object);
+    CHECK_EXCEPTIONS (env) {
+      gref = JNI_FUNC_PTR(env,NewWeakGlobalRef)(env, object);
+    } END_CHECK_EXCEPTIONS;
+
     HPROF_ASSERT(gref!=NULL);
     return gref;
 }