jbonofre commented on code in PR #1008:
URL: https://github.com/apache/arrow-java/pull/1008#discussion_r2821939144
##########
memory/memory-core/src/main/java/org/apache/arrow/memory/util/MemoryUtil.java:
##########
@@ -81,9 +82,18 @@ public Object run() {
BYTE_ARRAY_BASE_OFFSET = UNSAFE.arrayBaseOffset(byte[].class);
// get the offset of the address field in a java.nio.Buffer object
+ long maybeOffset;
Field addressField = java.nio.Buffer.class.getDeclaredField("address");
- addressField.setAccessible(true);
- BYTE_BUFFER_ADDRESS_OFFSET = UNSAFE.objectFieldOffset(addressField);
+ try {
+ addressField.setAccessible(true);
+ maybeOffset = UNSAFE.objectFieldOffset(addressField);
+ } catch (InaccessibleObjectException e) {
+ maybeOffset = -1;
Review Comment:
I understand the rationale here: we try first with the address field offset,
and if it fails (`InaccessibleObjectException`) we fallback to offset -1 and
try again. It can fail again (`InaccessibleObjectException`), and then we throw
the exception.
I don't see any side effect, but it's potential a kind of breaking change on
the allocation.
It looks good to me, but I would love to have four eyes validation by
@lidavidm
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]