From ca7943ac3b194bfbe00f848e958802e0154fe9ec Mon Sep 17 00:00:00 2001
From: Dmitry Samersoff <dsamersoff@openjdk.org>
Date: Thu, 28 Aug 2014 06:32:16 -0700
Subject: [PATCH] 8031583: warnings from b03 for
 hotspot/agent/src/os/solaris/proc: JNI exception pending

Added missed exception checks

Reviewed-by: sla, sspitsyn
---
 hotspot/agent/src/os/solaris/proc/saproc.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hotspot/agent/src/os/solaris/proc/saproc.cpp b/hotspot/agent/src/os/solaris/proc/saproc.cpp
index 3f0e6b25814..d727740ee34 100644
--- a/hotspot/agent/src/os/solaris/proc/saproc.cpp
+++ b/hotspot/agent/src/os/solaris/proc/saproc.cpp
@@ -90,7 +90,9 @@ struct DebuggerWith2Objects : DebuggerWithObject {
 */
 
 static void throwNewDebuggerException(JNIEnv* env, const char* errMsg) {
-  env->ThrowNew(env->FindClass("sun/jvm/hotspot/debugger/DebuggerException"), errMsg);
+  jclass clazz = env->FindClass("sun/jvm/hotspot/debugger/DebuggerException");
+  CHECK_EXCEPTION;
+  env->ThrowNew(clazz, errMsg);
 }
 
 // JNI ids for some fields, methods
@@ -962,6 +964,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLoca
   CHECK_EXCEPTION_(0);
   jboolean isCopy;
   jlong* ptr = env->GetLongArrayElements(res, &isCopy);
+  CHECK_EXCEPTION_(NULL);
   for (int i = 0; i < NPRGREG; i++) {
     ptr[i] = (jlong) (uintptr_t) gregs[i];
   }
@@ -1253,6 +1256,7 @@ JNIEXPORT jstring JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_d
   (JNIEnv *env, jobject this_object, jstring name) {
   jboolean isCopy;
   const char* ptr = env->GetStringUTFChars(name, &isCopy);
+  CHECK_EXCEPTION_(NULL);
   char  buf[2*SYMBOL_BUF_SIZE + 1];
   jstring res = 0;
   if (cplus_demangle((char*) ptr, buf, sizeof(buf)) != DEMANGLE_ESPACE) {
@@ -1439,7 +1443,9 @@ JNIEXPORT void JNICALL Java_sun_jvm_hotspot_debugger_proc_ProcDebuggerLocal_init
                             "createClosestSymbol", "(Ljava/lang/String;J)Lsun/jvm/hotspot/debugger/cdbg/ClosestSymbol;");
   CHECK_EXCEPTION;
 
-  listAdd_ID = env->GetMethodID(env->FindClass("java/util/List"), "add", "(Ljava/lang/Object;)Z");
+  jclass list_clazz = env->FindClass("java/util/List");
+  CHECK_EXCEPTION;
+  listAdd_ID = env->GetMethodID(list_clazz, "add", "(Ljava/lang/Object;)Z");
   CHECK_EXCEPTION;
 
   // part of the class sharing workaround