Print this page
rev 7151 : 8043224: -Xcheck:jni improvements to exception checking and excessive local refs
Summary: Warning when not checking exceptions from function that require so, also when local refs expand beyond capacity.
Reviewed-by: dsimms

Split Split Close
Expand all
Collapse all
          --- old/hotspot/src/share/vm/prims/jniCheck.cpp
          +++ new/hotspot/src/share/vm/prims/jniCheck.cpp
   1    1  /*
   2      - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
        2 + * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.
   8    8   *
   9    9   * This code is distributed in the hope that it will be useful, but WITHOUT
  10   10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11   11   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12   12   * version 2 for more details (a copy is included in the LICENSE file that
↓ open down ↓ 33 lines elided ↑ open up ↑
  46   46  #ifdef TARGET_ARCH_zero
  47   47  # include "jniTypes_zero.hpp"
  48   48  #endif
  49   49  #ifdef TARGET_ARCH_arm
  50   50  # include "jniTypes_arm.hpp"
  51   51  #endif
  52   52  #ifdef TARGET_ARCH_ppc
  53   53  # include "jniTypes_ppc.hpp"
  54   54  #endif
  55   55  
       56 +// Complain every extra number of unplanned local refs
       57 +#define CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD 32
  56   58  
  57   59  // Heap objects are allowed to be directly referenced only in VM code,
  58   60  // not in native code.
  59   61  
  60   62  #define ASSERT_OOPS_ALLOWED                                          \
  61   63      assert(JavaThread::current()->thread_state() == _thread_in_vm,   \
  62   64             "jniCheck examining oops in bad state.")
  63   65  
  64   66  
  65   67  // Execute the given block of source code with the thread in VM state.
↓ open down ↓ 95 lines elided ↑ open up ↑
 161  163    )
 162  164  }
 163  165  
 164  166  
 165  167  
 166  168  
 167  169  /*
 168  170   * SUPPORT FUNCTIONS
 169  171   */
 170  172  
      173 +/**
      174 + * Check whether or not a programmer has actually checked for exceptions. According
      175 + * to the JNI Specification ("jni/spec/design.html#java_exceptions"):
      176 + *
      177 + * There are two cases where the programmer needs to check for exceptions without
      178 + * being able to first check an error code:
      179 + *
      180 + * - The JNI functions that invoke a Java method return the result of the Java method.
      181 + * The programmer must call ExceptionOccurred() to check for possible exceptions
      182 + * that occurred during the execution of the Java method.
      183 + *
      184 + * - Some of the JNI array access functions do not return an error code, but may
      185 + * throw an ArrayIndexOutOfBoundsException or ArrayStoreException.
      186 + *
      187 + * In all other cases, a non-error return value guarantees that no exceptions have been thrown.
      188 + */
 171  189  static inline void
 172      -functionEnterCritical(JavaThread* thr)
 173      -{
      190 +check_pending_exception(JavaThread* thr) {
 174  191    if (thr->has_pending_exception()) {
 175  192      NativeReportJNIWarning(thr, "JNI call made with exception pending");
 176  193    }
      194 +  if (thr->is_pending_jni_exception_check()) {
      195 +    IN_VM(
      196 +      tty->print_cr("WARNING in native method: JNI call made without checking exceptions when required to from %s",
      197 +        thr->get_pending_jni_exception_check());
      198 +      thr->print_stack();
      199 +    )
      200 +    thr->clear_pending_jni_exception_check(); // Just complain once
      201 +  }
      202 +}
      203 +
      204 +
      205 +static inline void
      206 +functionEnterCritical(JavaThread* thr)
      207 +{
      208 +  check_pending_exception(thr);
 177  209  }
 178  210  
 179  211  static inline void
 180  212  functionEnterCriticalExceptionAllowed(JavaThread* thr)
 181  213  {
 182  214  }
 183  215  
 184  216  static inline void
 185  217  functionEnter(JavaThread* thr)
 186  218  {
 187  219    if (thr->in_critical()) {
 188  220      tty->print_cr("%s", warn_other_function_in_critical);
 189  221    }
 190      -  if (thr->has_pending_exception()) {
 191      -    NativeReportJNIWarning(thr, "JNI call made with exception pending");
 192      -  }
      222 +  check_pending_exception(thr);
 193  223  }
 194  224  
 195  225  static inline void
 196  226  functionEnterExceptionAllowed(JavaThread* thr)
 197  227  {
 198  228    if (thr->in_critical()) {
 199  229      tty->print_cr("%s", warn_other_function_in_critical);
 200  230    }
 201  231  }
 202  232  
 203  233  static inline void
 204      -functionExit(JNIEnv *env)
      234 +functionExit(JavaThread* thr)
 205  235  {
 206      -  /* nothing to do at this time */
      236 +  JNIHandleBlock* handles = thr->active_handles();
      237 +  size_t planned_capacity = handles->get_planned_capacity();
      238 +  size_t live_handles = handles->get_number_of_live_handles();
      239 +  if (live_handles > planned_capacity) {
      240 +    IN_VM(
      241 +      tty->print_cr("WARNING: JNI local refs: %zu, exceeds capacity: %zu",
      242 +          live_handles, planned_capacity);
      243 +      thr->print_stack();
      244 +    )
      245 +    // Complain just the once, reset to current + warn threshold
      246 +    handles->set_planned_capacity(live_handles + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
      247 +  }
 207  248  }
 208  249  
 209  250  static inline void
 210  251  checkStaticFieldID(JavaThread* thr, jfieldID fid, jclass cls, int ftype)
 211  252  {
 212  253    fieldDescriptor fd;
 213  254  
 214  255    /* make sure it is a static field */
 215  256    if (!jfieldIDWorkaround::is_static_jfieldID(fid))
 216  257      ReportJNIFatalError(thr, fatal_should_be_static);
↓ open down ↓ 284 lines elided ↑ open up ↑
 501  542    checked_jni_DefineClass(JNIEnv *env,
 502  543                            const char *name,
 503  544                            jobject loader,
 504  545                            const jbyte *buf,
 505  546                            jsize len))
 506  547      functionEnter(thr);
 507  548      IN_VM(
 508  549        jniCheck::validate_object(thr, loader);
 509  550      )
 510  551      jclass result = UNCHECKED()->DefineClass(env, name, loader, buf, len);
 511      -    functionExit(env);
      552 +    functionExit(thr);
 512  553      return result;
 513  554  JNI_END
 514  555  
 515  556  JNI_ENTRY_CHECKED(jclass,
 516  557    checked_jni_FindClass(JNIEnv *env,
 517  558                          const char *name))
 518  559      functionEnter(thr);
 519  560      IN_VM(
 520  561        jniCheck::validate_class_descriptor(thr, name);
 521  562      )
 522  563      jclass result = UNCHECKED()->FindClass(env, name);
 523      -    functionExit(env);
      564 +    functionExit(thr);
 524  565      return result;
 525  566  JNI_END
 526  567  
 527  568  JNI_ENTRY_CHECKED(jmethodID,
 528  569    checked_jni_FromReflectedMethod(JNIEnv *env,
 529  570                                    jobject method))
 530  571      functionEnter(thr);
 531  572      IN_VM(
 532  573        jniCheck::validate_object(thr, method);
 533  574      )
 534  575      jmethodID result = UNCHECKED()->FromReflectedMethod(env, method);
 535      -    functionExit(env);
      576 +    functionExit(thr);
 536  577      return result;
 537  578  JNI_END
 538  579  
 539  580  JNI_ENTRY_CHECKED(jfieldID,
 540  581    checked_jni_FromReflectedField(JNIEnv *env,
 541  582                                   jobject field))
 542  583      functionEnter(thr);
 543  584      IN_VM(
 544  585        jniCheck::validate_object(thr, field);
 545  586      )
 546  587      jfieldID result = UNCHECKED()->FromReflectedField(env, field);
 547      -    functionExit(env);
      588 +    functionExit(thr);
 548  589      return result;
 549  590  JNI_END
 550  591  
 551  592  JNI_ENTRY_CHECKED(jobject,
 552  593    checked_jni_ToReflectedMethod(JNIEnv *env,
 553  594                                  jclass cls,
 554  595                                  jmethodID methodID,
 555  596                                  jboolean isStatic))
 556  597      functionEnter(thr);
 557  598      IN_VM(
 558  599        jniCheck::validate_class(thr, cls, false);
 559  600        jniCheck::validate_jmethod_id(thr, methodID);
 560  601      )
 561  602      jobject result = UNCHECKED()->ToReflectedMethod(env, cls, methodID,
 562  603                                                      isStatic);
 563      -    functionExit(env);
      604 +    functionExit(thr);
 564  605      return result;
 565  606  JNI_END
 566  607  
 567  608  JNI_ENTRY_CHECKED(jclass,
 568  609    checked_jni_GetSuperclass(JNIEnv *env,
 569  610                              jclass sub))
 570  611      functionEnter(thr);
 571  612      IN_VM(
 572  613        jniCheck::validate_class(thr, sub, true);
 573  614      )
 574  615      jclass result = UNCHECKED()->GetSuperclass(env, sub);
 575      -    functionExit(env);
      616 +    functionExit(thr);
 576  617      return result;
 577  618  JNI_END
 578  619  
 579  620  JNI_ENTRY_CHECKED(jboolean,
 580  621    checked_jni_IsAssignableFrom(JNIEnv *env,
 581  622                                 jclass sub,
 582  623                                 jclass sup))
 583  624      functionEnter(thr);
 584  625      IN_VM(
 585  626        jniCheck::validate_class(thr, sub, true);
 586  627        jniCheck::validate_class(thr, sup, true);
 587  628      )
 588  629      jboolean result = UNCHECKED()->IsAssignableFrom(env, sub, sup);
 589      -    functionExit(env);
      630 +    functionExit(thr);
 590  631      return result;
 591  632  JNI_END
 592  633  
 593  634  JNI_ENTRY_CHECKED(jobject,
 594  635    checked_jni_ToReflectedField(JNIEnv *env,
 595  636                                 jclass cls,
 596  637                                 jfieldID fieldID,
 597  638                                 jboolean isStatic))
 598  639      functionEnter(thr);
 599  640      IN_VM(
 600  641        jniCheck::validate_class(thr, cls, false);
 601  642      )
 602  643      jobject result = UNCHECKED()->ToReflectedField(env, cls, fieldID,
 603  644                                                     isStatic);
 604      -    functionExit(env);
      645 +    functionExit(thr);
 605  646      return result;
 606  647  JNI_END
 607  648  
 608  649  JNI_ENTRY_CHECKED(jint,
 609  650    checked_jni_Throw(JNIEnv *env,
 610  651                      jthrowable obj))
 611  652      functionEnter(thr);
 612  653      IN_VM(
 613  654        oop oopObj = jniCheck::validate_object(thr, obj);
 614  655        if (oopObj == NULL) {
 615  656          // Unchecked Throw tolerates a NULL obj, so just warn
 616  657          ReportJNIWarning(thr, "JNI Throw called with NULL throwable");
 617  658        } else {
 618  659          jniCheck::validate_throwable_klass(thr, oopObj->klass());
 619  660        }
 620  661      )
 621  662      jint result = UNCHECKED()->Throw(env, obj);
 622      -    functionExit(env);
      663 +    functionExit(thr);
 623  664      return result;
 624  665  JNI_END
 625  666  
 626  667  JNI_ENTRY_CHECKED(jint,
 627  668    checked_jni_ThrowNew(JNIEnv *env,
 628  669                         jclass clazz,
 629  670                         const char *msg))
 630  671      functionEnter(thr);
 631  672      IN_VM(
 632  673        Klass* k = jniCheck::validate_class(thr, clazz, false);
 633  674        assert(k != NULL, "validate_class shouldn't return NULL Klass*");
 634  675        jniCheck::validate_throwable_klass(thr, k);
 635  676      )
 636  677      jint result = UNCHECKED()->ThrowNew(env, clazz, msg);
 637      -    functionExit(env);
      678 +    functionExit(thr);
 638  679      return result;
 639  680  JNI_END
 640  681  
 641  682  JNI_ENTRY_CHECKED(jthrowable,
 642  683    checked_jni_ExceptionOccurred(JNIEnv *env))
      684 +    thr->clear_pending_jni_exception_check();
 643  685      functionEnterExceptionAllowed(thr);
 644  686      jthrowable result = UNCHECKED()->ExceptionOccurred(env);
 645      -    functionExit(env);
      687 +    functionExit(thr);
 646  688      return result;
 647  689  JNI_END
 648  690  
 649  691  JNI_ENTRY_CHECKED(void,
 650  692    checked_jni_ExceptionDescribe(JNIEnv *env))
 651  693      functionEnterExceptionAllowed(thr);
 652  694      UNCHECKED()->ExceptionDescribe(env);
 653      -    functionExit(env);
      695 +    functionExit(thr);
 654  696  JNI_END
 655  697  
 656  698  JNI_ENTRY_CHECKED(void,
 657  699    checked_jni_ExceptionClear(JNIEnv *env))
      700 +    thr->clear_pending_jni_exception_check();
 658  701      functionEnterExceptionAllowed(thr);
 659  702      UNCHECKED()->ExceptionClear(env);
 660      -    functionExit(env);
      703 +    functionExit(thr);
 661  704  JNI_END
 662  705  
 663  706  JNI_ENTRY_CHECKED(void,
 664  707    checked_jni_FatalError(JNIEnv *env,
 665  708                           const char *msg))
      709 +    thr->clear_pending_jni_exception_check();
 666  710      functionEnter(thr);
 667  711      UNCHECKED()->FatalError(env, msg);
 668      -    functionExit(env);
      712 +    functionExit(thr);
 669  713  JNI_END
 670  714  
 671  715  JNI_ENTRY_CHECKED(jint,
 672  716    checked_jni_PushLocalFrame(JNIEnv *env,
 673  717                               jint capacity))
 674  718      functionEnterExceptionAllowed(thr);
 675  719      if (capacity < 0)
 676  720        NativeReportJNIFatalError(thr, "negative capacity");
 677  721      jint result = UNCHECKED()->PushLocalFrame(env, capacity);
 678      -    functionExit(env);
      722 +    if (result == JNI_OK) {
      723 +      thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
      724 +    }
      725 +    functionExit(thr);
 679  726      return result;
 680  727  JNI_END
 681  728  
 682  729  JNI_ENTRY_CHECKED(jobject,
 683  730    checked_jni_PopLocalFrame(JNIEnv *env,
 684  731                              jobject result))
 685  732      functionEnterExceptionAllowed(thr);
 686  733      jobject res = UNCHECKED()->PopLocalFrame(env, result);
 687      -    functionExit(env);
      734 +    functionExit(thr);
 688  735      return res;
 689  736  JNI_END
 690  737  
 691  738  JNI_ENTRY_CHECKED(jobject,
 692  739    checked_jni_NewGlobalRef(JNIEnv *env,
 693  740                             jobject lobj))
 694  741      functionEnter(thr);
 695  742      IN_VM(
 696  743        if (lobj != NULL) {
 697  744          jniCheck::validate_handle(thr, lobj);
 698  745        }
 699  746      )
 700  747      jobject result = UNCHECKED()->NewGlobalRef(env,lobj);
 701      -    functionExit(env);
      748 +    functionExit(thr);
 702  749      return result;
 703  750  JNI_END
 704  751  
 705  752  JNI_ENTRY_CHECKED(void,
 706  753    checked_jni_DeleteGlobalRef(JNIEnv *env,
 707  754                                jobject gref))
 708  755      functionEnterExceptionAllowed(thr);
 709  756      IN_VM(
 710  757        jniCheck::validate_object(thr, gref);
 711  758        if (gref && !JNIHandles::is_global_handle(gref)) {
 712  759          ReportJNIFatalError(thr,
 713  760              "Invalid global JNI handle passed to DeleteGlobalRef");
 714  761        }
 715  762      )
 716  763      UNCHECKED()->DeleteGlobalRef(env,gref);
 717      -    functionExit(env);
      764 +    functionExit(thr);
 718  765  JNI_END
 719  766  
 720  767  JNI_ENTRY_CHECKED(void,
 721  768    checked_jni_DeleteLocalRef(JNIEnv *env,
 722  769                               jobject obj))
 723  770      functionEnterExceptionAllowed(thr);
 724  771      IN_VM(
 725  772        jniCheck::validate_object(thr, obj);
 726  773        if (obj && !(JNIHandles::is_local_handle(thr, obj) ||
 727  774                     JNIHandles::is_frame_handle(thr, obj)))
 728  775          ReportJNIFatalError(thr,
 729  776              "Invalid local JNI handle passed to DeleteLocalRef");
 730  777      )
 731  778      UNCHECKED()->DeleteLocalRef(env, obj);
 732      -    functionExit(env);
      779 +    functionExit(thr);
 733  780  JNI_END
 734  781  
 735  782  JNI_ENTRY_CHECKED(jboolean,
 736  783    checked_jni_IsSameObject(JNIEnv *env,
 737  784                             jobject obj1,
 738  785                             jobject obj2))
 739  786      functionEnterExceptionAllowed(thr);
 740  787      IN_VM(
 741  788        /* This JNI function can be used to compare weak global references
 742  789         * to NULL objects. If the handles are valid, but contain NULL,
 743  790         * then don't attempt to validate the object.
 744  791         */
 745  792        if (obj1 != NULL && jniCheck::validate_handle(thr, obj1) != NULL) {
 746  793          jniCheck::validate_object(thr, obj1);
 747  794        }
 748  795        if (obj2 != NULL && jniCheck::validate_handle(thr, obj2) != NULL) {
 749  796          jniCheck::validate_object(thr, obj2);
 750  797        }
 751  798      )
 752  799      jboolean result = UNCHECKED()->IsSameObject(env,obj1,obj2);
 753      -    functionExit(env);
      800 +    functionExit(thr);
 754  801      return result;
 755  802  JNI_END
 756  803  
 757  804  JNI_ENTRY_CHECKED(jobject,
 758  805    checked_jni_NewLocalRef(JNIEnv *env,
 759  806                            jobject ref))
 760  807      functionEnter(thr);
 761  808      IN_VM(
 762  809        if (ref != NULL) {
 763  810          jniCheck::validate_handle(thr, ref);
 764  811        }
 765  812      )
 766  813      jobject result = UNCHECKED()->NewLocalRef(env, ref);
 767      -    functionExit(env);
      814 +    functionExit(thr);
 768  815      return result;
 769  816  JNI_END
 770  817  
 771  818  JNI_ENTRY_CHECKED(jint,
 772  819    checked_jni_EnsureLocalCapacity(JNIEnv *env,
 773  820                                    jint capacity))
 774  821      functionEnter(thr);
 775  822      if (capacity < 0) {
 776  823        NativeReportJNIFatalError(thr, "negative capacity");
 777  824      }
 778  825      jint result = UNCHECKED()->EnsureLocalCapacity(env, capacity);
 779      -    functionExit(env);
      826 +    if (result == JNI_OK) {
      827 +      thr->active_handles()->set_planned_capacity(capacity + CHECK_JNI_LOCAL_REF_CAP_WARN_THRESHOLD);
      828 +    }
      829 +    functionExit(thr);
 780  830      return result;
 781  831  JNI_END
 782  832  
 783  833  JNI_ENTRY_CHECKED(jobject,
 784  834    checked_jni_AllocObject(JNIEnv *env,
 785  835                            jclass clazz))
 786  836      functionEnter(thr);
 787  837      IN_VM(
 788  838        jniCheck::validate_class(thr, clazz, false);
 789  839      )
 790  840      jobject result = UNCHECKED()->AllocObject(env,clazz);
 791      -    functionExit(env);
      841 +    functionExit(thr);
 792  842      return result;
 793  843  JNI_END
 794  844  
 795  845  JNI_ENTRY_CHECKED(jobject,
 796  846    checked_jni_NewObject(JNIEnv *env,
 797  847                          jclass clazz,
 798  848                          jmethodID methodID,
 799  849                          ...))
 800  850      functionEnter(thr);
 801  851      va_list args;
 802  852      IN_VM(
 803  853        jniCheck::validate_class(thr, clazz, false);
 804  854        jniCheck::validate_jmethod_id(thr, methodID);
 805  855      )
 806  856      va_start(args, methodID);
 807  857      jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args);
 808  858      va_end(args);
 809      -    functionExit(env);
      859 +    functionExit(thr);
 810  860      return result;
 811  861  JNI_END
 812  862  
 813  863  JNI_ENTRY_CHECKED(jobject,
 814  864    checked_jni_NewObjectV(JNIEnv *env,
 815  865                           jclass clazz,
 816  866                           jmethodID methodID,
 817  867                           va_list args))
 818  868      functionEnter(thr);
 819  869      IN_VM(
 820  870        jniCheck::validate_class(thr, clazz, false);
 821  871        jniCheck::validate_jmethod_id(thr, methodID);
 822  872      )
 823  873      jobject result = UNCHECKED()->NewObjectV(env,clazz,methodID,args);
 824      -    functionExit(env);
      874 +    functionExit(thr);
 825  875      return result;
 826  876  JNI_END
 827  877  
 828  878  JNI_ENTRY_CHECKED(jobject,
 829  879    checked_jni_NewObjectA(JNIEnv *env,
 830  880                           jclass clazz,
 831  881                           jmethodID methodID,
 832  882                           const jvalue *args))
 833  883      functionEnter(thr);
 834  884      IN_VM(
 835  885        jniCheck::validate_class(thr, clazz, false);
 836  886        jniCheck::validate_jmethod_id(thr, methodID);
 837  887      )
 838  888      jobject result = UNCHECKED()->NewObjectA(env,clazz,methodID,args);
 839      -    functionExit(env);
      889 +    functionExit(thr);
 840  890      return result;
 841  891  JNI_END
 842  892  
 843  893  JNI_ENTRY_CHECKED(jclass,
 844  894    checked_jni_GetObjectClass(JNIEnv *env,
 845  895                               jobject obj))
 846  896      functionEnter(thr);
 847  897      IN_VM(
 848  898        jniCheck::validate_object(thr, obj);
 849  899      )
 850  900      jclass result = UNCHECKED()->GetObjectClass(env,obj);
 851      -    functionExit(env);
      901 +    functionExit(thr);
 852  902      return result;
 853  903  JNI_END
 854  904  
 855  905  JNI_ENTRY_CHECKED(jboolean,
 856  906    checked_jni_IsInstanceOf(JNIEnv *env,
 857  907                             jobject obj,
 858  908                             jclass clazz))
 859  909      functionEnter(thr);
 860  910      IN_VM(
 861  911        jniCheck::validate_object(thr, obj);
 862  912        jniCheck::validate_class(thr, clazz, true);
 863  913      )
 864  914      jboolean result = UNCHECKED()->IsInstanceOf(env,obj,clazz);
 865      -    functionExit(env);
      915 +    functionExit(thr);
 866  916      return result;
 867  917  JNI_END
 868  918  
 869  919  JNI_ENTRY_CHECKED(jmethodID,
 870  920    checked_jni_GetMethodID(JNIEnv *env,
 871  921                            jclass clazz,
 872  922                            const char *name,
 873  923                            const char *sig))
 874  924      functionEnter(thr);
 875  925      IN_VM(
 876  926        jniCheck::validate_class(thr, clazz, false);
 877  927      )
 878  928      jmethodID result = UNCHECKED()->GetMethodID(env,clazz,name,sig);
 879      -    functionExit(env);
      929 +    functionExit(thr);
 880  930      return result;
 881  931  JNI_END
 882  932  
 883  933  #define WRAPPER_CallMethod(ResultType, Result) \
 884  934  JNI_ENTRY_CHECKED(ResultType,  \
 885  935    checked_jni_Call##Result##Method(JNIEnv *env, \
 886  936                                     jobject obj, \
 887  937                                     jmethodID methodID, \
 888  938                                     ...)) \
 889  939      functionEnter(thr); \
 890  940      va_list args; \
 891  941      IN_VM( \
 892  942        jniCheck::validate_call_object(thr, obj, methodID); \
 893  943      ) \
 894  944      va_start(args,methodID); \
 895  945      ResultType result =UNCHECKED()->Call##Result##MethodV(env, obj, methodID, \
 896  946                                                            args); \
 897  947      va_end(args); \
 898      -    functionExit(env); \
      948 +    thr->set_pending_jni_exception_check("Call"#Result"Method"); \
      949 +    functionExit(thr); \
 899  950      return result; \
 900  951  JNI_END \
 901  952  \
 902  953  JNI_ENTRY_CHECKED(ResultType,  \
 903  954    checked_jni_Call##Result##MethodV(JNIEnv *env, \
 904  955                                      jobject obj, \
 905  956                                      jmethodID methodID, \
 906  957                                      va_list args)) \
 907  958      functionEnter(thr); \
 908  959      IN_VM(\
 909  960        jniCheck::validate_call_object(thr, obj, methodID); \
 910  961      ) \
 911  962      ResultType result = UNCHECKED()->Call##Result##MethodV(env, obj, methodID,\
 912  963                                                             args); \
 913      -    functionExit(env); \
      964 +    thr->set_pending_jni_exception_check("Call"#Result"MethodV"); \
      965 +    functionExit(thr); \
 914  966      return result; \
 915  967  JNI_END \
 916  968  \
 917  969  JNI_ENTRY_CHECKED(ResultType,  \
 918  970    checked_jni_Call##Result##MethodA(JNIEnv *env, \
 919  971                                      jobject obj, \
 920  972                                      jmethodID methodID, \
 921  973                                      const jvalue * args)) \
 922  974      functionEnter(thr); \
 923  975      IN_VM( \
 924  976        jniCheck::validate_call_object(thr, obj, methodID); \
 925  977      ) \
 926  978      ResultType result = UNCHECKED()->Call##Result##MethodA(env, obj, methodID,\
 927  979                                                             args); \
 928      -    functionExit(env); \
      980 +    thr->set_pending_jni_exception_check("Call"#Result"MethodA"); \
      981 +    functionExit(thr); \
 929  982      return result; \
 930  983  JNI_END
 931  984  
 932  985  WRAPPER_CallMethod(jobject,Object)
 933  986  WRAPPER_CallMethod(jboolean,Boolean)
 934  987  WRAPPER_CallMethod(jbyte,Byte)
 935  988  WRAPPER_CallMethod(jshort,Short)
 936  989  WRAPPER_CallMethod(jchar,Char)
 937  990  WRAPPER_CallMethod(jint,Int)
 938  991  WRAPPER_CallMethod(jlong,Long)
↓ open down ↓ 6 lines elided ↑ open up ↑
 945  998                               jmethodID methodID, \
 946  999                               ...))
 947 1000      functionEnter(thr);
 948 1001      va_list args;
 949 1002      IN_VM(
 950 1003        jniCheck::validate_call_object(thr, obj, methodID);
 951 1004      )
 952 1005      va_start(args,methodID);
 953 1006      UNCHECKED()->CallVoidMethodV(env,obj,methodID,args);
 954 1007      va_end(args);
 955      -    functionExit(env);
     1008 +    thr->set_pending_jni_exception_check("CallVoidMethod");
     1009 +    functionExit(thr);
 956 1010  JNI_END
 957 1011  
 958 1012  JNI_ENTRY_CHECKED(void,
 959 1013    checked_jni_CallVoidMethodV(JNIEnv *env,
 960 1014                                jobject obj,
 961 1015                                jmethodID methodID,
 962 1016                                va_list args))
 963 1017      functionEnter(thr);
 964 1018      IN_VM(
 965 1019        jniCheck::validate_call_object(thr, obj, methodID);
 966 1020      )
 967 1021      UNCHECKED()->CallVoidMethodV(env,obj,methodID,args);
 968      -    functionExit(env);
     1022 +    thr->set_pending_jni_exception_check("CallVoidMethodV");
     1023 +    functionExit(thr);
 969 1024  JNI_END
 970 1025  
 971 1026  JNI_ENTRY_CHECKED(void,
 972 1027    checked_jni_CallVoidMethodA(JNIEnv *env,
 973 1028                                jobject obj,
 974 1029                                jmethodID methodID,
 975 1030                                const jvalue * args))
 976 1031      functionEnter(thr);
 977 1032      IN_VM(
 978 1033        jniCheck::validate_call_object(thr, obj, methodID);
 979 1034      )
 980 1035      UNCHECKED()->CallVoidMethodA(env,obj,methodID,args);
 981      -    functionExit(env);
     1036 +    thr->set_pending_jni_exception_check("CallVoidMethodA");
     1037 +    functionExit(thr);
 982 1038  JNI_END
 983 1039  
 984 1040  #define WRAPPER_CallNonvirtualMethod(ResultType, Result) \
 985 1041  JNI_ENTRY_CHECKED(ResultType,  \
 986 1042    checked_jni_CallNonvirtual##Result##Method(JNIEnv *env, \
 987 1043                                               jobject obj, \
 988 1044                                               jclass clazz, \
 989 1045                                               jmethodID methodID, \
 990 1046                                               ...)) \
 991 1047      functionEnter(thr); \
↓ open down ↓ 2 lines elided ↑ open up ↑
 994 1050        jniCheck::validate_call_object(thr, obj, methodID); \
 995 1051        jniCheck::validate_call_class(thr, clazz, methodID); \
 996 1052      ) \
 997 1053      va_start(args,methodID); \
 998 1054      ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodV(env, \
 999 1055                                                                       obj, \
1000 1056                                                                       clazz, \
1001 1057                                                                       methodID,\
1002 1058                                                                       args); \
1003 1059      va_end(args); \
1004      -    functionExit(env); \
     1060 +    thr->set_pending_jni_exception_check("CallNonvirtual"#Result"Method"); \
     1061 +    functionExit(thr); \
1005 1062      return result; \
1006 1063  JNI_END \
1007 1064  \
1008 1065  JNI_ENTRY_CHECKED(ResultType,  \
1009 1066    checked_jni_CallNonvirtual##Result##MethodV(JNIEnv *env, \
1010 1067                                                jobject obj, \
1011 1068                                                jclass clazz, \
1012 1069                                                jmethodID methodID, \
1013 1070                                                va_list args)) \
1014 1071      functionEnter(thr); \
1015 1072      IN_VM( \
1016 1073        jniCheck::validate_call_object(thr, obj, methodID); \
1017 1074        jniCheck::validate_call_class(thr, clazz, methodID); \
1018 1075      ) \
1019 1076      ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodV(env, \
1020 1077                                                                       obj, \
1021 1078                                                                       clazz, \
1022 1079                                                                       methodID,\
1023 1080                                                                       args); \
1024      -    functionExit(env); \
     1081 +    thr->set_pending_jni_exception_check("CallNonvirtual"#Result"MethodV"); \
     1082 +    functionExit(thr); \
1025 1083      return result; \
1026 1084  JNI_END \
1027 1085  \
1028 1086  JNI_ENTRY_CHECKED(ResultType,  \
1029 1087    checked_jni_CallNonvirtual##Result##MethodA(JNIEnv *env, \
1030 1088                                                jobject obj, \
1031 1089                                                jclass clazz, \
1032 1090                                                jmethodID methodID, \
1033 1091                                                const jvalue * args)) \
1034 1092      functionEnter(thr); \
1035 1093      IN_VM( \
1036 1094        jniCheck::validate_call_object(thr, obj, methodID); \
1037 1095        jniCheck::validate_call_class(thr, clazz, methodID); \
1038 1096      ) \
1039 1097      ResultType result = UNCHECKED()->CallNonvirtual##Result##MethodA(env, \
1040 1098                                                                       obj, \
1041 1099                                                                       clazz, \
1042 1100                                                                       methodID,\
1043 1101                                                                       args); \
1044      -    functionExit(env); \
     1102 +    thr->set_pending_jni_exception_check("CallNonvirtual"#Result"MethodA"); \
     1103 +    functionExit(thr); \
1045 1104      return result; \
1046 1105  JNI_END
1047 1106  
1048 1107  WRAPPER_CallNonvirtualMethod(jobject,Object)
1049 1108  WRAPPER_CallNonvirtualMethod(jboolean,Boolean)
1050 1109  WRAPPER_CallNonvirtualMethod(jbyte,Byte)
1051 1110  WRAPPER_CallNonvirtualMethod(jshort,Short)
1052 1111  WRAPPER_CallNonvirtualMethod(jchar,Char)
1053 1112  WRAPPER_CallNonvirtualMethod(jint,Int)
1054 1113  WRAPPER_CallNonvirtualMethod(jlong,Long)
↓ open down ↓ 8 lines elided ↑ open up ↑
1063 1122                                         ...))
1064 1123      functionEnter(thr);
1065 1124      va_list args;
1066 1125      IN_VM(
1067 1126        jniCheck::validate_call_object(thr, obj, methodID);
1068 1127        jniCheck::validate_call_class(thr, clazz, methodID);
1069 1128      )
1070 1129      va_start(args,methodID);
1071 1130      UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args);
1072 1131      va_end(args);
1073      -    functionExit(env);
     1132 +    thr->set_pending_jni_exception_check("CallNonvirtualVoidMethod");
     1133 +    functionExit(thr);
1074 1134  JNI_END
1075 1135  
1076 1136  JNI_ENTRY_CHECKED(void,
1077 1137    checked_jni_CallNonvirtualVoidMethodV(JNIEnv *env,
1078 1138                                          jobject obj,
1079 1139                                          jclass clazz,
1080 1140                                          jmethodID methodID,
1081 1141                                          va_list args))
1082 1142      functionEnter(thr);
1083 1143      IN_VM(
1084 1144        jniCheck::validate_call_object(thr, obj, methodID);
1085 1145        jniCheck::validate_call_class(thr, clazz, methodID);
1086 1146      )
1087 1147      UNCHECKED()->CallNonvirtualVoidMethodV(env,obj,clazz,methodID,args);
1088      -    functionExit(env);
     1148 +    thr->set_pending_jni_exception_check("CallNonvirtualVoidMethodV");
     1149 +    functionExit(thr);
1089 1150  JNI_END
1090 1151  
1091 1152  JNI_ENTRY_CHECKED(void,
1092 1153    checked_jni_CallNonvirtualVoidMethodA(JNIEnv *env,
1093 1154                                          jobject obj,
1094 1155                                          jclass clazz,
1095 1156                                          jmethodID methodID,
1096 1157                                          const jvalue * args))
1097 1158      functionEnter(thr);
1098 1159      IN_VM(
1099 1160        jniCheck::validate_call_object(thr, obj, methodID);
1100 1161        jniCheck::validate_call_class(thr, clazz, methodID);
1101 1162      )
1102 1163      UNCHECKED()->CallNonvirtualVoidMethodA(env,obj,clazz,methodID,args);
1103      -    functionExit(env);
     1164 +    thr->set_pending_jni_exception_check("CallNonvirtualVoidMethodA");
     1165 +    functionExit(thr);
1104 1166  JNI_END
1105 1167  
1106 1168  JNI_ENTRY_CHECKED(jfieldID,
1107 1169    checked_jni_GetFieldID(JNIEnv *env,
1108 1170                           jclass clazz,
1109 1171                           const char *name,
1110 1172                           const char *sig))
1111 1173      functionEnter(thr);
1112 1174      IN_VM(
1113 1175        jniCheck::validate_class(thr, clazz, false);
1114 1176      )
1115 1177      jfieldID result = UNCHECKED()->GetFieldID(env,clazz,name,sig);
1116      -    functionExit(env);
     1178 +    functionExit(thr);
1117 1179      return result;
1118 1180  JNI_END
1119 1181  
1120 1182  #define WRAPPER_GetField(ReturnType,Result,FieldType) \
1121 1183  JNI_ENTRY_CHECKED(ReturnType,  \
1122 1184    checked_jni_Get##Result##Field(JNIEnv *env, \
1123 1185                                   jobject obj, \
1124 1186                                   jfieldID fieldID)) \
1125 1187      functionEnter(thr); \
1126 1188      IN_VM( \
1127 1189        checkInstanceFieldID(thr, fieldID, obj, FieldType); \
1128 1190      ) \
1129 1191      ReturnType result = UNCHECKED()->Get##Result##Field(env,obj,fieldID); \
1130      -    functionExit(env); \
     1192 +    functionExit(thr); \
1131 1193      return result; \
1132 1194  JNI_END
1133 1195  
1134 1196  WRAPPER_GetField(jobject,  Object,  T_OBJECT)
1135 1197  WRAPPER_GetField(jboolean, Boolean, T_BOOLEAN)
1136 1198  WRAPPER_GetField(jbyte,    Byte,    T_BYTE)
1137 1199  WRAPPER_GetField(jshort,   Short,   T_SHORT)
1138 1200  WRAPPER_GetField(jchar,    Char,    T_CHAR)
1139 1201  WRAPPER_GetField(jint,     Int,     T_INT)
1140 1202  WRAPPER_GetField(jlong,    Long,    T_LONG)
↓ open down ↓ 4 lines elided ↑ open up ↑
1145 1207  JNI_ENTRY_CHECKED(void,  \
1146 1208    checked_jni_Set##Result##Field(JNIEnv *env, \
1147 1209                                   jobject obj, \
1148 1210                                   jfieldID fieldID, \
1149 1211                                   ValueType val)) \
1150 1212      functionEnter(thr); \
1151 1213      IN_VM( \
1152 1214        checkInstanceFieldID(thr, fieldID, obj, FieldType); \
1153 1215      ) \
1154 1216      UNCHECKED()->Set##Result##Field(env,obj,fieldID,val); \
1155      -    functionExit(env); \
     1217 +    functionExit(thr); \
1156 1218  JNI_END
1157 1219  
1158 1220  WRAPPER_SetField(jobject,  Object,  T_OBJECT)
1159 1221  WRAPPER_SetField(jboolean, Boolean, T_BOOLEAN)
1160 1222  WRAPPER_SetField(jbyte,    Byte,    T_BYTE)
1161 1223  WRAPPER_SetField(jshort,   Short,   T_SHORT)
1162 1224  WRAPPER_SetField(jchar,    Char,    T_CHAR)
1163 1225  WRAPPER_SetField(jint,     Int,     T_INT)
1164 1226  WRAPPER_SetField(jlong,    Long,    T_LONG)
1165 1227  WRAPPER_SetField(jfloat,   Float,   T_FLOAT)
↓ open down ↓ 3 lines elided ↑ open up ↑
1169 1231  JNI_ENTRY_CHECKED(jmethodID,
1170 1232    checked_jni_GetStaticMethodID(JNIEnv *env,
1171 1233                                  jclass clazz,
1172 1234                                  const char *name,
1173 1235                                  const char *sig))
1174 1236      functionEnter(thr);
1175 1237      IN_VM(
1176 1238        jniCheck::validate_class(thr, clazz, false);
1177 1239      )
1178 1240      jmethodID result = UNCHECKED()->GetStaticMethodID(env,clazz,name,sig);
1179      -    functionExit(env);
     1241 +    functionExit(thr);
1180 1242      return result;
1181 1243  JNI_END
1182 1244  
1183 1245  #define WRAPPER_CallStaticMethod(ReturnType,Result) \
1184 1246  JNI_ENTRY_CHECKED(ReturnType,  \
1185 1247    checked_jni_CallStatic##Result##Method(JNIEnv *env, \
1186 1248                                           jclass clazz, \
1187 1249                                           jmethodID methodID, \
1188 1250                                           ...)) \
1189 1251      functionEnter(thr); \
↓ open down ↓ 1 lines elided ↑ open up ↑
1191 1253      IN_VM( \
1192 1254        jniCheck::validate_jmethod_id(thr, methodID); \
1193 1255        jniCheck::validate_class(thr, clazz, false); \
1194 1256      ) \
1195 1257      va_start(args,methodID); \
1196 1258      ReturnType result = UNCHECKED()->CallStatic##Result##MethodV(env, \
1197 1259                                                                   clazz, \
1198 1260                                                                   methodID, \
1199 1261                                                                   args); \
1200 1262      va_end(args); \
1201      -    functionExit(env); \
     1263 +    thr->set_pending_jni_exception_check("CallStatic"#Result"Method"); \
     1264 +    functionExit(thr); \
1202 1265      return result; \
1203 1266  JNI_END \
1204 1267  \
1205 1268  JNI_ENTRY_CHECKED(ReturnType,  \
1206 1269    checked_jni_CallStatic##Result##MethodV(JNIEnv *env, \
1207 1270                                            jclass clazz, \
1208 1271                                            jmethodID methodID,\
1209 1272                                            va_list args)) \
1210 1273      functionEnter(thr); \
1211 1274      IN_VM( \
1212 1275        jniCheck::validate_jmethod_id(thr, methodID); \
1213 1276        jniCheck::validate_class(thr, clazz, false); \
1214 1277      ) \
1215 1278      ReturnType result = UNCHECKED()->CallStatic##Result##MethodV(env, \
1216 1279                                                                   clazz, \
1217 1280                                                                   methodID, \
1218 1281                                                                   args); \
1219      -    functionExit(env); \
     1282 +    thr->set_pending_jni_exception_check("CallStatic"#Result"MethodV"); \
     1283 +    functionExit(thr); \
1220 1284      return result; \
1221 1285  JNI_END \
1222 1286  \
1223 1287  JNI_ENTRY_CHECKED(ReturnType,  \
1224 1288    checked_jni_CallStatic##Result##MethodA(JNIEnv *env, \
1225 1289                                            jclass clazz, \
1226 1290                                            jmethodID methodID, \
1227 1291                                            const jvalue *args)) \
1228 1292      functionEnter(thr); \
1229 1293      IN_VM( \
1230 1294        jniCheck::validate_jmethod_id(thr, methodID); \
1231 1295        jniCheck::validate_class(thr, clazz, false); \
1232 1296      ) \
1233 1297      ReturnType result = UNCHECKED()->CallStatic##Result##MethodA(env, \
1234 1298                                                                   clazz, \
1235 1299                                                                   methodID, \
1236 1300                                                                   args); \
1237      -    functionExit(env); \
     1301 +    thr->set_pending_jni_exception_check("CallStatic"#Result"MethodA"); \
     1302 +    functionExit(thr); \
1238 1303      return result; \
1239 1304  JNI_END
1240 1305  
1241 1306  WRAPPER_CallStaticMethod(jobject,Object)
1242 1307  WRAPPER_CallStaticMethod(jboolean,Boolean)
1243 1308  WRAPPER_CallStaticMethod(jbyte,Byte)
1244 1309  WRAPPER_CallStaticMethod(jshort,Short)
1245 1310  WRAPPER_CallStaticMethod(jchar,Char)
1246 1311  WRAPPER_CallStaticMethod(jint,Int)
1247 1312  WRAPPER_CallStaticMethod(jlong,Long)
↓ open down ↓ 7 lines elided ↑ open up ↑
1255 1320                                     ...))
1256 1321      functionEnter(thr);
1257 1322      va_list args;
1258 1323      IN_VM(
1259 1324        jniCheck::validate_jmethod_id(thr, methodID);
1260 1325        jniCheck::validate_class(thr, cls, false);
1261 1326      )
1262 1327      va_start(args,methodID);
1263 1328      UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args);
1264 1329      va_end(args);
1265      -    functionExit(env);
     1330 +    thr->set_pending_jni_exception_check("CallStaticVoidMethod");
     1331 +    functionExit(thr);
1266 1332  JNI_END
1267 1333  
1268 1334  JNI_ENTRY_CHECKED(void,
1269 1335    checked_jni_CallStaticVoidMethodV(JNIEnv *env,
1270 1336                                      jclass cls,
1271 1337                                      jmethodID methodID,
1272 1338                                      va_list args))
1273 1339      functionEnter(thr);
1274 1340      IN_VM(
1275 1341        jniCheck::validate_jmethod_id(thr, methodID);
1276 1342        jniCheck::validate_class(thr, cls, false);
1277 1343      )
1278 1344      UNCHECKED()->CallStaticVoidMethodV(env,cls,methodID,args);
1279      -    functionExit(env);
     1345 +    thr->set_pending_jni_exception_check("CallStaticVoidMethodV");
     1346 +    functionExit(thr);
1280 1347  JNI_END
1281 1348  
1282 1349  JNI_ENTRY_CHECKED(void,
1283 1350    checked_jni_CallStaticVoidMethodA(JNIEnv *env,
1284 1351                                      jclass cls,
1285 1352                                      jmethodID methodID,
1286 1353                                      const jvalue * args))
1287 1354      functionEnter(thr);
1288 1355      IN_VM(
1289 1356        jniCheck::validate_jmethod_id(thr, methodID);
1290 1357        jniCheck::validate_class(thr, cls, false);
1291 1358      )
1292 1359      UNCHECKED()->CallStaticVoidMethodA(env,cls,methodID,args);
1293      -    functionExit(env);
     1360 +    thr->set_pending_jni_exception_check("CallStaticVoidMethodA");
     1361 +    functionExit(thr);
1294 1362  JNI_END
1295 1363  
1296 1364  JNI_ENTRY_CHECKED(jfieldID,
1297 1365    checked_jni_GetStaticFieldID(JNIEnv *env,
1298 1366                                 jclass clazz,
1299 1367                                 const char *name,
1300 1368                                 const char *sig))
1301 1369      functionEnter(thr);
1302 1370      IN_VM(
1303 1371        jniCheck::validate_class(thr, clazz, false);
1304 1372      )
1305 1373      jfieldID result = UNCHECKED()->GetStaticFieldID(env,clazz,name,sig);
1306      -    functionExit(env);
     1374 +    functionExit(thr);
1307 1375      return result;
1308 1376  JNI_END
1309 1377  
1310 1378  #define WRAPPER_GetStaticField(ReturnType,Result,FieldType) \
1311 1379  JNI_ENTRY_CHECKED(ReturnType,  \
1312 1380    checked_jni_GetStatic##Result##Field(JNIEnv *env, \
1313 1381                                         jclass clazz, \
1314 1382                                         jfieldID fieldID)) \
1315 1383      functionEnter(thr); \
1316 1384      IN_VM( \
1317 1385        jniCheck::validate_class(thr, clazz, false); \
1318 1386        checkStaticFieldID(thr, fieldID, clazz, FieldType); \
1319 1387      ) \
1320 1388      ReturnType result = UNCHECKED()->GetStatic##Result##Field(env, \
1321 1389                                                                clazz, \
1322 1390                                                                fieldID); \
1323      -    functionExit(env); \
     1391 +    functionExit(thr); \
1324 1392      return result; \
1325 1393  JNI_END
1326 1394  
1327 1395  WRAPPER_GetStaticField(jobject,  Object,  T_OBJECT)
1328 1396  WRAPPER_GetStaticField(jboolean, Boolean, T_BOOLEAN)
1329 1397  WRAPPER_GetStaticField(jbyte,    Byte,    T_BYTE)
1330 1398  WRAPPER_GetStaticField(jshort,   Short,   T_SHORT)
1331 1399  WRAPPER_GetStaticField(jchar,    Char,    T_CHAR)
1332 1400  WRAPPER_GetStaticField(jint,     Int,     T_INT)
1333 1401  WRAPPER_GetStaticField(jlong,    Long,    T_LONG)
↓ open down ↓ 5 lines elided ↑ open up ↑
1339 1407    checked_jni_SetStatic##Result##Field(JNIEnv *env, \
1340 1408                                         jclass clazz, \
1341 1409                                         jfieldID fieldID, \
1342 1410                                         ValueType value)) \
1343 1411      functionEnter(thr); \
1344 1412      IN_VM( \
1345 1413        jniCheck::validate_class(thr, clazz, false); \
1346 1414        checkStaticFieldID(thr, fieldID, clazz, FieldType); \
1347 1415      ) \
1348 1416      UNCHECKED()->SetStatic##Result##Field(env,clazz,fieldID,value); \
1349      -    functionExit(env); \
     1417 +    functionExit(thr); \
1350 1418  JNI_END
1351 1419  
1352 1420  WRAPPER_SetStaticField(jobject,  Object,  T_OBJECT)
1353 1421  WRAPPER_SetStaticField(jboolean, Boolean, T_BOOLEAN)
1354 1422  WRAPPER_SetStaticField(jbyte,    Byte,    T_BYTE)
1355 1423  WRAPPER_SetStaticField(jshort,   Short,   T_SHORT)
1356 1424  WRAPPER_SetStaticField(jchar,    Char,    T_CHAR)
1357 1425  WRAPPER_SetStaticField(jint,     Int,     T_INT)
1358 1426  WRAPPER_SetStaticField(jlong,    Long,    T_LONG)
1359 1427  WRAPPER_SetStaticField(jfloat,   Float,   T_FLOAT)
1360 1428  WRAPPER_SetStaticField(jdouble,  Double,  T_DOUBLE)
1361 1429  
1362 1430  
1363 1431  JNI_ENTRY_CHECKED(jstring,
1364 1432    checked_jni_NewString(JNIEnv *env,
1365 1433                          const jchar *unicode,
1366 1434                          jsize len))
1367 1435      functionEnter(thr);
1368 1436      jstring result = UNCHECKED()->NewString(env,unicode,len);
1369      -    functionExit(env);
     1437 +    functionExit(thr);
1370 1438      return result;
1371 1439  JNI_END
1372 1440  
1373 1441  JNI_ENTRY_CHECKED(jsize,
1374 1442    checked_jni_GetStringLength(JNIEnv *env,
1375 1443                                jstring str))
1376 1444      functionEnter(thr);
1377 1445      IN_VM(
1378 1446        checkString(thr, str);
1379 1447      )
1380 1448      jsize result = UNCHECKED()->GetStringLength(env,str);
1381      -    functionExit(env);
     1449 +    functionExit(thr);
1382 1450      return result;
1383 1451  JNI_END
1384 1452  
1385 1453  // Arbitrary (but well-known) tag
1386 1454  const void* STRING_TAG = (void*)0x47114711;
1387 1455  
1388 1456  JNI_ENTRY_CHECKED(const jchar *,
1389 1457    checked_jni_GetStringChars(JNIEnv *env,
1390 1458                               jstring str,
1391 1459                               jboolean *isCopy))
↓ open down ↓ 8 lines elided ↑ open up ↑
1400 1468        size_t len = UNCHECKED()->GetStringLength(env,str) + 1; // + 1 for NULL termination
1401 1469        len *= sizeof(jchar);
1402 1470        new_result = (jchar*) GuardedMemory::wrap_copy(result, len, STRING_TAG);
1403 1471        if (new_result == NULL) {
1404 1472          vm_exit_out_of_memory(len, OOM_MALLOC_ERROR, "checked_jni_GetStringChars");
1405 1473        }
1406 1474        // Avoiding call to UNCHECKED()->ReleaseStringChars() since that will fire unexpected dtrace probes
1407 1475        // Note that the dtrace arguments for the allocated memory will not match up with this solution.
1408 1476        FreeHeap((char*)result);
1409 1477      }
1410      -    functionExit(env);
     1478 +    functionExit(thr);
1411 1479      return new_result;
1412 1480  JNI_END
1413 1481  
1414 1482  JNI_ENTRY_CHECKED(void,
1415 1483    checked_jni_ReleaseStringChars(JNIEnv *env,
1416 1484                                   jstring str,
1417 1485                                   const jchar *chars))
1418 1486      functionEnterExceptionAllowed(thr);
1419 1487      IN_VM(
1420 1488        checkString(thr, str);
↓ open down ↓ 14 lines elided ↑ open up ↑
1435 1503        if (guarded.get_tag() != STRING_TAG) {
1436 1504          tty->print_cr("ReleaseStringChars: called on something not allocated "
1437 1505              "by GetStringChars. string: " PTR_FORMAT " chars: " PTR_FORMAT,
1438 1506              p2i(str), p2i(chars));
1439 1507          NativeReportJNIFatalError(thr, "ReleaseStringChars called on something "
1440 1508              "not allocated by GetStringChars");
1441 1509        }
1442 1510         UNCHECKED()->ReleaseStringChars(env, str,
1443 1511             (const jchar*) guarded.release_for_freeing());
1444 1512      }
1445      -    functionExit(env);
     1513 +    functionExit(thr);
1446 1514  JNI_END
1447 1515  
1448 1516  JNI_ENTRY_CHECKED(jstring,
1449 1517    checked_jni_NewStringUTF(JNIEnv *env,
1450 1518                             const char *utf))
1451 1519      functionEnter(thr);
1452 1520      jstring result = UNCHECKED()->NewStringUTF(env,utf);
1453      -    functionExit(env);
     1521 +    functionExit(thr);
1454 1522      return result;
1455 1523  JNI_END
1456 1524  
1457 1525  JNI_ENTRY_CHECKED(jsize,
1458 1526    checked_jni_GetStringUTFLength(JNIEnv *env,
1459 1527                                   jstring str))
1460 1528      functionEnter(thr);
1461 1529      IN_VM(
1462 1530        checkString(thr, str);
1463 1531      )
1464 1532      jsize result = UNCHECKED()->GetStringUTFLength(env,str);
1465      -    functionExit(env);
     1533 +    functionExit(thr);
1466 1534      return result;
1467 1535  JNI_END
1468 1536  
1469 1537  // Arbitrary (but well-known) tag - different than GetStringChars
1470 1538  const void* STRING_UTF_TAG = (void*) 0x48124812;
1471 1539  
1472 1540  JNI_ENTRY_CHECKED(const char *,
1473 1541    checked_jni_GetStringUTFChars(JNIEnv *env,
1474 1542                                  jstring str,
1475 1543                                  jboolean *isCopy))
↓ open down ↓ 7 lines elided ↑ open up ↑
1483 1551      if (result != NULL) {
1484 1552        size_t len = strlen(result) + 1; // + 1 for NULL termination
1485 1553        new_result = (char*) GuardedMemory::wrap_copy(result, len, STRING_UTF_TAG);
1486 1554        if (new_result == NULL) {
1487 1555          vm_exit_out_of_memory(len, OOM_MALLOC_ERROR, "checked_jni_GetStringUTFChars");
1488 1556        }
1489 1557        // Avoiding call to UNCHECKED()->ReleaseStringUTFChars() since that will fire unexpected dtrace probes
1490 1558        // Note that the dtrace arguments for the allocated memory will not match up with this solution.
1491 1559        FreeHeap((char*)result, mtInternal);
1492 1560      }
1493      -    functionExit(env);
     1561 +    functionExit(thr);
1494 1562      return new_result;
1495 1563  JNI_END
1496 1564  
1497 1565  JNI_ENTRY_CHECKED(void,
1498 1566    checked_jni_ReleaseStringUTFChars(JNIEnv *env,
1499 1567                                      jstring str,
1500 1568                                      const char* chars))
1501 1569      functionEnterExceptionAllowed(thr);
1502 1570      IN_VM(
1503 1571        checkString(thr, str);
↓ open down ↓ 14 lines elided ↑ open up ↑
1518 1586        if (guarded.get_tag() != STRING_UTF_TAG) {
1519 1587          tty->print_cr("ReleaseStringUTFChars: called on something not "
1520 1588              "allocated by GetStringUTFChars. string: " PTR_FORMAT " chars: "
1521 1589              PTR_FORMAT, p2i(str), p2i(chars));
1522 1590          NativeReportJNIFatalError(thr, "ReleaseStringUTFChars "
1523 1591              "called on something not allocated by GetStringUTFChars");
1524 1592        }
1525 1593        UNCHECKED()->ReleaseStringUTFChars(env, str,
1526 1594            (const char*) guarded.release_for_freeing());
1527 1595      }
1528      -    functionExit(env);
     1596 +    functionExit(thr);
1529 1597  JNI_END
1530 1598  
1531 1599  JNI_ENTRY_CHECKED(jsize,
1532 1600    checked_jni_GetArrayLength(JNIEnv *env,
1533 1601                               jarray array))
1534 1602      functionEnter(thr);
1535 1603      IN_VM(
1536 1604        check_is_array(thr, array);
1537 1605      )
1538 1606      jsize result = UNCHECKED()->GetArrayLength(env,array);
1539      -    functionExit(env);
     1607 +    functionExit(thr);
1540 1608      return result;
1541 1609  JNI_END
1542 1610  
1543 1611  JNI_ENTRY_CHECKED(jobjectArray,
1544 1612    checked_jni_NewObjectArray(JNIEnv *env,
1545 1613                               jsize len,
1546 1614                               jclass clazz,
1547 1615                               jobject init))
1548 1616      functionEnter(thr);
1549 1617      jobjectArray result = UNCHECKED()->NewObjectArray(env,len,clazz,init);
1550      -    functionExit(env);
     1618 +    functionExit(thr);
1551 1619      return result;
1552 1620  JNI_END
1553 1621  
1554 1622  JNI_ENTRY_CHECKED(jobject,
1555 1623    checked_jni_GetObjectArrayElement(JNIEnv *env,
1556 1624                                      jobjectArray array,
1557 1625                                      jsize index))
1558 1626      functionEnter(thr);
1559 1627      IN_VM(
1560 1628        check_is_obj_array(thr, array);
1561 1629      )
1562 1630      jobject result = UNCHECKED()->GetObjectArrayElement(env,array,index);
1563      -    functionExit(env);
     1631 +    thr->set_pending_jni_exception_check("GetObjectArrayElement");
     1632 +    functionExit(thr);
