Clarify exceptions thrown in JNI

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P4
    • 9
    • Affects Version/s: None
    • Component/s: hotspot

      The specification for GetString[UTF]Chars is ambiguous ( the Sheng Liang JNI book is at odds with the online specification ). It is not clear if there is a JNI pending exception if the function returns NULL.
      To ensure that an exception is thrown the following pattern (or similar) needs to be used.

            if (obj == NULL) {
                if (!(*env)->ExceptionCheck(env))
                    JNU_ThrowOutOfMemoryError(env, NULL);
                return NULL;
           }

      Since both out of memory and throwing exceptions is rare supplying extra code to check
      for conditions that do not occur is wasteful.

      Please clarify the JNI specification.

            Assignee:
            Unassigned
            Reporter:
            Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: