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

Wrong JNI error code for preexisting JVM

XMLWordPrintable

    • b41

        Hello,

        I initially proposed this attached patch 3 years ago [1]
        I was wondering if this patch could be applied against the version 8. I
        tested it against the JDK 7 and 8 (the patch applies without any problem
        to both forest).

        This would save a lot of time for people who are getting this bug.
        Without it, it is hard to find out what is wrong in the JNI code.

        Thanks,
        Sylvestre
        [1]
        http://mail.openjdk.java.net/pipermail/hotspot-dev/2010-September/003340.html
        PS: please C/C me


        JNI_EEXIST-usage.diff

        # HG changeset patch
        # User Sylvestre Ledru <sylvestre@debian.org>
        # Date 1372757479 -7200
        # Node ID d02f633c4133c3e66d3a81d39923fff0c59652cb
        # Parent b6d1e42655cdf72f6747224366cd1b78b4ec9548
        Return the appropriate JNI error message (instead of the generic one) when the JVM is already started

        diff --git a/src/share/vm/prims/jni.cpp b/src/share/vm/prims/jni.cpp
        --- a/src/share/vm/prims/jni.cpp
        +++ b/src/share/vm/prims/jni.cpp
        @@ -5097,7 +5097,7 @@
           // function used to determine this will always return false. Atomic::xchg
           // does not have this problem.
           if (Atomic::xchg(1, &vm_created) == 1) {
        - return JNI_ERR; // already created, or create attempt in progress
        + return JNI_EEXIST; // already created, or create attempt in progress
           }
           if (Atomic::xchg(0, &safe_to_recreate_vm) == 0) {
             return JNI_ERR; // someone tried and failed and retry not allowed.

              coleenp Coleen Phillimore
              coleenp Coleen Phillimore
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: