Commit 4a3e863
authored
Fix Snowflake JDBC driver initialization error by adding required JVM module access (#92)
## Problem
The Snowflake JDBC driver was failing to initialize when used in the CLI
tool with the following error:
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
This occurred because the Snowflake JDBC driver uses Apache Arrow for
high-performance memory management, which requires reflective access
to internal `java.nio.Buffer` classes. Java's module system (introduced
in Java 9+) blocks this access by default for security reasons.
## Solution
Added `--add-opens=java.base/java.nio=ALL-UNNAMED` to the
`applicationDefaultJvmArgs` in `ndc-cli/build.gradle.kts`. This JVM
argument
opens the `java.nio` package from the `java.base` module to unnamed
modules, allowing the Snowflake driver's Arrow library to access the
necessary internal classes.
## Impact
- Fixes native query creation and other CLI operations that use the
Snowflake JDBC driver
- Safe for all database connectors (Oracle, MySQL, Trino) - this flag
only affects libraries that actually need the access
- Standard practice for JDBC applications with modern drivers that use
direct memory access
## Testing
Verified that the CLI can now successfully connect to Snowflake and
create native queries without the `InaccessibleObjectException`.
This gives a clear explanation of the problem, the technical reason
behind it, and why the solution is appropriate and safe.1 parent b3fa9f4 commit 4a3e863
1 file changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
0 commit comments