1564 1633      return result;
1565 1634  JNI_END
1566 1635  
1567 1636  JNI_ENTRY_CHECKED(void,
1568 1637    checked_jni_SetObjectArrayElement(JNIEnv *env,
1569 1638                                      jobjectArray array,
1570 1639                                      jsize index,
1571 1640                                      jobject val))
1572 1641      functionEnter(thr);
1573 1642      IN_VM(
1574 1643        check_is_obj_array(thr, array);
1575 1644      )
1576 1645      UNCHECKED()->SetObjectArrayElement(env,array,index,val);
1577      -    functionExit(env);
     1646 +    thr->set_pending_jni_exception_check("SetObjectArrayElement");
     1647 +    functionExit(thr);
1578 1648  JNI_END
1579 1649  
1580 1650  #define WRAPPER_NewScalarArray(Return, Result) \
1581 1651  JNI_ENTRY_CHECKED(Return, \
1582 1652    checked_jni_New##Result##Array(JNIEnv *env, \
1583 1653                                   jsize len)) \
1584 1654      functionEnter(thr); \
1585 1655      Return result = UNCHECKED()->New##Result##Array(env,len); \
1586      -    functionExit(env); \
     1656 +    functionExit(thr); \
1587 1657      return (Return) result; \
1588 1658  JNI_END
1589 1659  
1590 1660  WRAPPER_NewScalarArray(jbooleanArray, Boolean)
1591 1661  WRAPPER_NewScalarArray(jbyteArray, Byte)
1592 1662  WRAPPER_NewScalarArray(jshortArray, Short)
1593 1663  WRAPPER_NewScalarArray(jcharArray, Char)
1594 1664  WRAPPER_NewScalarArray(jintArray, Int)
1595 1665  WRAPPER_NewScalarArray(jlongArray, Long)
1596 1666  WRAPPER_NewScalarArray(jfloatArray, Float)
↓ open down ↓ 7 lines elided ↑ open up ↑
1604 1674      functionEnter(thr); \
1605 1675      IN_VM( \
1606 1676        check_primitive_array_type(thr, array, ElementTag); \
1607 1677      ) \
1608 1678      ElementType *result = UNCHECKED()->Get##Result##ArrayElements(env, \
1609 1679                                                                    array, \
1610 1680                                                                    isCopy); \
1611 1681      if (result != NULL) { \
1612 1682        result = (ElementType *) check_jni_wrap_copy_array(thr, array, result); \
1613 1683      } \
1614      -    functionExit(env); \
     1684 +    functionExit(thr); \
