JDK-8331108 : Unused Math.abs call in java.lang.FdLibm.Expm1#compute
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 23
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-04-25
  • Updated: 2024-10-26
  • Resolved: 2024-04-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 23
23 b21Fixed
Related Reports
Relates :  
Description
IntelliJ IDEA highlights that initial assignment of 'y' is unnecessary.

y = Math.abs(x);

https://github.com/openjdk/jdk/blob/c9f8d0eff706d9ac59179afbb821367da09c9aae/src/java.base/share/classes/java/lang/FdLibm.java#L3008

After removing assignment code is still compiles. So it seems unnecessary.
Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/18963 Date: 2024-04-25 21:32:03 +0000
26-10-2024

Changeset: 4e5c25ee Author: Joe Darcy <darcy@openjdk.org> Date: 2024-04-28 22:55:44 +0000 URL: https://git.openjdk.org/jdk/commit/4e5c25ee43d4ec31ed5160fd93a2fd15e35182f8
28-04-2024

The idiom return huge*huge; // overflow is used by C FDLIBM to raise the IEEE 754 overflow sticky flag. The sticky flags are common on processors implementing the IEEE 754 standard, but out outside of the computation model of the JVM. Without checking, some other instances of this idiom have been replaced in the port of FDLIBM to Java.
25-04-2024

Also noticed confusing code to get Infinity. https://github.com/openjdk/jdk/blob/c9f8d0eff706d9ac59179afbb821367da09c9aae/src/java.base/share/classes/java/lang/FdLibm.java#L3022 return huge*huge; // overflow Can it be replaced with plain return INFINITY; ?
25-04-2024