RegisterNative() does not work with the JIT

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P3
    • None
    • Affects Version/s: 1.1.5
    • Component/s: vm-legacy



      Name: chT40241 Date: 12/12/97


      We have the following C++ code in our program:
      JNI_GetDefaultJavaVMInitArgs(&vm_args);

      CString home = "java.home="+theApp.m_strInstallDir+"\\java\\bin\\..";
      properties[0] = home.GetBuffer(1);

      if (theApp.m_bEnableJIT)
      {
       TRACE("JIT enabled on build-time Java VM\n");
       properties[1] = "java.compiler=symcjit";
       properties[2] = NULL;
      }
      else
      {
       properties[1] = NULL;
       properties[2] = NULL;
      }

      vm_args.properties = properties;
      if (JNI_CreateJavaVM(&jvm, &env, &vm_args) != 0)
      {
       AfxMessageBox("Unable to start the Java Virtual Machine", MB_ICONINFORMATION);
       return FALSE;
      }
      jclass jcl = env->FindClass("com/sas/ide/FrameEventHandler");
      if (env->ExceptionOccurred())
      {
       env->ExceptionDescribe();
       env->ExceptionClear();
       AfxMessageBox("Unable to find FrameEventHandler.class");
       return FALSE;
      }

      if (jcl)
      {
       mjc_FrameEventHandler = (jclass)env->NewGlobalRef (jcl);
       env->DeleteLocalRef (jcl);

       JNINativeMethod m2[] = {
        { "componentResizeCallback", "(Ljava/awt/Component;IIII)V", CIDEMDIView::componentResizeCallback},
        { "isIDEComponent", "(Ljava/awt/Component;)Z", CIDEMDIView::isIDEComponent}
       };

       env->RegisterNatives(mjc_FrameEventHandler, m2, 2);

       if (env->ExceptionOccurred())
       {
        env->ExceptionDescribe();
        env->ExceptionClear();
        AfxMessageBox("Unable to register resize callbacks");
        return FALSE;
       }
      }

      The FrameEventHandler class has the following native method defined:
      public native void componentResizeCallback(java.awt.Component c, int x, int y, int w, int h);

      When the application is run without the JIT things work fine. When the JIT is enabled we get an UnsatisfiedLinkError thrown.
      ======================================================================

            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: