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

Embed JVM in C get "Error ID: 4F533F4C494E55580E4350500549" (perl)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • hotspot
    • x86
    • linux



      Name: stC104175 Date: 08/31/2000


      [yw@ywlap cgi-bin]$ java -version
      java version "1.3.0beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta_refresh-b09)
      Java HotSpot(TM) Client VM (build 1.3.0beta-b07, mixed mode)
      [yw@ywlap cgi-bin]$

      I try to embed JVM into Perl, and got this:
      [yw@ywlap cgi-bin]$ perl t
      Create Jvm!
      #
      # HotSpot Virtual Machine Error, Internal Error
      # Please report this error at
      # http://java.sun.com/cgi-bin/bugreport.cgi
      #
      # Error ID: 4F533F4C494E55580E4350500549
      #
      # Problematic Thread: Segmentation fault (core dumped)
      [yw@ywlap cgi-bin]$

      Basically, the perl script invokes C function, which load
      $JDKHOME/jre/lib/i386/server/libjvm.so, and use JNI
      to invoke Java VM API to access Java.

      [yw@ywlap cgi-bin]$ cat t
      #!/usr/bin/perl -w
      use Jvm;
      use Sybase::CTlib;

      new Jvm();
      [yw@ywlap cgi-bin]$


      If take "use Sybase::CTlib" out, it works fine.
      It's only has problem when use "Sybase::CTlib" module, which is from
      the 3rd party. This module maybe load some other shared lib, and cause
      the problem.(It can be downloaded from http://www.mbay.net/~mpeppler)

      The "new Jvm()" is very simple, it's implemented in C:

      JNIEnv* createJVM () {
          JNIEnv *env;
          JavaVM *jvm;
          /*JDK1_1InitArgs vm_args;*/
      JavaVMInitArgs vm_args;
          jint res;
          jclass cls;
          jmethodID mid;
          jstring jstr;
          jobjectArray args;
          char classpath[1024];

          jint (JNICALL *JNI_DefaultArgs)(void*);
          jint (JNICALL *JNI_CreateVM)(const void*,const void*,void*);
          void * dl_handle;

          /* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond */
       
          /* vm_args.version = 0x00010002; */
          vm_args.version = JNI_VERSION_1_2;
          /* printf("ver %x\n", JNI_VERSION_1_2); */
          vm_args.ignoreUnrecognized = JNI_FALSE;
          /* vm_args.options = options; */
          vm_args.nOptions = 0;

          /*
          JNI_GetDefaultJavaVMInitArgs(&vm_args);
          */

          /* dl_handle = load_so("/home/pkgs/jdk1.3/jre/lib/i386/server/libjvm.so"); *
      /
          dl_handle = load_so(g_libjvm);
          JNI_DefaultArgs = (jint (JNICALL *)(void*)) getsym (dl_handle, "JNI_GetDefau
      ltJavaVMInitArgs");
          JNI_CreateVM = (jint (JNICALL *)(const void*,const void*,void*)) getsym (dl_
      handle, "JNI_CreateJavaVM");

          (*JNI_DefaultArgs)(&vm_args);

          /* Create the Java VM */
          /* res = JNI_CreateJavaVM(&jvm,&env,&vm_args); */
          res = (*JNI_CreateVM)(&jvm,&env,&vm_args);
          if (res) {
              fprintf(stderr, "Can't create Java VM\n");
              exit(1);
          }

      return env;
      }
      (Review ID: 109145)
      ======================================================================

            myangsunw Mingyao Yang (Inactive)
            stompkinsunw Sean Tompkins (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: