Files
asmhatreandClaude Sonnet 5.5 ecceaa8b32 Add jextract module: SQLite bindings generated with jextract, FFM arenas, C strings, out-parameters, errors, upcalls, and a JMH comparison with JNI
jextract-25 early-access build (25-jextract+2-4) on JDK 25.0.5+8 against SQLite 3.45.1: 25 functions and 13 constants
generated into 4 committed files (the whole header would be 83 files), a small Db wrapper, the four arena kinds
used wrongly on purpose, ADDRESS vs C_POINTER zero-length vs unbounded segments and the SIGSEGV from getString
on a NULL pointer, sqlite3_open out-parameter, return codes to exceptions, a sqlite3_exec upcall and the VM exit
when it throws, the JDK 25 native-access warning and --illegal-native-access=deny, library loading failures,
and a JMH benchmark of FFM vs hand-written JNI vs plain Java (indicative only: shared 2-CPU machine).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b6Kg9RWSTJzyz6KP9X
2026-10-30 16:36:09 +00:00

23 lines
926 B
Java

package bench;
/** The JNI twin of the jextract bindings: the same SQLite calls, through a hand-written C shim (jni/sqlite_jni.c). */
public final class SqliteJni {
static {
System.loadLibrary("sqlitejni"); // libsqlitejni.so, found through -Djava.library.path
}
private SqliteJni() {}
public static native int versionNumber();
public static native int strlike(String glob, String text);
public static native long open(String path);
public static native int exec(long db, String sql);
public static native long prepare(long db, String sql);
public static native int bindInt(long stmt, int index, int value);
public static native int bindText(long stmt, int index, String value);
public static native int step(long stmt);
public static native int reset(long stmt);
public static native int finalizeStmt(long stmt);
public static native int close(long db);
}