NativeRegister'ed methods not found when JIT is used

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 1.1.6
    • Affects Version/s: 1.1.4, 1.1.5, 1.1.6
    • Component/s: vm-legacy
    • 1.1.6
    • x86
    • windows_95, windows_nt
    • Not verified



      Name: chT40241 Date: 01/29/98


      When the symcjit is used, native methods defined via the RegisterNatives JNI call are not called, and instead an UnsatisfiedLinkError is thrown. The code works without the JIT.

      Here is a simple test case. The Java code (JITterBug.java):

      public class JITterBug {
      static native void direct();
      static native void indirect();
      public static void main(String args[]) {
      direct();
      try {
      indirect();
      } catch(Throwable t) {
      t.printStackTrace();
      }
      }
      static {
      System.loadLibrary("JITterBugC");
      }
      }

      and the C code (JITterBugC.c):

      #include "jni.h"
      #include <stdio.h>

      __declspec(dllexport) void __stdcall Java_JITterBug_direct(void *, jobject);
      void __stdcall IndirectMethod(void *, jobject);

      __declspec(dllexport) void __stdcall Java_JITterBug_direct(void *Jenv, jobject This)
      {
      int rc;
      JNIEnv *env = (JNIEnv *) Jenv;
      JNINativeMethod methods[1] = {
      { "indirect", "()V", &IndirectMethod }};
      fprintf(stderr, "Entered direct() method.\n");
      rc = (*env)->RegisterNatives(env, This, methods, 1);
      if (rc != 0) fprintf(stderr, "RegisterNatives failed!\n");
      }

      void __stdcall IndirectMethod(void *env, jobject This)
      {
      fprintf(stderr, "Entered indirect() method.\n");
      }

      Without the JIT, stderr indicates that IndirectMethod was called, while with the JIT it shows an UnsatisfiedLinkError being thrown.


      chuck.hickey@Eng 1998-01-30

      I deleted their suggested fix, which had an error, and placed the most
      recent fix in "Suggested Fix"

            Assignee:
            Deepa Viswanathan (Inactive)
            Reporter:
            Chuck Hickey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: