JDK-8080449 : doc for Object.toString should use @implSpec
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2015-05-14
  • Updated: 2024-12-17
  • Resolved: 2024-12-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
The doc comment for Object.toString is as follows:

    /**
     * Returns a string representation of the object. In general, the
     * {@code 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.
     * <p>
     * The {@code toString} method for class {@code Object}
     * returns a string consisting of the name of the class of which the
     * object is an instance, the at-sign character `{@code @}', 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:
     * <blockquote>
     * <pre>
     * getClass().getName() + '@' + Integer.toHexString(hashCode())
     * </pre></blockquote>
     *
     * @return  a string representation of the object.
     */

There are really two parts here: API specification and implementation specification. The latter should be demarcated using the @implSpec tag. See JDK-8068562.

This is a general issue; I'm sure there are many other cases that apply elsewhere along with the specific instance of Object.toString.

Seen on StackOverflow: http://stackoverflow.com/q/30244464/1441122
Comments
The use of implSpec as suggested was done as part of JDK-8261123; closed this bug as a duplicate.
17-12-2024