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

JNI panic - it failed to throw NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.1.7
    • hotspot
    • x86
    • windows_nt



      Name: dm26566 Date: 10/21/98


      1. steps:
         javac case15.java
         javah -jni case15
         cl -c foo.c
         cl /LD /Fenative.dll foo.obj libc.lib
         java case15
      2.
      source case15.java:
      class case15 {

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

          public native int foo(case15 o);

          public static void main(String[] args)
          {
            case15 a = new case15();

            int i;

            a.foo(a);
            a.foo(null);
          }

          public void bar()
          {
              System.out.println("in bar");
          }
      }
      source foo.c:
      #include "case15.h"

      JNIEXPORT jint JNICALL Java_case15_foo (JNIEnv *env, jobject obj, jobject obj2)
      {
              jclass cls;
              jmethodID mid;

              cls = (*env)->FindClass(env, "case15");
              mid = (*env)->GetMethodID(env, cls, "bar", "()V");
              (*env)->CallVoidMethod(env, obj2, mid);
              if ((*env)->ExceptionOccurred(env) != NULL)
                printf("NullPointerException raised\n");
              else
                printf("Call to bar passed\n");
      }
      3. JNI panic: native code passed a null object to a non-static method
              at case15.main(case15.java:16)
      (Review ID: 40563)
      ======================================================================

            Unassigned Unassigned
            dmcduffisunw Dale Mcduffie (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: