Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4067541

(jni) ExceptionDescribe has the side affect of clearing exception

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1.3
    • Fix Version/s: None
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description



      Name: rlT66838 Date: 07/25/97


      1. Build test.class and native.dll using the files below.
      2. run "java test".
      You will see that that the native method returned
      even though there should still be a thrown exception.

      The problem is caused by the fact the exceptionDescribe
      in exceptions.c uses execute_java_dynamic_method
      to call printStackTrace. execute_java_dynamic_method
      clears any thrown exceptions right before it calls
      the java method.


      /* begin test.java */
      class TestExcept2 extends Exception
      {
      }

      class test
      {
          public static void main( String[] args )
          {
              test t = new test();

              t.useJNI();

              System.out.println("useJNI returned");
          }

          public void throwExcept2() throws TestExcept2
          {
              throw new TestExcept2();
          }

          public native void useJNI();

          static
          {
              System.loadLibrary("native");
          }

      }
      /* end test.java */

      /* begin native.cpp */
      #include <jni.h>
      #include "test.h"
      #include <stdio.h>

      extern "C"
      {


      JNIEXPORT void JNICALL Java_test_useJNI
        (JNIEnv * env, jobject o)
      {

          jclass jc1, jc2;
          jobject jo1;
          int i;
          jmethodID id;


          printf("ExceptionOccurred\n=============================================\n");
          jc1 = env->GetObjectClass( o );
          id = ( jmethodID ) env->GetMethodID( jc1, "throwExcept2", "()V");
          env->CallVoidMethod( o, id );
          jo1 = env->ExceptionOccurred();

          printf("ExceptionDescribe\n=============================================\n");
          env->ExceptionDescribe();


      }

      }
      /* end native.cpp */
      company - Symantec Corp. , email - ###@###.###
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            collins Gary Collins (Inactive)
            Reporter:
            rlewis Roger Lewis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: