< prev index next >

src/share/vm/runtime/jniHandles.hpp

Print this page




 201 }
 202 
 203 inline oop& JNIHandles::jobject_ref(jobject handle) {
 204   assert(!is_jweak(handle), "precondition");
 205   return *reinterpret_cast<oop*>(handle);
 206 }
 207 
 208 inline oop& JNIHandles::jweak_ref(jobject handle) {
 209   assert(is_jweak(handle), "precondition");
 210   char* ptr = reinterpret_cast<char*>(handle) - weak_tag_value;
 211   return *reinterpret_cast<oop*>(ptr);
 212 }
 213 
 214 // external_guard is true if called from resolve_external_guard.
 215 // Treat deleted (and possibly zapped) as NULL for external_guard,
 216 // else as (asserted) error.
 217 template<bool external_guard>
 218 inline oop JNIHandles::guard_value(oop value) {
 219   if (!external_guard) {
 220     assert(value != badJNIHandle, "Pointing to zapped jni handle area");
 221     assert(value != deleted_handle(), "Used a deleted global handle");
 222   } else if ((value == badJNIHandle) || (value == deleted_handle())) {
 223     value = NULL;
 224   }
 225   return value;
 226 }
 227 
 228 // external_guard is true if called from resolve_external_guard.
 229 template<bool external_guard>
 230 inline oop JNIHandles::resolve_impl(jobject handle) {
 231   assert(handle != NULL, "precondition");
 232   oop result;
 233   if (is_jweak(handle)) {       // Unlikely
 234     result = resolve_jweak<external_guard>(handle);
 235   } else {
 236     result = jobject_ref(handle);
 237     // Construction of jobjects canonicalize a null value into a null
 238     // jobject, so for non-jweak the pointee should never be null.
 239     assert(external_guard || result != NULL,
 240            "Invalid value read from jni handle");
 241     result = guard_value<external_guard>(result);
 242   }




 201 }
 202 
 203 inline oop& JNIHandles::jobject_ref(jobject handle) {
 204   assert(!is_jweak(handle), "precondition");
 205   return *reinterpret_cast<oop*>(handle);
 206 }
 207 
 208 inline oop& JNIHandles::jweak_ref(jobject handle) {
 209   assert(is_jweak(handle), "precondition");
 210   char* ptr = reinterpret_cast<char*>(handle) - weak_tag_value;
 211   return *reinterpret_cast<oop*>(ptr);
 212 }
 213 
 214 // external_guard is true if called from resolve_external_guard.
 215 // Treat deleted (and possibly zapped) as NULL for external_guard,
 216 // else as (asserted) error.
 217 template<bool external_guard>
 218 inline oop JNIHandles::guard_value(oop value) {
 219   if (!external_guard) {
 220     assert(value != badJNIHandle, "Pointing to zapped jni handle area");
 221     assert(value != deleted_handle(), "Used a deleted global handle.");
 222   } else if (value == badJNIHandle || value == deleted_handle()) {
 223     value = NULL;
 224   }
 225   return value;
 226 }
 227 
 228 // external_guard is true if called from resolve_external_guard.
 229 template<bool external_guard>
 230 inline oop JNIHandles::resolve_impl(jobject handle) {
 231   assert(handle != NULL, "precondition");
 232   oop result;
 233   if (is_jweak(handle)) {       // Unlikely
 234     result = resolve_jweak<external_guard>(handle);
 235   } else {
 236     result = jobject_ref(handle);
 237     // Construction of jobjects canonicalize a null value into a null
 238     // jobject, so for non-jweak the pointee should never be null.
 239     assert(external_guard || result != NULL,
 240            "Invalid value read from jni handle");
 241     result = guard_value<external_guard>(result);
 242   }


< prev index next >