src/share/vm/prims/jniCheck.cpp

changeset 7843
9904bb920313
parent 7627
d68158e12cea
child 7994
04ff2f6cd0eb
child 8440
fde446cb8e19
     1.1 --- a/src/share/vm/prims/jniCheck.cpp	Wed May 20 02:57:25 2015 -0700
     1.2 +++ b/src/share/vm/prims/jniCheck.cpp	Mon Jul 14 10:50:20 2014 +0200
     1.3 @@ -185,6 +185,9 @@
     1.4   * throw an ArrayIndexOutOfBoundsException or ArrayStoreException.
     1.5   *
     1.6   * In all other cases, a non-error return value guarantees that no exceptions have been thrown.
     1.7 + *
     1.8 + * Programmers often defend against ArrayIndexOutOfBoundsException, so warning
     1.9 + * for these functions would be pedantic.
    1.10   */
    1.11  static inline void
    1.12  check_pending_exception(JavaThread* thr) {
    1.13 @@ -201,6 +204,16 @@
    1.14    }
    1.15  }
    1.16  
    1.17 +/**
    1.18 + * Add to the planned number of handles. I.e. plus current live & warning threshold
    1.19 + */
    1.20 +static inline void
    1.21 +add_planned_handle_capacity(JNIHandleBlock* handles, size_t capacity) {
    1.22 +  handles->set_planned_capacity(capacity +
    1.23 +                                handles->get_number_of_live_handles() +
    1.24 +                                CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
    1.25 +}
    1.26 +
    1.27  
    1.28  static inline void
    1.29  functionEnterCritical(JavaThread* thr)
    1.30 @@ -243,7 +256,7 @@
    1.31        thr->print_stack();
    1.32      )
    1.33      // Complain just the once, reset to current + warn threshold
    1.34 -    handles->set_planned_capacity(live_handles + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
    1.35 +    add_planned_handle_capacity(handles, 0);
    1.36    }
    1.37  }
    1.38  
    1.39 @@ -720,7 +733,7 @@
    1.40        NativeReportJNIFatalError(thr, "negative capacity");
    1.41      jint result = UNCHECKED()->PushLocalFrame(env, capacity);
    1.42      if (result == JNI_OK) {
    1.43 -      thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
    1.44 +      add_planned_handle_capacity(thr->active_handles(), capacity);
    1.45      }
    1.46      functionExit(thr);
    1.47      return result;
    1.48 @@ -824,7 +837,7 @@
    1.49      }
    1.50      jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity);
    1.51      if (result == JNI_OK) {
    1.52 -      thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
    1.53 +      add_planned_handle_capacity(thr->active_handles(), capacity);
    1.54      }
    1.55      functionExit(thr);
    1.56      return result;
    1.57 @@ -1628,7 +1641,6 @@
    1.58        check_is_obj_array(thr, array);
    1.59      )
    1.60      jobject result = UNCHECKED()->GetObjectArrayElement(env,array,index);
    1.61 -    thr->set_pending_jni_exception_check("GetObjectArrayElement");
    1.62      functionExit(thr);
    1.63      return result;
    1.64  JNI_END
    1.65 @@ -1643,7 +1655,6 @@
    1.66        check_is_obj_array(thr, array);
    1.67      )
    1.68      UNCHECKED()->SetObjectArrayElement(env,array,index,val);
    1.69 -    thr->set_pending_jni_exception_check("SetObjectArrayElement");
    1.70      functionExit(thr);
    1.71  JNI_END
    1.72  
    1.73 @@ -1733,7 +1744,6 @@
    1.74        check_primitive_array_type(thr, array, ElementTag); \
    1.75      ) \
    1.76      UNCHECKED()->Get##Result##ArrayRegion(env,array,start,len,buf); \
    1.77 -    thr->set_pending_jni_exception_check("Get"#Result"ArrayRegion"); \
    1.78      functionExit(thr); \
    1.79  JNI_END
    1.80  
    1.81 @@ -1758,7 +1768,6 @@
    1.82        check_primitive_array_type(thr, array, ElementTag); \
    1.83      ) \
    1.84      UNCHECKED()->Set##Result##ArrayRegion(env,array,start,len,buf); \
    1.85 -    thr->set_pending_jni_exception_check("Set"#Result"ArrayRegion"); \
    1.86      functionExit(thr); \
    1.87  JNI_END
    1.88  
    1.89 @@ -1835,7 +1844,6 @@
    1.90        checkString(thr, str);
    1.91      )
    1.92      UNCHECKED()->GetStringRegion(env, str, start, len, buf);
    1.93 -    thr->set_pending_jni_exception_check("GetStringRegion");
    1.94      functionExit(thr);
    1.95  JNI_END
    1.96  
    1.97 @@ -1850,7 +1858,6 @@
    1.98        checkString(thr, str);
    1.99      )
   1.100      UNCHECKED()->GetStringUTFRegion(env, str, start, len, buf);
   1.101 -    thr->set_pending_jni_exception_check("GetStringUTFRegion");
   1.102      functionExit(thr);
   1.103  JNI_END
   1.104  

mercurial