Skip to content

Commit 4a3e863

Browse files
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

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ndc-cli/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,7 @@ java {
4242

4343
application {
4444
mainClass = "io.hasura.cli.CLI"
45+
applicationDefaultJvmArgs = listOf(
46+
"--add-opens=java.base/java.nio=ALL-UNNAMED"
47+
)
4548
}

0 commit comments

Comments
 (0)