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

VarHandle combinator check for exceptions is too strict

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: repo-panama
    • Fix Version/s: None
    • Component/s: tools

      Description

      The current VarHandle combinators, such as filterCoordinate, which are currently exposed through jdk.incubator.foreign.MemoryHandles check whether the filter MethodHandle used for the combinator throws any checked exceptions.

      In the case where the filter handle is a BoundMethodHandle, the check walks all the fields of the BoundMehtodHandle, and if they are MethodHandles themselves, recursively checks if they throw any exception.

      However, this check is too strict, as even though a MethodHandle bound to a BoundMethodHandle might throw an exception, it could be caught higher up in the method handle chain, making it so the top level method handle will never throw an exception.

      The attached example illustrates the problem. Even though the exception thrown by the method 'm' is handled by the catchException combinator, the call to filterCoordinates still throws an IllegalArgumentException.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jvernee Jorn Vernee
              Reporter:
              jvernee Jorn Vernee
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: