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

Improve documentation for Types.directSupertypes()

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P4
    • 20
    • core-libs
    • None
    • behavioral
    • minimal
    • Explicitly document existing behavior.
    • Java API
    • SE

    Description

      Summary

      Add explicit specification to Types.directSupertypes on how java.lang.Object is handled.

      Problem

      java.lang.Object is a special case in for the direct super type relationship. The specification for Types.directSupertypes does not explicitly mention this case; although the correct behavior can be inferred from the existing specification.

      Solution

      Add explicit text stating java.lang.Object has no direct super types.

      Specification

      diff --git a/src/java.compiler/share/classes/javax/lang/model/util/Types.java b/src/java.compiler/share/classes/javax/lang/model/util/Types.java
      index 02c7085bd8c..cd5a9a848a9 100644
      --- a/src/java.compiler/share/classes/javax/lang/model/util/Types.java
      +++ b/src/java.compiler/share/classes/javax/lang/model/util/Types.java
      @@ -133,6 +133,10 @@ public interface Types {
            * will appear last in the list. For an interface type with no direct
            * super-interfaces, a type mirror representing {@code java.lang.Object}
            * is returned.
      +     * The type {@code java.lang.Object} has no direct supertype
      +     * ({@jls 8.1.4}, {@jls 8.1.5}) so an empty list is returned for the direct
      +     * supertypes of a type mirror representing {@code
      +     * java.lang.Object}.
            *
            * @param t  the type being examined
            * @return the direct supertypes, or an empty list if none

      Attachments

        Issue Links

          Activity

            People

              darcy Joe Darcy
              prappo Pavel Rappo
              Jan Lahoda, Pavel Rappo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: