A DESCRIPTION OF THE PROBLEM :
The documentation for the method `allocateMemory` of the classes `sun.misc.Unsafe` and `jdk.internal.misc.Unsafe` says:
> The resulting native pointer will never be zero
However, this seems to be incorrect. Calling the method with 0 as argument returns 0 as result:
```
unsafe.allocateMemory(0)
```
Maybe this is just a documentation error? The implementation has a special check for `bytes == 0` in which case it returns 0.
Note that `reallocateMemory` behaves the same way, but there it is properly documented.
The documentation for the method `allocateMemory` of the classes `sun.misc.Unsafe` and `jdk.internal.misc.Unsafe` says:
> The resulting native pointer will never be zero
However, this seems to be incorrect. Calling the method with 0 as argument returns 0 as result:
```
unsafe.allocateMemory(0)
```
Maybe this is just a documentation error? The implementation has a special check for `bytes == 0` in which case it returns 0.
Note that `reallocateMemory` behaves the same way, but there it is properly documented.
- csr for
-
JDK-8325149 Unsafe.allocateMemory documentation incorrect regarding zero return value
- Closed