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

Clarify the specification of JNI DestroyJavaVM in relation to "unloading the VM"

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 18
    • Fix Version/s: 18
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b19

      Description

      The specification for JNI's DestroyJavaVM starts with:

      "Unloads a Java VM and reclaims its resources."

      but then ends with:

      "Unloading of the VM is not supported."

      which is a direct contradiction and leaves it very unclear what DestroyJavaVM actually does.

      The original JNI programmers book (which was the precursor to the spec document) states the following:

      The support for DestroyJavaVM was not complete in JDK
      release 1.1; only the main thread may call DestroyJavaVM. The
      virtual machine implementation blocks until the main thread is
      the only user-level thread and returns a negative error code.

      Java 2 SDK release 1.2 still does not support unloading virtual
      machine instances. There is a slight relaxation to the use of
      DestroyJavaVM, however; any thread may call DestroyJavaVM.
      The virtual machine implementation blocks until the current
      thread is the only user thread before it returns an error code.

      ---

      I think the final sentence in the spec is what is left of that block of text. Obviously we improved things to the point where it does actually "terminate" the VM by some definition and returns JNI_OK rather than an error code. But it remains true that the VM is not actually unloaded from the process, and only some resources are reclaimed. The specification needs to be updated to clarify this.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dholmes David Holmes
              Reporter:
              dholmes David Holmes
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: