Enhanced method handles [JEP-274]
The Enhanced Method Handles JEP-274 was to improve the following listed classes, to make common usage easier with improved optimizations:
MethodHandle
classMethodHandles
classMethodHandles.Lookup
class
The listed classes are all part of the java.lang.invoke
package, which has been updated as part of the Java 9 platform. The improvements were made possible through the use of lookup refinement and MethodHandle
combinations for
loops and try...finally
blocks.
In this section, we will look at the following regarding JEP-274:
- Reason for the enhancement
- Lookup functions
- Argument handling
- Additional combinations
Reason for the enhancement
This enhancement stemmed from developer feedback and the desire to make the MethodHandle
, MethodHandles
, and MethodHandles.Lookup
classes much easier to use. There was also the call to add additional use cases.
The changes resulted in the following benefits:
- Enabled precision in the usage of the
MethodHandle
API - Instantiation reduction
- Increased...