-
Notifications
You must be signed in to change notification settings - Fork 6.2k
JDK-8310453: Update javadoc of java.lang.Object #14567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
|
|
@@ -67,7 +67,7 @@ public Object() {} | |
| public final native Class<?> getClass(); | ||
|
|
||
| /** | ||
| * Returns a hash code value for the object. This method is | ||
| * {@return a hash code value for this object} This method is | ||
| * supported for the benefit of hash tables such as those provided by | ||
| * {@link java.util.HashMap}. | ||
| * <p> | ||
|
|
@@ -95,7 +95,11 @@ public Object() {} | |
| * As far as is reasonably practical, the {@code hashCode} method defined | ||
| * by class {@code Object} returns distinct integers for distinct objects. | ||
| * | ||
| * @return a hash code value for this object. | ||
| * @apiNote | ||
| * The {@link java.util.Objects#hash(Object...) hash} and {@link | ||
| * java.util.Objects#hashCode(Object) hashCode} methods of {@link | ||
| * java.util.Objects} can be used to help construct simple hash codes. | ||
| * | ||
| * @see java.lang.Object#equals(java.lang.Object) | ||
| * @see java.lang.System#identityHashCode | ||
| */ | ||
|
|
@@ -153,6 +157,9 @@ public Object() {} | |
| * method whenever this method is overridden, so as to maintain the | ||
| * general contract for the {@code hashCode} method, which states | ||
| * that equal objects must have equal hash codes. | ||
| * <p>The two-argument {@link java.util.Objects#equals(Object, | ||
| * Object) Objects.equals} method implements an equivalence relation | ||
| * on two possibly-null object references. | ||
| * | ||
| * @param obj the reference object with which to compare. | ||
| * @return {@code true} if this object is the same as the obj | ||
|
|
@@ -229,7 +236,7 @@ public boolean equals(Object obj) { | |
| protected native Object clone() throws CloneNotSupportedException; | ||
|
|
||
| /** | ||
| * Returns a string representation of the object. | ||
| * {@return a string representation of the object} | ||
| * @apiNote | ||
| * In general, the | ||
| * {@code toString} method returns a string that | ||
|
|
@@ -246,12 +253,14 @@ public boolean equals(Object obj) { | |
| * 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> | ||
| * {@snippet lang=java : | ||
| * getClass().getName() + '@' + Integer.toHexString(hashCode()) | ||
| * </pre></blockquote> | ||
| * | ||
| * @return a string representation of the object. | ||
| * } | ||
| * The {@link java.util.Objects#toIdentityString(Object) | ||
| * Objects.toIdentityString} method returns the string for an | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That last sentence doesn't feel like it needs to be part of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is, a clear connection to what's being described by that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method has an existing apiNote and implSpec. I suspect Joe meant to add this sentence to the apiNote, not the implSpec.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did mean to add the cross-reference to Objects.toIdentityString to the implSpec section since earlier in the implSpec section the expression that is the basis for Objects.toIdentityString is listed.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Separately, is it just me or this sentence could be rephrased to not read like |
||
| * object equal to the string that would be returned if neither | ||
| * the {@code toString} nor {@code hashCode} methods were | ||
| * overridden by the object's class. | ||
| */ | ||
| public String toString() { | ||
| return getClass().getName() + "@" + Integer.toHexString(hashCode()); | ||
|
|
@@ -446,16 +455,16 @@ public final void wait(long timeoutMillis) throws InterruptedException { | |
| * below. Among other things, this approach avoids problems that can be caused | ||
| * by spurious wakeups. | ||
| * | ||
| * <pre>{@code | ||
| * {@snippet lang=java : | ||
| * synchronized (obj) { | ||
| * while (<condition does not hold> and <timeout not exceeded>) { | ||
| * while ( <condition does not hold and timeout not exceeded> ) { | ||
| * long timeoutMillis = ... ; // recompute timeout values | ||
| * int nanos = ... ; | ||
| * obj.wait(timeoutMillis, nanos); | ||
| * } | ||
| * ... // Perform action appropriate to condition or timeout | ||
| * } | ||
| * }</pre> | ||
| * } | ||
| * | ||
| * @param timeoutMillis the maximum time to wait, in milliseconds | ||
| * @param nanos additional time, in nanoseconds, in the range 0-999999 inclusive | ||
|
|
@@ -555,15 +564,16 @@ public final void wait(long timeoutMillis, int nanos) throws InterruptedExceptio | |
| * To guard against exceptions prematurely terminating the finalize chain, | ||
| * the subclass should use a {@code try-finally} block to ensure | ||
| * {@code super.finalize()} is always invoked. For example, | ||
| * <pre>{@code @Override | ||
| * {@snippet lang="java": | ||
| * @Override | ||
| * protected void finalize() throws Throwable { | ||
| * try { | ||
| * ... // cleanup subclass state | ||
| * } finally { | ||
| * super.finalize(); | ||
| * } | ||
| * } | ||
| * }</pre> | ||
| * } | ||
| * | ||
| * @deprecated Finalization is deprecated and subject to removal in a future | ||
| * release. The use of finalization can lead to problems with security, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend a blank line before to make the paragraph break more obvious.