49 return NULL; // ignore null handles 50 } else { 51 assert(Universe::heap()->is_in_reserved(obj), "sanity check"); 52 return thread->active_handles()->allocate_handle(obj); 53 } 54 } 55 56 57 jobject JNIHandles::make_local(JNIEnv* env, oop obj) { 58 if (obj == NULL) { 59 return NULL; // ignore null handles 60 } else { 61 JavaThread* thread = JavaThread::thread_from_jni_environment(env); 62 assert(Universe::heap()->is_in_reserved(obj), "sanity check"); 63 return thread->active_handles()->allocate_handle(obj); 64 } 65 } 66 67 68 jobject JNIHandles::make_global(Handle obj) { 69 jobject res = NULL; 70 if (!obj.is_null()) { 71 // ignore null handles 72 MutexLocker ml(JNIGlobalHandle_lock); 73 assert(Universe::heap()->is_in_reserved(obj()), "sanity check"); 74 res = _global_handles->allocate_handle(obj()); 75 } else { 76 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); 77 } 78 79 return res; 80 } 81 82 83 jobject JNIHandles::make_weak_global(Handle obj) { 84 jobject res = NULL; 85 if (!obj.is_null()) { 86 // ignore null handles 87 MutexLocker ml(JNIGlobalHandle_lock); 88 assert(Universe::heap()->is_in_reserved(obj()), "sanity check"); 89 res = _weak_global_handles->allocate_handle(obj()); 90 } else { 91 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); 92 } 93 return res; 94 } 95 96 jmethodID JNIHandles::make_jmethod_id(methodHandle mh) { 97 return (jmethodID) make_weak_global(mh); 98 } 99 100 101 102 void JNIHandles::change_method_associated_with_jmethod_id(jmethodID jmid, methodHandle mh) { 103 MutexLocker ml(JNIGlobalHandle_lock); // Is this necessary? | 49 return NULL; // ignore null handles 50 } else { 51 assert(Universe::heap()->is_in_reserved(obj), "sanity check"); 52 return thread->active_handles()->allocate_handle(obj); 53 } 54 } 55 56 57 jobject JNIHandles::make_local(JNIEnv* env, oop obj) { 58 if (obj == NULL) { 59 return NULL; // ignore null handles 60 } else { 61 JavaThread* thread = JavaThread::thread_from_jni_environment(env); 62 assert(Universe::heap()->is_in_reserved(obj), "sanity check"); 63 return thread->active_handles()->allocate_handle(obj); 64 } 65 } 66 67 68 jobject JNIHandles::make_global(Handle obj) { 69 assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC"); 70 jobject res = NULL; 71 if (!obj.is_null()) { 72 // ignore null handles 73 MutexLocker ml(JNIGlobalHandle_lock); 74 assert(Universe::heap()->is_in_reserved(obj()), "sanity check"); 75 res = _global_handles->allocate_handle(obj()); 76 } else { 77 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); 78 } 79 80 return res; 81 } 82 83 84 jobject JNIHandles::make_weak_global(Handle obj) { 85 assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC"); 86 jobject res = NULL; 87 if (!obj.is_null()) { 88 // ignore null handles 89 MutexLocker ml(JNIGlobalHandle_lock); 90 assert(Universe::heap()->is_in_reserved(obj()), "sanity check"); 91 res = _weak_global_handles->allocate_handle(obj()); 92 } else { 93 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); 94 } 95 return res; 96 } 97 98 jmethodID JNIHandles::make_jmethod_id(methodHandle mh) { 99 return (jmethodID) make_weak_global(mh); 100 } 101 102 103 104 void JNIHandles::change_method_associated_with_jmethod_id(jmethodID jmid, methodHandle mh) { 105 MutexLocker ml(JNIGlobalHandle_lock); // Is this necessary? |