-
Bug
-
Resolution: Fixed
-
P3
-
23, 24
-
b07
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8337363 | 23.0.2 | Chen Liang | P3 | Resolved | Fixed | b01 |
JDK-8337910 | 23.0.1 | Chen Liang | P3 | Resolved | Fixed | b06 |
JDK-8336350 | 23 | Chen Liang | P3 | Resolved | Fixed | b32 |
(As discovered by my colleague Chris Povirk)
In the following example, a record with double components implements equals() using Double.compare, as required by JLS 8.10.3.
However the javadoc for equals for a record incorrectly states that
> All components in this record class are compared with '=='.
The javadoc should be updated to reflect the specified behaviour for double and float record components.
```
public record RecordDoubleComponent(double x) {
public static void main(String[] args) {
double a = 0.0;
double b = -0.0;
System.out.println(a == b);
System.out.println(new RecordDoubleComponent(a).equals(new RecordDoubleComponent(b)));
}
}
```
$ java -fullversion
openjdk full version "24-ea+5-515"
$ java RecordDoubleComponent.java
true
false
$ javadoc RecordDoubleComponent.java
$ grep 'All comp' RecordDoubleComponent.html
<div class="block">Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.</div>
In the following example, a record with double components implements equals() using Double.compare, as required by JLS 8.10.3.
However the javadoc for equals for a record incorrectly states that
> All components in this record class are compared with '=='.
The javadoc should be updated to reflect the specified behaviour for double and float record components.
```
public record RecordDoubleComponent(double x) {
public static void main(String[] args) {
double a = 0.0;
double b = -0.0;
System.out.println(a == b);
System.out.println(new RecordDoubleComponent(a).equals(new RecordDoubleComponent(b)));
}
}
```
$ java -fullversion
openjdk full version "24-ea+5-515"
$ java RecordDoubleComponent.java
true
false
$ javadoc RecordDoubleComponent.java
$ grep 'All comp' RecordDoubleComponent.html
<div class="block">Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.</div>
- backported by
-
JDK-8336350 Synthetic documentation for a record's equals is incorrect for floating-point types
-
- Resolved
-
-
JDK-8337363 Synthetic documentation for a record's equals is incorrect for floating-point types
-
- Resolved
-
-
JDK-8337910 Synthetic documentation for a record's equals is incorrect for floating-point types
-
- Resolved
-
- links to
-
Commit(jdk23) openjdk/jdk/d1373a2f
-
Commit(master) openjdk/jdk/b3ef2a60
-
Review(jdk23) openjdk/jdk/20147
-
Review(master) openjdk/jdk/20129
(2 links to)