-
CSR
-
Resolution: Approved
-
P3
-
None
-
behavioral
-
minimal
-
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.
-
Java API
-
SE
Summary
Fix the implementation of MethodHandles.filterArguments
to conform to the specification (the pseudocode) and clarify the specification as the pseudocode behaviour could easily be missed.
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. Clarify the specification.
Specification
Update to JavaDoc of java/lang/invoke/MethodHandles.java
:
* specified in the elements of the {@code filters} array.
* The first element of the filter array corresponds to the {@code pos}
* argument of the target, and so on in sequence.
+ * The filter functions are invoked in left to right order.
* <p>
* Null arguments in the array are treated as identity functions,
* and the corresponding arguments left unchanged.
- csr of
-
JDK-8194554 filterArguments runs multiple filters in the wrong order
-
- Resolved
-
- relates to
-
JDK-8201503 filterArguments runs multiple filters in the wrong order
-
- Closed
-