diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b1e796a0..167c8f6a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,21 +69,15 @@ jobs: strategy: matrix: os: [ ubuntu-latest, windows-latest, macos-latest ] - java: [ 11, 17 ] + java: [ '17', '20' ] profiles: ['native', 'native,native-exported'] - exclude: # Exclusions can be removed from GraalVM 23.0: https://github.com/oracle/graal/pull/5932 - - os: ubuntu-latest - profiles: 'native,native-exported' - - os: macos-latest - profiles: 'native,native-exported' runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - uses: graalvm/setup-graalvm@v1 with: - version: '22.3.0' java-version: ${{ matrix.java }} - components: 'native-image' + distribution: 'graalvm-community' github-token: ${{ secrets.GITHUB_TOKEN }} - name: Test run: mvn --batch-mode --no-transfer-progress -P ${{ matrix.profiles }} integration-test diff --git a/src/main/java/org/sqlite/SQLiteJDBCLoader.java b/src/main/java/org/sqlite/SQLiteJDBCLoader.java index 9f64d6f64..2ecb927f6 100644 --- a/src/main/java/org/sqlite/SQLiteJDBCLoader.java +++ b/src/main/java/org/sqlite/SQLiteJDBCLoader.java @@ -298,6 +298,17 @@ private static boolean loadNativeLibrary(String path, String name) { } } + private static boolean loadNativeLibraryJdk() { + try { + System.loadLibrary(LibraryLoaderUtil.NATIVE_LIB_BASE_NAME); + return true; + } catch (UnsatisfiedLinkError e) { + System.err.println("Failed to load native library through System.loadLibrary"); + e.printStackTrace(); + return false; + } + } + /** * Loads SQLite native library using given path and name of the library. * @@ -358,6 +369,12 @@ private static void loadSQLiteNativeLibrary() throws Exception { } } + // As an ultimate last resort, try loading through System.loadLibrary + if (loadNativeLibraryJdk()) { + extracted = true; + return; + } + extracted = false; throw new Exception( String.format( diff --git a/src/main/java/org/sqlite/util/LibraryLoaderUtil.java b/src/main/java/org/sqlite/util/LibraryLoaderUtil.java index 3eb27325b..98e62e2b6 100644 --- a/src/main/java/org/sqlite/util/LibraryLoaderUtil.java +++ b/src/main/java/org/sqlite/util/LibraryLoaderUtil.java @@ -3,6 +3,9 @@ import org.sqlite.SQLiteJDBCLoader; public class LibraryLoaderUtil { + + public static final String NATIVE_LIB_BASE_NAME = "sqlitejdbc"; + /** * Get the OS-specific resource directory within the jar, where the relevant sqlitejdbc native * library is located. @@ -15,7 +18,7 @@ public static String getNativeLibResourcePath() { /** Get the OS-specific name of the sqlitejdbc native library. */ public static String getNativeLibName() { - return System.mapLibraryName("sqlitejdbc"); + return System.mapLibraryName(NATIVE_LIB_BASE_NAME); } public static boolean hasNativeLib(String path, String libraryName) {