Skip to content

borkdude/sqlite4j-clojure-native-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sqlite4j-demo

A demo of sqlite4j — SQLite compiled to pure JVM bytecode via Chicory (no JNI) — used from Clojure with next.jdbc, including GraalVM native-image compilation.

Prerequisites

Run on JVM

clojure -M -m sqlite4j-demo.main

Build native image

Build the uberjar:

clojure -T:build uber

Compile to native:

native-image -jar target/sqlite4j-demo.jar \
  -o sqlite4j-demo \
  -H:ReflectionConfigurationFiles=reflect-config.json \
  -H:+ReportExceptionStackTraces \
  --features=clj_easy.graal_build_time.InitClojureClasses \
  --initialize-at-build-time=io.roastedroot.zerofs \
  --initialize-at-build-time=io.roastedroot.sqlite4j \
  --initialize-at-build-time=com.dylibso.chicory \
  --initialize-at-run-time=io.roastedroot.sqlite4j.JDBC \
  --no-fallback

Run the binary:

./sqlite4j-demo

Native-image notes

The key insight for native-image is the initialization timing:

  • io.roastedroot.sqlite4j, io.roastedroot.zerofs, and com.dylibso.chicory are initialized at build time
  • io.roastedroot.sqlite4j.JDBC must be initialized at run time so it registers with java.sql.DriverManager when the binary starts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors