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

(jni spec) Description of 3rd parameter to AttachCurrentThread is confusing

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 20
    • hotspot
    • None
    • minimal
    • There is no spec change here just a removal of confusing text.
    • Other
    • SE

      Summary

      Two redundant and/or confusing sentences in relation to the arguments of AttachCurrentThread are removed.

      Problem

      In Java 7, the spec was:

      In JDK 1.1, the second argument to AttachCurrentThread is always a pointer to JNIEnv. The third argument to AttachCurrentThread was reserved, and should be set to NULL.

      In JDK 1.2, you pass NULL as the third argument for 1.1 behavior, or pass a pointer to the following structure to specify additional information:

      In Java 8 it changed to just:

      The second argument to AttachCurrentThread is always a pointer to JNIEnv. The third argument to AttachCurrentThread was reserved, and should be set to NULL.

      The sentence "The second argument .." is redundant as it just repeats the definition of the second argument.

      The sentence "The third argument to ..." is not correct as it can be NULL or a pointer to a JavaVMAttachArgs structure when there is additional information to specify.

      Solution

      Delete both sentences. In doing so the following sentence also becomes redundant and can be removed:

      You pass a pointer to the following structure to specify additional information:

      Specification

      Before:

      PARAMETERS:

      vm: the VM to which the current thread will be attached, must not be NULL.

      p_env: pointer to the location where the JNI interface pointer of the current thread will be placed, must not be NULL.

      thr_args: can be NULL or a pointer to a JavaVMAttachArgs structure to specify additional information:

      The second argument to AttachCurrentThread is always a pointer to JNIEnv. The third argument to AttachCurrentThread was reserved, and should be set to NULL.

      You pass a pointer to the following structure to specify additional information:

      typedef struct JavaVMAttachArgs { ...

      After:

      PARAMETERS:

      vm: the VM to which the current thread will be attached, must not be NULL.

      p_env: pointer to the location where the JNI interface pointer of the current thread will be placed, must not be NULL.

      thr_args: can be NULL or a pointer to a JavaVMAttachArgs structure to specify additional information:

      typedef struct JavaVMAttachArgs { ...

      There is also a typographical error in the method description where the wrong parameter name is used. This:

      Attaches the current thread to a Java VM. Returns a JNI interface pointer in the JNIEnv argument.

      should say the p_env argument.

            dholmes David Holmes
            alanb Alan Bateman
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: