From 38fb8b2b4141a86fce56086cf82d047a7943c742 Mon Sep 17 00:00:00 2001 From: tison Date: Wed, 27 Sep 2023 14:34:35 +0800 Subject: [PATCH] chore(bindings/java): simplify library path resolution Signed-off-by: tison --- .../java/org/apache/opendal/NativeObject.java | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/bindings/java/src/main/java/org/apache/opendal/NativeObject.java b/bindings/java/src/main/java/org/apache/opendal/NativeObject.java index d136e365975..edd92702702 100644 --- a/bindings/java/src/main/java/org/apache/opendal/NativeObject.java +++ b/bindings/java/src/main/java/org/apache/opendal/NativeObject.java @@ -122,20 +122,9 @@ private static void doLoadBundledLibrary() throws IOException { } private static String bundledLibraryPath() { - final String os = System.getProperty("os.name").toLowerCase(); - final StringBuilder path = new StringBuilder("/native/" + Environment.getClassifier() + "/"); - if (!os.startsWith("windows")) { - path.append("lib"); - } - path.append("opendal_java"); - if (os.startsWith("windows")) { - path.append(".dll"); - } else if (os.startsWith("mac")) { - path.append(".dylib"); - } else { - path.append(".so"); - } - return path.toString(); + final String classifier = Environment.getClassifier(); + final String libraryName = System.mapLibraryName("opendal_java"); + return "/native/" + classifier + "/" + libraryName; } /**