Skip to content

Commit

Permalink
8282665: [REDO] ByteBufferTest.java: replace endless recursion with R…
Browse files Browse the repository at this point in the history
…untimeException in void ck(double x, double y)

Backport-of: d07f7c76c5df1473bffa41f10a89ca1e21e001ef
  • Loading branch information
Amos Shi authored and GoeLin committed Dec 4, 2023
1 parent 4245e3c commit d4fcded
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/hotspot/jtreg/compiler/intrinsics/unsafe/ByteBufferTest.java
Expand Up @@ -211,13 +211,22 @@ short getShortX(long a) {

void ck(long x, long y) {
if (x != y) {
throw new RuntimeException(" x = " + Long.toHexString(x) + ", y = " + Long.toHexString(y));
throw new RuntimeException("expect x == y: x = " + Long.toHexString(x) + ", y = " + Long.toHexString(y));
}
}

void ck(double x, double y) {
if (x == x && y == y && x != y) {
ck(x, y);
// Check if x and y have identical values.
// Remember: NaN == x is false for ANY x, including if x is NaN (IEEE standard).
// Therefore, if x and y are NaN, x != y would return true, which is not what we want.
// We do not want an Exception if both are NaN.
// Double.compare takes care of these special cases
// including NaNs, and comparing -0.0 to 0.0
if (Double.compare(x,y) != 0) {
throw new RuntimeException("expect x == y:"
+ " x = " + Double.toString(x) + ", y = " + Double.toString(y)
+ " (x = " + Long.toHexString(Double.doubleToRawLongBits(x))
+ ", y = " + Long.toHexString(Double.doubleToRawLongBits(y)) + ")");
}
}

Expand Down

1 comment on commit d4fcded

@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.