1563 static void threadExitUncaughtException(Thread* self, Object* group)
1564 {
1565 Object* exception;
1566 Object* handlerObj;
1567 Method* uncaughtHandler;
1568
1569 ALOGW("threadid=%d: thread exiting with uncaught exception (group=%p)",
1570 self->threadId, group);
1571 assert(group != NULL);
1572
1573
1577 exception = dvmGetException(self);
1578 assert(exception != NULL);
1579 dvmAddTrackedAlloc(exception, self);
1580 dvmClearException(self);
1581
1582
1588 handlerObj = dvmGetFieldObject(self->threadObj,
1589 gDvm.offJavaLangThread_uncaughtHandler);
1590 if (handlerObj == NULL)
1591 handlerObj = group;
1592
1593
1597 uncaughtHandler = dvmFindVirtualMethodHierByDescriptor(handlerObj->clazz,
1598 "uncaughtException", "(Ljava/lang/Thread;Ljava/lang/Throwable;)V");
1599
1600 if (uncaughtHandler != NULL) {
1601
1602
1603 JValue unused;
1604 dvmCallMethod(self, uncaughtHandler, handlerObj, &unused,
1605 self->threadObj, exception);
1606 } else {
1607
1608 ALOGW("WARNING: no 'uncaughtException' method in class %s",
1609 handlerObj->clazz->descriptor);
1610 dvmSetException(self, exception);
1611 dvmLogExceptionStackTrace();
1612 }
1613
1614
1615 dvmClearException(self);
1616
1617 dvmReleaseTrackedAlloc(exception, self);
1618
1619
1620 lockThreadSuspendCount();
1621 dvmAddToSuspendCounts(self, -self->suspendCount, 0);
1622 unlockThreadSuspendCount();
1623 }