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

javadoc standard doclet should add Functional Interface blurb when @FunctionalInterface annotation is present

XMLWordPrintable

    • b124
    • Verified

        Javadoc's standard doclet adds the following blurb to functional interfaces:

            Functional Interface:

            This is a functional interface and can therefore be used as the
            assignment target for a lambda expression or method reference.

        It does so if the interface being processed matches the structure of a functional interface, that is, it has a single abstract method.

        However, not all single-abstract-method interfaces are actually suitable for use with lambda. The @FunctionalInterface annotation was added to mark the interfaces that are intended to be used with lambda. This annotation was initially added to many single-abstract-method interfaces, but later JDK-8022658 removed this annotation from some interfaces for which lambda was considered unsuitable. However, javadoc+doclet still add the documentation to all such interfaces based on their structure, not on the intent as expressed by the annotation.

        Thus, javadoc should be changed to emit the Functional Interface blurb based on the presence of the @FunctionalInterface annotation, not on the structure (single abstract method) of the interface being processed.

        Filing this as P2 since this really ought to be fixed before 8 ships, since it affects the API specification that will be posted and referred to on the web for years. (And to attract some attention as well. Sorry.)

        We still need to get buy-in from the lambda team on whether they agree this is the right thing to do, but at this writing it does seem sensible to make this change.

              bpatel Bhavesh Patel (Inactive)
              smarks Stuart Marks
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: