src/share/vm/services/gcNotifier.cpp
Print this page
*** 178,198 ****
return Handle(gcInfo_instance());
}
void GCNotifier::sendNotification(TRAPS) {
ResourceMark rm(THREAD);
GCNotificationRequest *request = getRequest();
if(request != NULL) {
! Handle objGcInfo = createGcInfo(request->gcManager,request->gcStatInfo,THREAD);
Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK);
Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK);
Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK);
klassOop k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
! instanceKlassHandle gc_mbean_klass (THREAD, k);
instanceOop gc_mbean = request->gcManager->get_memory_manager_instance(THREAD);
instanceHandle gc_mbean_h(THREAD, gc_mbean);
if (!gc_mbean_h->is_a(k)) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
--- 178,224 ----
return Handle(gcInfo_instance());
}
void GCNotifier::sendNotification(TRAPS) {
+ GCNotifier::sendNotificationInternal(THREAD);
+ // Clearing pending exception to avoid premature termination of
+ // the service thread
+ if (HAS_PENDING_EXCEPTION) {
+ CLEAR_PENDING_EXCEPTION;
+ }
+ }
+
+ class NotificationMark : public StackObj {
+ // This class is used in GCNotifier::sendNotificationInternal to ensure that
+ // the GCNotificationRequest object is properly cleaned up, whatever path
+ // is used to exit the method.
+ GCNotificationRequest* _request;
+ public:
+ NotificationMark(GCNotificationRequest* r) {
+ _request = r;
+ }
+ ~NotificationMark() {
+ assert(_request != NULL, "Sanity check");
+ delete _request;
+ }
+ };
+
+ void GCNotifier::sendNotificationInternal(TRAPS) {
ResourceMark rm(THREAD);
+ HandleMark hm(THREAD);
GCNotificationRequest *request = getRequest();
if(request != NULL) {
! NotificationMark nm(request);
! Handle objGcInfo = createGcInfo(request->gcManager,request->gcStatInfo, THREAD);
Handle objName = java_lang_String::create_from_platform_dependent_str(request->gcManager->name(), CHECK);
Handle objAction = java_lang_String::create_from_platform_dependent_str(request->gcAction, CHECK);
Handle objCause = java_lang_String::create_from_platform_dependent_str(request->gcCause, CHECK);
klassOop k = Management::sun_management_GarbageCollectorImpl_klass(CHECK);
! instanceKlassHandle gc_mbean_klass(THREAD, k);
instanceOop gc_mbean = request->gcManager->get_memory_manager_instance(THREAD);
instanceHandle gc_mbean_h(THREAD, gc_mbean);
if (!gc_mbean_h->is_a(k)) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
*** 211,223 ****
gc_mbean_klass,
vmSymbols::createGCNotification_name(),
vmSymbols::createGCNotification_signature(),
&args,
CHECK);
- if (HAS_PENDING_EXCEPTION) {
- CLEAR_PENDING_EXCEPTION;
}
-
- delete request;
- }
}
--- 237,244 ----