You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Fabian Mastenbroek (Jira)" <ji...@apache.org> on 2022/10/11 13:06:00 UTC
[jira] [Commented] (ARROW-16449) [Java] java.lang.reflect.InaccessibleObjectException on Java 18
[ https://issues.apache.org/jira/browse/ARROW-16449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17615771#comment-17615771 ]
Fabian Mastenbroek commented on ARROW-16449:
--------------------------------------------
Hi,
I stumbled upon this issue today and ideally I would like to avoid having to open `java.base` to unnamed modules. I took a look at the source code of [MemoryUtil|https://github.com/apache/arrow/blob/master/java/memory/memory-core/src/main/java/org/apache/arrow/memory/util/MemoryUtil.java] today and it seems there might be workaround for this issue.
The [reflective call|https://github.com/apache/arrow/blob/3d7f2f22a0fc441a41b8fa971e11c0f4290ebb24/java/memory/memory-core/src/main/java/org/apache/arrow/memory/util/MemoryUtil.java#L84] that is currently causing the failure is not necessary. Applying [this patch|https://github.com/fabianishere/arrow/commit/7386cdbb9e67b91c763aad647bc0b407c8b5e9e7] to the Arrow tree seems to resolve this issue for me. However, without the suggested _add-opens_ parameter, any call to _MemoryUtil.directBuffer_ will now fail during runtime.
[This patch|https://github.com/fabianishere/arrow/commit/5a32dcaa7d4732742d65b69a149f560e61aa36c7] resolves that issue for me. However, this is a rather hairy solution, since it overwrites fields of _DirectByteBuffer_ using _Unsafe_ to construct a buffer for an arbitrary memory address.
> [Java] java.lang.reflect.InaccessibleObjectException on Java 18
> ---------------------------------------------------------------
>
> Key: ARROW-16449
> URL: https://issues.apache.org/jira/browse/ARROW-16449
> Project: Apache Arrow
> Issue Type: Bug
> Components: Java
> Affects Versions: 6.0.0
> Reporter: Daniel Glöckner
> Priority: Major
>
> Getting the following stack trace when running on Java 18.
> {{BaseAllocator}} throws this when it calls the {{DefaultAllocationManagerFactory}}.
> {code}
> private ArrowBuf createEmpty() {
> return this.allocationManagerFactory.empty();
> }
> {code}
> {code:java}
> Caused by: java.lang.RuntimeException: Failed to initialize MemoryUtil.
> at org.apache.arrow.memory.util.MemoryUtil.<clinit>(MemoryUtil.java:136)
> ... 20 more
> Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field long java.nio.Buffer.address accessible: module java.base does not \"opens java.nio\" to unnamed module @3453e479
> at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
> at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
> at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
> at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
> at org.apache.arrow.memory.util.MemoryUtil.<clinit>(MemoryUtil.java:84)
> ... 20 more
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)