mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-15 21:05:11 +00:00
8029551: Add value-type notice to java.time classes
Add warning about identity of value types and reference to ValueBased.html Reviewed-by: briangoetz, smarks, scolebourne
This commit is contained in:
parent
d8cb69a469
commit
2b6adb0b44
@ -118,6 +118,13 @@ import java.util.regex.Pattern;
|
||||
* most applications.
|
||||
* See {@link Instant} for a discussion as to the meaning of the second and time-scales.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code Duration} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -197,6 +197,13 @@ import java.util.Objects;
|
||||
* This includes {@code Instant}, {@code LocalDate}, {@code LocalTime}, {@code OffsetDateTime},
|
||||
* {@code ZonedDateTime} and {@code Duration}.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code Instant} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -122,6 +122,13 @@ import java.util.Objects;
|
||||
* However, any application that makes use of historical dates, and requires them
|
||||
* to be accurate will find the ISO-8601 approach unsuitable.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code LocalDate} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -120,6 +120,13 @@ import java.util.Objects;
|
||||
* However, any application that makes use of historical dates, and requires them
|
||||
* to be accurate will find the ISO-8601 approach unsuitable.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code LocalDateTime} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -110,6 +110,13 @@ import java.util.Objects;
|
||||
* in most of the world. This API assumes that all calendar systems use the same
|
||||
* representation, this class, for time-of-day.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code LocalTime} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -112,6 +112,13 @@ import java.util.Objects;
|
||||
* However, any application that makes use of historical dates, and requires them
|
||||
* to be accurate will find the ISO-8601 approach unsuitable.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code MonthDay} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -113,6 +113,13 @@ import java.util.Objects;
|
||||
* in simpler applications. This class may be used when modeling date-time concepts in
|
||||
* more detail, or when communicating to a database or in a network protocol.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code OffsetDateTime} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -103,6 +103,13 @@ import java.util.Objects;
|
||||
* For example, the value "13:45.30.123456789+02:00" can be stored
|
||||
* in an {@code OffsetTime}.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code OffsetTime} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -120,6 +120,13 @@ import java.util.regex.Pattern;
|
||||
* The period is modeled as a directed amount of time, meaning that individual parts of the
|
||||
* period may be negative.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code Period} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -120,6 +120,13 @@ import java.util.Objects;
|
||||
* However, any application that makes use of historical dates, and requires them
|
||||
* to be accurate will find the ISO-8601 approach unsuitable.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code Year} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -116,6 +116,13 @@ import java.util.Objects;
|
||||
* However, any application that makes use of historical dates, and requires them
|
||||
* to be accurate will find the ISO-8601 approach unsuitable.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code YearMonth} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -160,6 +160,13 @@ import java.util.TimeZone;
|
||||
* This approach is designed to allow a {@link ZonedDateTime} to be loaded and
|
||||
* queried, but not modified, on a Java Runtime with incomplete time-zone information.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code ZoneId} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This abstract class has two implementations, both of which are immutable and thread-safe.
|
||||
* One implementation models region-based IDs, the other is {@code ZoneOffset} modelling
|
||||
|
||||
@ -115,6 +115,13 @@ import java.util.concurrent.ConcurrentMap;
|
||||
* Implementations may choose to cache certain common offsets, however
|
||||
* applications must not rely on such caching.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code ZoneOffset} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -142,6 +142,13 @@ import java.util.Objects;
|
||||
* a vital, but secondary, piece of information, used to ensure that the class
|
||||
* represents an instant, especially during a daylight savings overlap.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code ZonedDateTime} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* A {@code ZonedDateTime} holds state equivalent to three separate objects,
|
||||
* a {@code LocalDateTime}, a {@code ZoneId} and the resolved {@code ZoneOffset}.
|
||||
|
||||
@ -103,6 +103,14 @@ import java.time.temporal.ValueRange;
|
||||
* to create new HijrahDate instances.
|
||||
* Alternatively, the {@link #withVariant} method can be used to convert
|
||||
* to a new HijrahChronology.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code HijrahDate} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -111,6 +111,13 @@ import sun.util.calendar.LocalGregorianCalendar;
|
||||
* Calling {@code japaneseDate.get(ERA)} will return 2, corresponding to
|
||||
* {@code JapaneseChronology.ERA_HEISEI}.<br>
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code JapaneseDate} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -91,6 +91,13 @@ import java.util.Objects;
|
||||
* This calendar system is primarily used in the Republic of China, often known as Taiwan.
|
||||
* Dates are aligned such that {@code 0001-01-01 (Minguo)} is {@code 1912-01-01 (ISO)}.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code MinguoDate} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -91,6 +91,13 @@ import java.util.Objects;
|
||||
* This calendar system is primarily used in Thailand.
|
||||
* Dates are aligned such that {@code 2484-01-01 (Buddhist)} is {@code 1941-01-01 (ISO)}.
|
||||
*
|
||||
* <p>
|
||||
* This is a <a href="{@docRoot}/java/lang/doc-files/ValueBased.html">value-based</a>
|
||||
* class; use of identity-sensitive operations (including reference equality
|
||||
* ({@code ==}), identity hash code, or synchronization) on instances of
|
||||
* {@code ThaiBuddhistDate} may have unpredictable results and should be avoided.
|
||||
* The {@code equals} method should be used for comparisons.
|
||||
*
|
||||
* @implSpec
|
||||
* This class is immutable and thread-safe.
|
||||
*
|
||||
|
||||
@ -1847,7 +1847,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest {
|
||||
LocalDateTime dt = base.plusMinutes(i);
|
||||
t = t.plusMinutes(1);
|
||||
|
||||
if (t == LocalTime.MIDNIGHT) {
|
||||
if (t.equals(LocalTime.MIDNIGHT)) {
|
||||
d = d.plusDays(1);
|
||||
}
|
||||
|
||||
@ -2539,7 +2539,7 @@ public class TCKLocalDateTime extends AbstractDateTimeTest {
|
||||
LocalDateTime dt = base.minusMinutes(i);
|
||||
t = t.plusMinutes(1);
|
||||
|
||||
if (t == LocalTime.MIDNIGHT) {
|
||||
if (t.equals(LocalTime.MIDNIGHT)) {
|
||||
d = d.plusDays(1);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user