What is the size of boolean read or written, to and from memory, by the methods in Unsafe like Unsafe.putBoolean, Unsafe.getBoolean, etc?
Asked
Active
Viewed 37 times
0
Suminda Sirinath S. Dharmasena
- 1,701
- 3
- 25
- 30
-
Many of the answers in the linked duplicate say it is undefined, but the above API though internal, would be using a specific size. The linked question and answers do not reliably answer that. – Suminda Sirinath S. Dharmasena Dec 14 '20 at 10:51
-
Yes. That is for boolean. But `sun.misc.Unsafe` will be using a specific size. OpenJDK, Azul Zing and OpenJ9 both use the same JCL and has Unsafe. The size used in `sun.misc.Unsafe` would be independent of size boolean in VMs users if they differ. If the size of boolean of `sun.misc.Unsafe` differ JCL will not work on VMs which one the OpenJDK JCL. I am not interested in the VMs size of `boolean` but what is used in `sun.misc.Unsafe` which I think should be defined and fixed. – Suminda Sirinath S. Dharmasena Dec 14 '20 at 11:03
-
`Unsafe` is mainly used for IO, Buffers, Protocols, etc. When writing a byte stream to IO one needs to know how many bits on is writing and in what order. This does not need to correspond with what in in memory through it can be the same. – Suminda Sirinath S. Dharmasena Dec 14 '20 at 11:11