RFR: 8299576: Reimplement java.io.Bits using VarHandle access [v7]

Joe Darcy darcy at openjdk.org
Mon Jan 9 20:44:52 UTC 2023


On Mon, 9 Jan 2023 13:17:42 GMT, Raffaello Giulietti <rgiulietti at openjdk.org> wrote:

>> I see - thanks for the explanation - the problem is with `floatToIntBits` vs `floatToRawIntBits` in the "put" operation. The get operation is ok, but then having asymmetry where we use a float VH in one case (get) but not in the other (put) is not desirable.
>
> @mcimadamore According to the spec, `floatToRawIntBits` and `doubleToRawLongBits` ensure that the original input bits are all preserved, even for NaN values.
> On the other hand, the spec says that `intBitsToFloat` and `longBitsToDouble` only ensure a best effort in preserving the output bits of NaN values.
> So I think `VarHandle` `get` and `put` do their best to preserve the bits, but no more than the underlying platform can possibly offer.
> This behavior for floating-point values is not fully specified in `VarHandle`, so there's room for improvement in the doc.

At least for the purposes of this PR, I think leaving the calls to the bitwise conversion methods in place is fine.

-------------

PR: https://git.openjdk.org/jdk/pull/11840


More information about the core-libs-dev mailing list