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

Problems with context check for JNI handle creation

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 11
    • Fix Version/s: 11
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      JDK-8167372 added checks to the JNI handle creation operations (make_local, make_global, make_weak_global), asserting !current_thread_in_native().

      As I understand it, what we need to be checking for is that the current thread is a Java thread, and that it's not "in native". If either of those is false, then the assert should fail. But that's not what we're actually checking for. We're asserting

       !current_thread_in_native
      =>
       ! ((current thread is a Java thread) && (current thread is "in native"))
      =>
       !(current thread is a Java thread) || !(current thread is "in native")

      which is not the same thing at all as

       (current thread is a Java thread) && !(current thread is "in native")

      That's all assuming I'm correct, and we should only be doing these operations from Java threads. That's not entirely clear though, as the existing assertions in the various JNIHandles::make_local overloads are inconsistent about that. (And if correct, that also raises the question of why _active_handles and _free_handle_block are in Thread rather than JavaThread.)

        Attachments

          Activity

            People

            • Assignee:
              hseigel Harold Seigel
              Reporter:
              kbarrett Kim Barrett
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: