Closed curioustorvald closed 4 years ago
To retrieve correct data from an array using Unsafe, you need to add the array base offset to the objects' own offset, producing code similar to this:
protected int getInt(byte[] array, int offset) { return UnsafeWrapper.getInt(array, offset + UNSAFE.arrayBaseOffset(array)); // notice the additional 'UNSAFE.arrayBaseOffset' }
I'm leaving an issue here rather than a pull request as I'm not in a situation to run a test, thanks.
The usage is correct. The array base offset is added in UnsafeWrapper (here).
UnsafeWrapper
To retrieve correct data from an array using Unsafe, you need to add the array base offset to the objects' own offset, producing code similar to this:
I'm leaving an issue here rather than a pull request as I'm not in a situation to run a test, thanks.