JDK-8174222 : LambdaMetafactory: validate inputs and improve documentation
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2017-02-08
  • Updated: 2021-06-11
  • Resolved: 2021-06-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17 b26Fixed
Related Reports
CSR :  
Relates :  
Description
The LambdaMetafactory.metafactory and LambdaMetafactory.altMetafactory methods throw various RuntimeExceptions when given bad inputs, often because assumptions about the inputs turn out not to hold. These error conditions need to be specified, and the set of possible exception types should be reduced.

Current behavior is to throw any of:
NullPointerException
IndexOutOfBoundsException
ClassCastException
NegativeArraySizeException
ArrayStoreException
IllegalArgumentException
SecurityException
LambdaConversionException

No error occurs if altMetafactory's 'args' has unexpected trailing components.
Comments
Changeset: fc08af58 Author: Dan Smith <dlsmith@openjdk.org> Date: 2021-06-07 23:21:24 +0000 URL: https://git.openjdk.java.net/jdk/commit/fc08af58cb0571ed375a7937aac7a951ba224644
07-06-2021

Also performing some restructuring of fields in the support classes to discourage improper use of some data���for example, 'implInfo' should generally be avoided, since the "real" values sometimes need to be computed. One issue this restructuring emphasizes is that it doesn't make sense for all but one generated methods to be flagged as ACC_BRIDGE. Since these aren't bridge methods (they don't delegate to another method of the class), and aren't even necessarily filling a similar role, it's best to avoid using ACC_BRIDGE on any generated methods.
14-02-2017

Some other documentation improvements: - Describe serialization behavior (serializable, not serializable, anti-serializable) - Rename some parameters to better describe their purpose
10-02-2017