Skip to content

Commit

Permalink
ci: update to GraalVM 23
Browse files Browse the repository at this point in the history
  • Loading branch information
kkriske authored Jul 26, 2023
1 parent 78defd0 commit 840ce0e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/org/sqlite/SQLiteJDBCLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/sqlite/util/LibraryLoaderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down

0 comments on commit 840ce0e

Please sign in to comment.