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

doc for Double/Int/LongSummaryStatistics.toString has errors

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • None
    • core-libs

        The specification for IntSummaryStatistics.toString is entirely copied from Object.toString:

        ==========
        Description copied from class: Object
        Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

        The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

             getClass().getName() + '@' + Integer.toHexString(hashCode())
        ==========

        This copies the contract portion of Object.toString's spec, but it shouldn't copy the implementation portion of the specification. Thus, use of @implSpec combined with {@inheritDoc} is called for here. (See JDK-8080449 regarding Object.toString and JDK-8068562 regarding the @implSpec tag.)

        In addition, the source code for IntSummaryStatistics.toString has this as its doc comment:

            /**
             * {@inheritDoc}
             *
             * Returns a non-empty string representation of this object suitable for
             * debugging. The exact presentation format is unspecified and may vary
             * between implementations and versions.
             */

        For some reason the text "Returns a non-empty string representation..." doesn't appear in the javadoc output. This may be a javadoc bug.

        This is probably just one instance of a general problem where overriding methods' specifications should be cleaned up to inherit selectively from their superclass.

        Seen on StackOverflow: http://stackoverflow.com/q/30244464/1441122

              smarks Stuart Marks
              smarks Stuart Marks
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: