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

(jni) JNI function GetEnv() does not set env to NULL

XMLWordPrintable

    • 1.2fcs
    • sparc
    • solaris_2.5.1
    • Verified



      Name: ouC59006 Date: 05/21/98



      GetEnv() of JDK-1.2beta4-F fails to set env pointer to NULL
      when it returns JNI_EDETACHED or JNI_EVERSION, despite of the
      statement in the JNI Enhancements in JDK 1.2 specification,
      that reads:

      "If the current thread is not attached to the VM,
      sets *env to NULL, and returns JNI_EDETACHED. If the
      specified version is not supported, sets *env to NULL,
      and returns JNI_EVERSION."

      Reduced form of new test genv00101 illustrates the problem:

      > java -fullversion
      java full version "JDK-1.2beta4-F"
      > cc -KPIC -I${JAVA_HOME}/include -I${JAVA_HOME}/include/solaris -o genv00101 genv00101.c -L${JAVA_HOME}/lib/sparc -ljvm -lthread
      > genv00101
      > echo $status
      2
      >

      --------------------genv00101.c----------------------
      #include "jni.h"

      main (int argc, char *argv[]) {
           jint res;
      JNIEnv *env;
      JavaVMInitArgs vm_args;
      JavaVM *vm;

      vm_args.version = JNI_VERSION_1_2;
      vm_args.nOptions = 0;

      res = JNI_CreateJavaVM(&vm, (void **) &env, &vm_args);
      if ( res != JNI_OK )
      return 3;

      res = (*vm) -> GetEnv(vm, (void **) &env, (jint) 0xfafa);
      if (env != NULL)
      return 2;

           return 1;
      }
      --------------------------------------------------------------------------------

      ======================================================================

            sliangsunw Sheng Liang (Inactive)
            oulyankisunw Oleg Ulyankin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: