GitHub user torito created a discussion: Using arrow without open module in JPMS

In the [installation doc](https://arrow.apache.org/java/main/install.html) it 
is stated we should include some `--add-opens` to the JVM, however, in my 
scenario, is impossible to add those flags as I cannot control how the JVM is 
launched.

Currently, my application dont even start, because the MemoryUtil class is not 
loaded because an [Exception in the static 
scope](https://github.com/apache/arrow-java/blob/ce1f3d75b25038af068b62cb9ebd35817b7a04a3/memory/memory-core/src/main/java/org/apache/arrow/memory/util/MemoryUtil.java#L141).

If instead of throwing an exception in the case the `--add-opens` is not set, 
we catch it as the other exceptions, we'll be able to load the class, and use 
arrow in our system 

```java
final Object maybeDirectBufferConstructor =
            AccessController.doPrivileged(
                new PrivilegedAction<Object>() {
                  @Override
                  public Object run() {
                    try {
                      final Constructor<?> constructor =
                          (majorVersion >= 21)
                              ? 
direct.getClass().getDeclaredConstructor(long.class, long.class)
                              : 
direct.getClass().getDeclaredConstructor(long.class, int.class);
                      constructor.setAccessible(true);
                      logger.debug("Constructor for direct buffer found and 
made accessible");
                      return constructor;
                    } catch (NoSuchMethodException e) {
                      logger.debug("Cannot get constructor for direct buffer 
allocation", e);
                      return e;
                    } catch (SecurityException e) {
                      logger.debug("Cannot get constructor for direct buffer 
allocation", e);
                      return e;
                   } catch (InaccessibleObjectException e) { // <-- new added 
exception case 
                      logger.debug("Cannot get constructor for direct buffer 
allocation", e);
                      return e;
                    }
                  }
                });

```   

Currently, I'm forced to fork arrow because of this limitation. The proposed 
change is something acceptable ? I can propose a PR for it, but I dont know the 
full implications in all Arrow, but in my scenario is enough to use it for my 
purpose, and I would like to continue to use it without maintaining a fork.

Thanks

GitHub link: https://github.com/apache/arrow-java/discussions/1003

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to