From b796a972dc372d65f2e3fb734c06c34487c1fc94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=84=A0=EC=9A=B0?= Date: Fri, 10 Jan 2025 19:50:50 +0900 Subject: [PATCH] Fix LimboDB.load to be static method --- .../github/tursodatabase/core/LimboDB.java | 26 +++++++++---------- .../tursodatabase/core/LimboDBTest.java | 6 ++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bindings/java/src/main/java/org/github/tursodatabase/core/LimboDB.java b/bindings/java/src/main/java/org/github/tursodatabase/core/LimboDB.java index f3001aead..accbad76b 100644 --- a/bindings/java/src/main/java/org/github/tursodatabase/core/LimboDB.java +++ b/bindings/java/src/main/java/org/github/tursodatabase/core/LimboDB.java @@ -30,6 +30,19 @@ public final class LimboDB extends AbstractDB { } } + /** + * Loads the SQLite interface backend. + */ + public static void load() { + if (isLoaded) return; + + try { + System.loadLibrary("_limbo_java"); + } finally { + isLoaded = true; + } + } + /** * @param url e.g. "jdbc:sqlite:fileName * @param fileName e.g. path to file @@ -43,19 +56,6 @@ public final class LimboDB extends AbstractDB { super(url, fileName); } - /** - * Loads the SQLite interface backend. - */ - public void load() { - if (isLoaded) return; - - try { - System.loadLibrary("_limbo_java"); - } finally { - isLoaded = true; - } - } - // WRAPPER FUNCTIONS //////////////////////////////////////////// // TODO: add support for JNI diff --git a/bindings/java/src/test/java/org/github/tursodatabase/core/LimboDBTest.java b/bindings/java/src/test/java/org/github/tursodatabase/core/LimboDBTest.java index feeeff060..66e842ea4 100644 --- a/bindings/java/src/test/java/org/github/tursodatabase/core/LimboDBTest.java +++ b/bindings/java/src/test/java/org/github/tursodatabase/core/LimboDBTest.java @@ -15,16 +15,16 @@ public class LimboDBTest { @Test void db_should_open_normally() throws Exception { String dbPath = TestUtils.createTempFile(); + LimboDB.load(); LimboDB db = LimboDB.create("jdbc:sqlite" + dbPath, dbPath); - db.load(); db.open(0); } @Test void should_throw_exception_when_opened_twice() throws Exception { String dbPath = TestUtils.createTempFile(); + LimboDB.load(); LimboDB db = LimboDB.create("jdbc:sqlite:" + dbPath, dbPath); - db.load(); db.open(0); assertThatThrownBy(() -> db.open(0)).isInstanceOf(SQLException.class); @@ -33,8 +33,8 @@ public class LimboDBTest { @Test void throwJavaException_should_throw_appropriate_java_exception() throws Exception { String dbPath = TestUtils.createTempFile(); + LimboDB.load(); LimboDB db = LimboDB.create("jdbc:sqlite:" + dbPath, dbPath); - db.load(); final int limboExceptionCode = LimboErrorCode.ETC.code; try {