1615 1685      return result; \
1616 1686  JNI_END
1617 1687  
1618 1688  WRAPPER_GetScalarArrayElements(T_BOOLEAN, jboolean, Boolean)
1619 1689  WRAPPER_GetScalarArrayElements(T_BYTE,    jbyte,    Byte)
1620 1690  WRAPPER_GetScalarArrayElements(T_SHORT,   jshort,   Short)
1621 1691  WRAPPER_GetScalarArrayElements(T_CHAR,    jchar,    Char)
1622 1692  WRAPPER_GetScalarArrayElements(T_INT,     jint,     Int)
1623 1693  WRAPPER_GetScalarArrayElements(T_LONG,    jlong,    Long)
1624 1694  WRAPPER_GetScalarArrayElements(T_FLOAT,   jfloat,   Float)
↓ open down ↓ 7 lines elided ↑ open up ↑
1632 1702                                               jint mode)) \
1633 1703      functionEnterExceptionAllowed(thr); \
1634 1704      IN_VM( \
1635 1705        check_primitive_array_type(thr, array, ElementTag); \
1636 1706        ASSERT_OOPS_ALLOWED; \
1637 1707        typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \
1638 1708      ) \
1639 1709      ElementType* orig_result = (ElementType *) check_wrapped_array_release( \
1640 1710          thr, "checked_jni_Release"#Result"ArrayElements", array, elems, mode); \
1641 1711      UNCHECKED()->Release##Result##ArrayElements(env, array, orig_result, mode); \
1642      -    functionExit(env); \
     1712 +    functionExit(thr); \
1643 1713  JNI_END
1644 1714  
1645 1715  WRAPPER_ReleaseScalarArrayElements(T_BOOLEAN,jboolean, Boolean, bool)
1646 1716  WRAPPER_ReleaseScalarArrayElements(T_BYTE,   jbyte,    Byte,    byte)
1647 1717  WRAPPER_ReleaseScalarArrayElements(T_SHORT,  jshort,   Short,   short)
1648 1718  WRAPPER_ReleaseScalarArrayElements(T_CHAR,   jchar,    Char,    char)
1649 1719  WRAPPER_ReleaseScalarArrayElements(T_INT,    jint,     Int,     int)
1650 1720  WRAPPER_ReleaseScalarArrayElements(T_LONG,   jlong,    Long,    long)
1651 1721  WRAPPER_ReleaseScalarArrayElements(T_FLOAT,  jfloat,   Float,   float)
1652 1722  WRAPPER_ReleaseScalarArrayElements(T_DOUBLE, jdouble,  Double,  double)
↓ open down ↓ 3 lines elided ↑ open up ↑
1656 1726    checked_jni_Get##Result##ArrayRegion(JNIEnv *env, \
1657 1727                                         ElementType##Array array, \
1658 1728                                         jsize start, \
1659 1729                                         jsize len, \
1660 1730                                         ElementType *buf)) \
1661 1731      functionEnter(thr); \
1662 1732      IN_VM( \
1663 1733        check_primitive_array_type(thr, array, ElementTag); \
1664 1734      ) \
1665 1735      UNCHECKED()->Get##Result##ArrayRegion(env,array,start,len,buf); \
1666      -    functionExit(env); \
     1736 +    thr->set_pending_jni_exception_check("Get"#Result"ArrayRegion"); \
     1737 +    functionExit(thr); \
1667 1738  JNI_END
1668 1739  
1669 1740  WRAPPER_GetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean)
1670 1741  WRAPPER_GetScalarArrayRegion(T_BYTE,    jbyte,    Byte)
1671 1742  WRAPPER_GetScalarArrayRegion(T_SHORT,   jshort,   Short)
1672 1743  WRAPPER_GetScalarArrayRegion(T_CHAR,    jchar,    Char)
1673 1744  WRAPPER_GetScalarArrayRegion(T_INT,     jint,     Int)
1674 1745  WRAPPER_GetScalarArrayRegion(T_LONG,    jlong,    Long)
1675 1746  WRAPPER_GetScalarArrayRegion(T_FLOAT,   jfloat,   Float)
1676 1747  WRAPPER_GetScalarArrayRegion(T_DOUBLE,  jdouble,  Double)
↓ open down ↓ 3 lines elided ↑ open up ↑
1680 1751    checked_jni_Set##Result##ArrayRegion(JNIEnv *env, \
1681 1752                                         ElementType##Array array, \
1682 1753                                         jsize start, \
1683 1754                                         jsize len, \
1684 1755                                         const ElementType *buf)) \
1685 1756      functionEnter(thr); \
1686 1757      IN_VM( \
1687 1758        check_primitive_array_type(thr, array, ElementTag); \
1688 1759      ) \
1689 1760      UNCHECKED()->Set##Result##ArrayRegion(env,array,start,len,buf); \
1690      -    functionExit(env); \
     1761 +    thr->set_pending_jni_exception_check("Set"#Result"ArrayRegion"); \
     1762 +    functionExit(thr); \
1691 1763  JNI_END
1692 1764  
1693 1765  WRAPPER_SetScalarArrayRegion(T_BOOLEAN, jboolean, Boolean)
1694 1766  WRAPPER_SetScalarArrayRegion(T_BYTE,    jbyte,    Byte)
1695 1767  WRAPPER_SetScalarArrayRegion(T_SHORT,   jshort,   Short)
1696 1768  WRAPPER_SetScalarArrayRegion(T_CHAR,    jchar,    Char)
1697 1769  WRAPPER_SetScalarArrayRegion(T_INT,     jint,     Int)
1698 1770  WRAPPER_SetScalarArrayRegion(T_LONG,    jlong,    Long)
1699 1771  WRAPPER_SetScalarArrayRegion(T_FLOAT,   jfloat,   Float)
1700 1772  WRAPPER_SetScalarArrayRegion(T_DOUBLE,  jdouble,  Double)
1701 1773  
1702 1774  JNI_ENTRY_CHECKED(jint,
1703 1775    checked_jni_RegisterNatives(JNIEnv *env,
1704 1776                                jclass clazz,
1705 1777                                const JNINativeMethod *methods,
1706 1778                                jint nMethods))
1707 1779      functionEnter(thr);
1708 1780      jint result = UNCHECKED()->RegisterNatives(env,clazz,methods,nMethods);
1709      -    functionExit(env);
     1781 +    functionExit(thr);
1710 1782      return result;
1711 1783  JNI_END
1712 1784  
1713 1785  JNI_ENTRY_CHECKED(jint,
1714 1786    checked_jni_UnregisterNatives(JNIEnv *env,
1715 1787                                  jclass clazz))
1716 1788      functionEnter(thr);
1717 1789      jint result = UNCHECKED()->UnregisterNatives(env,clazz);
1718      -    functionExit(env);
     1790 +    functionExit(thr);
1719 1791      return result;
1720 1792  JNI_END
1721 1793  
1722 1794  JNI_ENTRY_CHECKED(jint,
1723 1795    checked_jni_MonitorEnter(JNIEnv *env,
1724 1796                             jobject obj))
1725 1797      functionEnter(thr);
1726 1798      IN_VM(
1727 1799        jniCheck::validate_object(thr, obj);
1728 1800      )
1729 1801      jint result = UNCHECKED()->MonitorEnter(env,obj);
1730      -    functionExit(env);
     1802 +    functionExit(thr);
1731 1803      return result;
1732 1804  JNI_END
1733 1805  
1734 1806  JNI_ENTRY_CHECKED(jint,
1735 1807    checked_jni_MonitorExit(JNIEnv *env,
1736 1808                            jobject obj))
1737 1809      functionEnterExceptionAllowed(thr);
1738 1810      IN_VM(
1739 1811        jniCheck::validate_object(thr, obj);
1740 1812      )
1741 1813      jint result = UNCHECKED()->MonitorExit(env,obj);
1742      -    functionExit(env);
     1814 +    functionExit(thr);
1743 1815      return result;
1744 1816  JNI_END
1745 1817  
1746 1818  JNI_ENTRY_CHECKED(jint,
1747 1819    checked_jni_GetJavaVM(JNIEnv *env,
1748 1820                          JavaVM **vm))
1749 1821      functionEnter(thr);
1750 1822      jint result = UNCHECKED()->GetJavaVM(env,vm);
1751      -    functionExit(env);
     1823 +    functionExit(thr);
1752 1824      return result;
1753 1825  JNI_END
1754 1826  
1755 1827  JNI_ENTRY_CHECKED(void,
1756 1828    checked_jni_GetStringRegion(JNIEnv *env,
1757 1829                                jstring str,
1758 1830                                jsize start,
1759 1831                                jsize len,
1760 1832                                jchar *buf))
1761 1833      functionEnter(thr);
1762 1834      IN_VM(
1763 1835        checkString(thr, str);
1764 1836      )
1765 1837      UNCHECKED()->GetStringRegion(env, str, start, len, buf);
1766      -    functionExit(env);
     1838 +    thr->set_pending_jni_exception_check("GetStringRegion");
     1839 +    functionExit(thr);
1767 1840  JNI_END
1768 1841  
1769 1842  JNI_ENTRY_CHECKED(void,
1770 1843    checked_jni_GetStringUTFRegion(JNIEnv *env,
1771 1844                                   jstring str,
1772 1845                                   jsize start,
1773 1846                                   jsize len,
1774 1847                                   char *buf))
1775 1848      functionEnter(thr);
1776 1849      IN_VM(
1777 1850        checkString(thr, str);
1778 1851      )
1779 1852      UNCHECKED()->GetStringUTFRegion(env, str, start, len, buf);
1780      -    functionExit(env);
     1853 +    thr->set_pending_jni_exception_check("GetStringUTFRegion");
     1854 +    functionExit(thr);
1781 1855  JNI_END
1782 1856  
1783 1857  JNI_ENTRY_CHECKED(void *,
1784 1858    checked_jni_GetPrimitiveArrayCritical(JNIEnv *env,
1785 1859                                          jarray array,
1786 1860                                          jboolean *isCopy))
1787 1861      functionEnterCritical(thr);
1788 1862      IN_VM(
1789 1863        check_is_primitive_array(thr, array);
1790 1864      )
1791 1865      void *result = UNCHECKED()->GetPrimitiveArrayCritical(env, array, isCopy);
1792 1866      if (result != NULL) {
1793 1867        result = check_jni_wrap_copy_array(thr, array, result);
1794 1868      }
1795      -    functionExit(env);
     1869 +    functionExit(thr);
1796 1870      return result;
1797 1871  JNI_END
1798 1872  
1799 1873  JNI_ENTRY_CHECKED(void,
1800 1874    checked_jni_ReleasePrimitiveArrayCritical(JNIEnv *env,
1801 1875                                              jarray array,
1802 1876                                              void *carray,
1803 1877                                              jint mode))
1804 1878      functionEnterCriticalExceptionAllowed(thr);
1805 1879      IN_VM(
1806 1880        check_is_primitive_array(thr, array);
1807 1881      )
1808 1882      // Check the element array...
1809 1883      void* orig_result = check_wrapped_array_release(thr, "ReleasePrimitiveArrayCritical", array, carray, mode);
1810 1884      UNCHECKED()->ReleasePrimitiveArrayCritical(env, array, orig_result, mode);
1811      -    functionExit(env);
     1885 +    functionExit(thr);
1812 1886  JNI_END
1813 1887  
1814 1888  JNI_ENTRY_CHECKED(const jchar*,
1815 1889    checked_jni_GetStringCritical(JNIEnv *env,
1816 1890                                  jstring string,
1817 1891                                  jboolean *isCopy))
1818 1892      functionEnterCritical(thr);
1819 1893      IN_VM(
1820 1894        checkString(thr, string);
1821 1895      )
1822 1896      const jchar *result = UNCHECKED()->GetStringCritical(env, string, isCopy);
1823      -    functionExit(env);
     1897 +    functionExit(thr);
1824 1898      return result;
1825 1899  JNI_END
1826 1900  
1827 1901  JNI_ENTRY_CHECKED(void,
1828 1902    checked_jni_ReleaseStringCritical(JNIEnv *env,
1829 1903                                      jstring str,
1830 1904                                      const jchar *chars))
1831 1905      functionEnterCriticalExceptionAllowed(thr);
1832 1906      IN_VM(
1833 1907        checkString(thr, str);
1834 1908      )
1835 1909      /* The Hotspot JNI code does not use the parameters, so just check the
1836 1910       * string parameter as a minor sanity check
1837 1911       */
1838 1912      UNCHECKED()->ReleaseStringCritical(env, str, chars);
1839      -    functionExit(env);
     1913 +    functionExit(thr);
1840 1914  JNI_END
1841 1915  
1842 1916  JNI_ENTRY_CHECKED(jweak,
1843 1917    checked_jni_NewWeakGlobalRef(JNIEnv *env,
1844 1918                                 jobject obj))
1845 1919      functionEnter(thr);
1846 1920      IN_VM(
1847 1921        if (obj != NULL) {
1848 1922          jniCheck::validate_handle(thr, obj);
1849 1923        }
1850 1924      )
1851 1925      jweak result = UNCHECKED()->NewWeakGlobalRef(env, obj);
1852      -    functionExit(env);
     1926 +    functionExit(thr);
1853 1927      return result;
1854 1928  JNI_END
1855 1929  
1856 1930  JNI_ENTRY_CHECKED(void,
1857 1931    checked_jni_DeleteWeakGlobalRef(JNIEnv *env,
1858 1932                                    jweak ref))
1859 1933      functionEnterExceptionAllowed(thr);
1860 1934      UNCHECKED()->DeleteWeakGlobalRef(env, ref);
1861      -    functionExit(env);
     1935 +    functionExit(thr);
1862 1936  JNI_END
1863 1937  
1864 1938  JNI_ENTRY_CHECKED(jboolean,
1865 1939    checked_jni_ExceptionCheck(JNIEnv *env))
     1940 +    thr->clear_pending_jni_exception_check();
1866 1941      functionEnterExceptionAllowed(thr);
1867 1942      jboolean result = UNCHECKED()->ExceptionCheck(env);
1868      -    functionExit(env);
     1943 +    functionExit(thr);
1869 1944      return result;
1870 1945  JNI_END
1871 1946  
1872 1947  JNI_ENTRY_CHECKED(jobject,
1873 1948    checked_jni_NewDirectByteBuffer(JNIEnv *env,
1874 1949                                    void *address,
1875 1950                                    jlong capacity))
1876 1951      functionEnter(thr);
1877 1952      jobject result = UNCHECKED()->NewDirectByteBuffer(env, address, capacity);
1878      -    functionExit(env);
     1953 +    functionExit(thr);
1879 1954      return result;
1880 1955  JNI_END
1881 1956  
1882 1957  JNI_ENTRY_CHECKED(void *,
1883 1958    checked_jni_GetDirectBufferAddress(JNIEnv *env,
1884 1959                                       jobject buf))
1885 1960      functionEnter(thr);
1886 1961      void* result = UNCHECKED()->GetDirectBufferAddress(env, buf);
1887      -    functionExit(env);
     1962 +    functionExit(thr);
1888 1963      return result;
1889 1964  JNI_END
1890 1965  
1891 1966  JNI_ENTRY_CHECKED(jlong,
1892 1967    checked_jni_GetDirectBufferCapacity(JNIEnv *env,
1893 1968                                        jobject buf))
1894 1969      functionEnter(thr);
1895 1970      jlong result = UNCHECKED()->GetDirectBufferCapacity(env, buf);
1896      -    functionExit(env);
     1971 +    functionExit(thr);
1897 1972      return result;
1898 1973  JNI_END
1899 1974  
1900 1975  JNI_ENTRY_CHECKED(jobjectRefType,
1901 1976    checked_jni_GetObjectRefType(JNIEnv *env,
1902 1977                                 jobject obj))
1903 1978      functionEnter(thr);
1904 1979      /* validate the object being passed */
1905 1980      IN_VM(
1906 1981        jniCheck::validate_object(thr, obj);
1907 1982      )
1908 1983      jobjectRefType result = UNCHECKED()->GetObjectRefType(env, obj);
1909      -    functionExit(env);
     1984 +    functionExit(thr);
1910 1985      return result;
1911 1986  JNI_END
1912 1987  
1913 1988  
1914 1989  JNI_ENTRY_CHECKED(jint,
1915 1990    checked_jni_GetVersion(JNIEnv *env))
1916 1991      functionEnter(thr);
1917 1992      jint result = UNCHECKED()->GetVersion(env);
1918      -    functionExit(env);
     1993 +    functionExit(thr);
1919 1994      return result;
1920 1995  JNI_END
1921 1996  
1922 1997  
1923 1998  
1924 1999  /*
1925 2000   * Structure containing all checked jni functions
1926 2001   */
1927 2002  struct JNINativeInterface_  checked_jni_NativeInterface = {
1928 2003      NULL,
↓ open down ↓ 301 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX