Skip to content

Fix CLI Snowflake JDBC driver error by adding JVM module access#92

Merged
codedmart merged 1 commit intomainfrom
codedmart/cli-snowflake-fix
Oct 22, 2025
Merged

Fix CLI Snowflake JDBC driver error by adding JVM module access#92
codedmart merged 1 commit intomainfrom
codedmart/cli-snowflake-fix

Conversation

@codedmart
Copy link
Copy Markdown
Contributor

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.

… module access

## 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.
@codedmart codedmart merged commit 4a3e863 into main Oct 22, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant