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

Allow captureCallState and critical linker options to be combined

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 24
    • core-libs
    • None
    • behavioral
    • minimal
    • Use case that previously threw an exception is now accepted.
    • Java API
    • SE

      Summary

      Allow the captureCallState and critical linker options to be combined.

      Problem

      Currently, the captureCallState and the critical linker options can't be used together. After all, access to captured state (such as errno) is most likely when performing potentially blocking system calls. And, critical downcall method handles are only recommended when the target native function is guaranteed to terminate in a fixed (small) amount of time.

      There have been reports of use cases where the combination of the above linker options would be beneficial. This is especially true for clients that would like to use a heap segment to capture the call state, instead of using a native segment that is (a) more expensive to allocate, and (b) whose lifetime has to be to be managed (e.g. using an arena).

      Solution

      Relax the current restrictions, and allow the captureCallState and critical linker options to be combined. This will allow clients to use the critical linker option with allowHeap = true, and then use an heap segment as capture state segment.

      Specification

      diff --git a/src/java.base/share/classes/java/lang/foreign/Linker.java b/src/java.base/share/classes/java/lang/foreign/Linker.java
      index 5474fef66da13..f377c34eee947 100644
      --- a/src/java.base/share/classes/java/lang/foreign/Linker.java
      +++ b/src/java.base/share/classes/java/lang/foreign/Linker.java
      @@ -862,8 +862,6 @@ static Option firstVariadicArg(int index) {
                *     // use errno
                * }
                * }
      -         * <p>
      -         * This linker option can not be combined with {@link #critical}.
                *
                * @param capturedState the names of the values to save
                * @throws IllegalArgumentException if at least one of the provided

            jvernee Jorn Vernee
            jvernee Jorn Vernee
            Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: