src/share/vm/prims/jvmtiExport.cpp

Print this page




1288       if (ets->is_enabled(JVMTI_EVENT_EXCEPTION) && (exception != NULL)) {
1289 
1290         EVT_TRACE(JVMTI_EVENT_EXCEPTION,
1291                      ("JVMTI [%s] Evt Exception thrown sent %s.%s @ %d",
1292                       JvmtiTrace::safe_get_thread_name(thread),
1293                       (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
1294                       (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(),
1295                       location - mh()->code_base() ));
1296 
1297         JvmtiEnv *env = ets->get_env();
1298         JvmtiExceptionEventMark jem(thread, mh, location, exception_handle);
1299 
1300         // It's okay to clear these exceptions here because we duplicate
1301         // this lookup in InterpreterRuntime::exception_handler_for_exception.
1302         EXCEPTION_MARK;
1303 
1304         bool should_repeat;
1305         vframeStream st(thread);
1306         assert(!st.at_end(), "cannot be at end");
1307         methodOop current_method = NULL;

1308         int current_bci = -1;
1309         do {
1310           current_method = st.method();

1311           current_bci = st.bci();
1312           do {
1313             should_repeat = false;
1314             KlassHandle eh_klass(thread, exception_handle()->klass());
1315             current_bci = current_method->fast_exception_handler_bci_for(
1316               eh_klass, current_bci, THREAD);
1317             if (HAS_PENDING_EXCEPTION) {
1318               exception_handle = KlassHandle(thread, PENDING_EXCEPTION);
1319               CLEAR_PENDING_EXCEPTION;
1320               should_repeat = true;
1321             }
1322           } while (should_repeat && (current_bci != -1));
1323           st.next();
1324         } while ((current_bci < 0) && (!st.at_end()));
1325 
1326         jmethodID catch_jmethodID;
1327         if (current_bci < 0) {
1328           catch_jmethodID = 0;
1329           current_bci = 0;
1330         } else {
1331           catch_jmethodID = jem.to_jmethodID(
1332                                      methodHandle(thread, current_method));
1333         }
1334 
1335         JvmtiJavaThreadEventTransition jet(thread);
1336         jvmtiEventException callback = env->callbacks()->Exception;
1337         if (callback != NULL) {
1338           (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
1339                       jem.jni_methodID(), jem.location(),
1340                       jem.exception(),
1341                       catch_jmethodID, current_bci);
1342         }
1343       }
1344     }
1345   }
1346 
1347   // frames may get popped because of this throw, be safe - invalidate cached depth
1348   state->invalidate_cur_stack_depth();
1349 }
1350 
1351 
1352 void JvmtiExport::notice_unwind_due_to_exception(JavaThread *thread, methodOop method, address location, oop exception, bool in_handler_frame) {




1288       if (ets->is_enabled(JVMTI_EVENT_EXCEPTION) && (exception != NULL)) {
1289 
1290         EVT_TRACE(JVMTI_EVENT_EXCEPTION,
1291                      ("JVMTI [%s] Evt Exception thrown sent %s.%s @ %d",
1292                       JvmtiTrace::safe_get_thread_name(thread),
1293                       (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(),
1294                       (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(),
1295                       location - mh()->code_base() ));
1296 
1297         JvmtiEnv *env = ets->get_env();
1298         JvmtiExceptionEventMark jem(thread, mh, location, exception_handle);
1299 
1300         // It's okay to clear these exceptions here because we duplicate
1301         // this lookup in InterpreterRuntime::exception_handler_for_exception.
1302         EXCEPTION_MARK;
1303 
1304         bool should_repeat;
1305         vframeStream st(thread);
1306         assert(!st.at_end(), "cannot be at end");
1307         methodOop current_method = NULL;
1308         methodHandle current_mh = methodHandle(thread, current_method);
1309         int current_bci = -1;
1310         do {
1311           current_method = st.method();
1312           current_mh = methodHandle(thread, current_method);
1313           current_bci = st.bci();
1314           do {
1315             should_repeat = false;
1316             KlassHandle eh_klass(thread, exception_handle()->klass());
1317             current_bci = methodOopDesc::fast_exception_handler_bci_for(
1318               current_mh, eh_klass, current_bci, THREAD);
1319             if (HAS_PENDING_EXCEPTION) {
1320               exception_handle = KlassHandle(thread, PENDING_EXCEPTION);
1321               CLEAR_PENDING_EXCEPTION;
1322               should_repeat = true;
1323             }
1324           } while (should_repeat && (current_bci != -1));
1325           st.next();
1326         } while ((current_bci < 0) && (!st.at_end()));
1327 
1328         jmethodID catch_jmethodID;
1329         if (current_bci < 0) {
1330           catch_jmethodID = 0;
1331           current_bci = 0;
1332         } else {
1333           catch_jmethodID = jem.to_jmethodID(current_mh);

1334         }
1335 
1336         JvmtiJavaThreadEventTransition jet(thread);
1337         jvmtiEventException callback = env->callbacks()->Exception;
1338         if (callback != NULL) {
1339           (*callback)(env->jvmti_external(), jem.jni_env(), jem.jni_thread(),
1340                       jem.jni_methodID(), jem.location(),
1341                       jem.exception(),
1342                       catch_jmethodID, current_bci);
1343         }
1344       }
1345     }
1346   }
1347 
1348   // frames may get popped because of this throw, be safe - invalidate cached depth
1349   state->invalidate_cur_stack_depth();
1350 }
1351 
1352 
1353 void JvmtiExport::notice_unwind_due_to_exception(JavaThread *thread, methodOop method, address location, oop exception, bool in_handler_frame) {