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

LambdaMetafactory: validate inputs and improve documentation

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 17
    • core-libs
    • None
    • behavioral
    • minimal
    • Clients who provide invalid arguments may see new or different exceptions.
    • Java API
    • SE

      Summary

      Document and enforce the conditions under which invalid arguments will cause a RuntimeException to be thrown by the LambdaMetafactory methods.

      Problem

      The LambdaMetafactory methods fail to validate their inputs. When invoked directly (as opposed to standard usage by javac), invalid arguments lead to unspecified, ad hoc RuntimeExceptions or other surprising behavior.

      Solution

      Specify four exceptions that can be thrown: LambdaConversionException, NullPointerException, IllegalArgumentException, and SecurityException. Describe the conditions under which they will be thrown.

      This is a behavioral change: certain nonstandard usages of LambdaMetafactory will result in new or different exceptions.

      Also make some clarifying revisions to specification, such as more accurately naming parameters to reflect their behavior rather than the specific way javac uses them.

      Specification

      Diff of LambdaMetafactory.java is attached. See also the code review.

            dlsmith Dan Smith
            dlsmith Dan Smith
            Brian Goetz, Mandy Chung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: