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

filterArguments runs multiple filters in the wrong order

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 10-pool
    • core-libs
    • None
    • behavioral
    • minimal
    • The likelyhood of existing method handle filter argument code relying on invocation in argument order from right to left is considered very small, since it is expected most filters will not be stateful in their results.
    • JDK

      Summary

      Fix the implementation of MethodHandles.filterArguments to conform to the specification (the pseudocode).

      Problem

      MethodHandles.filterArguments pseudocode specifies that the filter method handles are invoked in argument order from left to right. However, the implementation invoked the filter method handles from right to left. This behaviour is observable if the filter arguments retain some global state that affects the results, likely an edge case. However that edge case is exposed for string concatenation using invokedynamic where the toString implementation has side-effects that affect the String result (see JDK-8200118).

      Solution

      Fix the implementation to invoke filter method handles in argument order from left to right.

      Specification

      This is a behavioral change. There are no specification changes for JDK 10. Specification is clarified in JDK 11 CSR (JDK-8201371).

            shade Aleksey Shipilev
            darcy Joe Darcy
            Mandy Chung, Paul Sandoz
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: