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

Quan Anh Mai qamai at openjdk.org
Tue Jan 17 09:03:19 UTC 2023


On Tue, 17 Jan 2023 08:30:58 GMT, Sergey Tsypanov <stsypanov at openjdk.org> wrote:

>>> > Do you see any concrete examples of classes in the JDK that could benefit from a "VarHandlization"?
>>> 
>>> `ImageOutputStreamImpl` and `ImageInputStreamImpl` in `javax.imageio.stream` have some very similar code that might benefit. Also `DataInputStream` and `DataOutpuStream`could possibly use `Bits` directly.
>> 
>> Thanks @j3graham
>
> @minborg I guess that the same can be done for `MethodHandles.readInt()`, `ByteBuffer.getInt()`, `AESCrypt.implEncryptBlock()`. Btw, I see that unlike original code `VarHandle.get()` returns Object, not primitive. Won't we have excessive allocation with this change?

@stsypanov `VarHandle.get()` is a polymorphic signature method, which means that a call `(int) INT.get(b, off)` will invoke a method with a signature of `int VarHandle::get(byte[], int)`

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

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


More information about the core-libs-dev mailing list