Skip to content

Commit

Permalink
Merge pull request #75 from bgilbert/four
Browse files Browse the repository at this point in the history
Require OpenSlide ≥ 4.0.0
  • Loading branch information
bgilbert authored Apr 13, 2024
2 parents ec7a0b9 + 6715a88 commit 138ba9a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 38 deletions.
4 changes: 0 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@
.gitattributes export-ignore
.gitignore export-ignore
/.github export-ignore

# Fixtures are currently only used by GitHub Actions. Omit from release
# tarballs.
/fixtures export-ignore
8 changes: 4 additions & 4 deletions .github/workflows/java.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ jobs:
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install libopenslide0
sudo add-apt-repository "ppa:openslide/openslide"
sudo apt-get install libopenslide1
- name: Install dependencies (macOS)
if: matrix.os == 'macos-14'
run: |
Expand Down Expand Up @@ -65,9 +66,8 @@ jobs:
run: mvn -Dmaven.compiler.failOnWarning=true
- name: Smoke test
run: |
java --enable-native-access=ALL-UNNAMED \
-cp target/openslide-java-*.jar org.openslide.TestCLI \
fixtures/small.svs
OPENSLIDE_DEBUG=synthetic java --enable-native-access=ALL-UNNAMED \
-cp target/openslide-java-*.jar org.openslide.TestCLI ""
- name: Dist
id: dist
if: matrix.dist
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This is a Java binding to [OpenSlide](https://openslide.org/).
## Runtime requirements

- JRE ≥ 22
- OpenSlide ≥ 3.4.0, in the system's library search path or preloaded with
- OpenSlide ≥ 4.0.0, in the system's library search path or preloaded with
`System.load()` or `System.loadLibrary()`


Expand Down
Binary file removed fixtures/small.svs
Binary file not shown.
22 changes: 12 additions & 10 deletions org/openslide/OpenSlide.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,29 @@ public String getDescription() {
private static final String LIBRARY_VERSION = OpenSlideFFM
.openslide_get_version();

final public static String PROPERTY_NAME_COMMENT = "openslide.comment";
final public static String PROPERTY_NAME_BACKGROUND_COLOR = "openslide.background-color";

final public static String PROPERTY_NAME_VENDOR = "openslide.vendor";
final public static String PROPERTY_NAME_BOUNDS_HEIGHT = "openslide.bounds-height";

final public static String PROPERTY_NAME_QUICKHASH1 = "openslide.quickhash-1";
final public static String PROPERTY_NAME_BOUNDS_WIDTH = "openslide.bounds-width";

final public static String PROPERTY_NAME_BACKGROUND_COLOR = "openslide.background-color";
final public static String PROPERTY_NAME_BOUNDS_X = "openslide.bounds-x";

final public static String PROPERTY_NAME_OBJECTIVE_POWER = "openslide.objective-power";
final public static String PROPERTY_NAME_BOUNDS_Y = "openslide.bounds-y";

final public static String PROPERTY_NAME_COMMENT = "openslide.comment";

final public static String PROPERTY_NAME_ICC_SIZE = "openslide.icc-size";

final public static String PROPERTY_NAME_MPP_X = "openslide.mpp-x";

final public static String PROPERTY_NAME_MPP_Y = "openslide.mpp-y";

final public static String PROPERTY_NAME_BOUNDS_X = "openslide.bounds-x";

final public static String PROPERTY_NAME_BOUNDS_Y = "openslide.bounds-y";
final public static String PROPERTY_NAME_OBJECTIVE_POWER = "openslide.objective-power";

final public static String PROPERTY_NAME_BOUNDS_WIDTH = "openslide.bounds-width";
final public static String PROPERTY_NAME_QUICKHASH1 = "openslide.quickhash-1";

final public static String PROPERTY_NAME_BOUNDS_HEIGHT = "openslide.bounds-height";
final public static String PROPERTY_NAME_VENDOR = "openslide.vendor";

private java.lang.foreign.MemorySegment osr;

Expand Down
35 changes: 16 additions & 19 deletions org/openslide/OpenSlideFFM.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,29 @@ private static SymbolLookup getSymbolLookup() {
return lookup;
}
String tmpl = System.mapLibraryName("openslide");
for (int ver = 1; ver >= 0; ver--) {
String lname;
if (tmpl.endsWith(".dll")) {
lname = String.format("libopenslide-%d.dll", ver);
} else if (tmpl.endsWith(".dylib")) {
lname = String.format("libopenslide.%d.dylib", ver);
} else {
lname = String.format("%s.%d", tmpl, ver);
}
try {
return SymbolLookup.libraryLookup(lname, LIBRARY_ARENA);
} catch (IllegalArgumentException ex) {
continue;
}
String lname;
if (tmpl.endsWith(".dll")) {
lname = "libopenslide-1.dll";
} else if (tmpl.endsWith(".dylib")) {
lname = "libopenslide.1.dylib";
} else {
lname = tmpl + ".1";
}
try {
return SymbolLookup.libraryLookup(lname, LIBRARY_ARENA);
} catch (IllegalArgumentException ex) {
throw new UnsatisfiedLinkError(
"Couldn't locate OpenSlide library; add it to the " +
"operating system's library search path or use " +
"System.load() or System.loadLibrary()");
}
throw new UnsatisfiedLinkError(
"Couldn't locate OpenSlide library; add it to the operating " +
"system's library search path or use System.load() or " +
"System.loadLibrary()");
}

private static MethodHandle function(MemoryLayout ret, String name,
MemoryLayout... args) {
MemorySegment symbol = SYMBOL_LOOKUP.find(name)
.orElseThrow(() -> new UnsatisfiedLinkError(
"Unresolved symbol " + name + "; need OpenSlide >= 3.4.0"));
"Unresolved symbol " + name + "; need OpenSlide >= 4.0.0"));
FunctionDescriptor desc;
if (ret != null) {
desc = FunctionDescriptor.of(ret, args);
Expand Down

0 comments on commit 138ba9a

Please sign in to comment.