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

Use Reference.reachabilityFence in direct ByteBuffer methods

    Details

    • Subcomponent:
    • Resolved In Build:
      b05
    • Verification:
      Not verified

      Description

      There is a very small risk when using direct ByteBuffer that the buffer instance will be GC'ed and the buffer's memory reclaimed while the memory address is still be used by a buffer method.

      This can be fixed by judiciously using Reference.reachabilityFence to keep references alive for the duration of use. Performance reasons held up such use but further analysis has revealed that it is possible to annotate Reference.reachabilityFence with @ForceInline (rather than @DontInline) since the HotSpot compilers currently track the usage scope of variables via bytecode analysis rather than IR analysis. So even if a compiler performs dead code elimination any eliminated variables will still live beyond their use (in accordance with the bytecode usage). Other non-HotSpot compilers may differ in this behaviour.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psandoz Paul Sandoz (Inactive)
                Reporter:
                psandoz Paul Sandoz (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: