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

add missing wildcards to Optional or() and flatMap()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b142

      Description

      In Optional, the signature of flatMap() should be changed as follows:

      OLD: <U> Optional<U> flatMap(Function<? super T, Optional<U>> mapper)
      NEW: <U> Optional<U> flatMap(Function<? super T, Optional<? extends U>> mapper)

      The signature of or() should be changed as follows:

      OLD: Optional<T> or(Supplier<Optional<T>> supplier)
      NEW: Optional<T> or(Supplier<Optional<? extends T>> supplier)

      This will alleviate some restrictions on the mapper and supplier functions.

      Some compatibility analysis should be done on flatMap() because it was originally defined in Java 8. The or() method is new in Java 9 so there should be no compatibility impact.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              smarks Stuart Marks
              Reporter:
              smarks Stuart Marks
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: