Skip to content

Commit

Permalink
8336036: Synthetic documentation for a record's equals is incorrect f…
Browse files Browse the repository at this point in the history
…or floating-point types

Reviewed-by: prappo
Backport-of: b3ef2a6
  • Loading branch information
liach committed Jul 14, 2024
1 parent 0a9e3bf commit d1373a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,12 @@ doclet.record_equals_doc.fullbody.head=\
doclet.record_equals_doc.fullbody.tail.both=\
Reference components are compared with \
{@link java.util.Objects#equals(Object,Object) Objects::equals(Object,Object)}; \
primitive components are compared with '=='.
primitive components are compared with the <code>compare</code> method from \
their corresponding wrapper classes.

doclet.record_equals_doc.fullbody.tail.primitive=\
All components in this record class are compared with '=='.
All components in this record class are compared with the <code>compare</code> \
method from their corresponding wrapper classes.

doclet.record_equals_doc.fullbody.tail.reference=\
All components in this record class are compared with \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, 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
Expand Down Expand Up @@ -237,7 +237,8 @@ public record R(int r1) { }""");
"""
Indicates whether some other object is "equal to" this one. The objects are equa\
l 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 '=='.""",
equal. All components in this record class are compared with the <code>compare</\
code> method from their corresponding wrapper classes.""",
"""
<span class="element-name">r1</span>""",
"""
Expand Down Expand Up @@ -300,7 +301,8 @@ public record R(int r1) { }""");
"""
Indicates whether some other object is "equal to" this one. The objects are equa\
l 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 '=='.""",
equal. All components in this record class are compared with the <code>compare</\
code> method from their corresponding wrapper classes.""",
"""
<span class="element-name">r1</span>""",
"""
Expand All @@ -311,7 +313,8 @@ l if the other object is of the same class and if all the record components are
@Test
public void testGeneratedEqualsPrimitive(Path base) throws IOException {
testGeneratedEquals(base, "int a, int b",
"All components in this record class are compared with '=='.");
"All components in this record class are compared with the <code>compare</code> method " +
"from their corresponding wrapper classes.");
}

@Test
Expand All @@ -324,7 +327,8 @@ public void testGeneratedEqualsReference(Path base) throws IOException {
public void testGeneratedEqualsMixed(Path base) throws IOException {
testGeneratedEquals(base, "int a, Object b",
"Reference components are compared with <code>Objects::equals(Object,Object)</code>; "
+ "primitive components are compared with '=='.");
+ "primitive components are compared with the <code>compare</code> method from their "
+ "corresponding wrapper classes.");
}

private void testGeneratedEquals(Path base, String comps, String expect) throws IOException {
Expand Down

1 comment on commit d1373a2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.