Skip to content

Commit 665daa1

Browse files
committed
* Let Loader.load() extract libraries suffixed with ##, but still ignored for copying by Builder
1 parent 2f7c956 commit 665daa1

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
* Let `Loader.load()` extract libraries suffixed with `##`, but still ignored for copying by `Builder`
23
* Make sure `Loader.load()` also initializes classes that are passed explicitly
34
* Fix `Loader.createLibraryLink()` incorrectly truncating library versions when there is one before and another after the suffix
45
* Iterate extensions of libraries or executables on `Loader.load()` in reverse to be consistent with properties overriding

src/main/java/org/bytedeco/javacpp/Loader.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
11361136
* @param cls the Class whose package name and {@link ClassLoader} are used to extract from resources
11371137
* @param properties contains the directories to scan for if we fail to extract the library from resources
11381138
* @param libnameversion ":" to disable prefixes and suffixes + the name of the library + "@" + optional version tag
1139-
* + "#" + a second optional name used at extraction (or empty to prevent it)
1139+
* + "#" + a second optional name used at extraction (or empty to prevent it, unless it is a second "#")
11401140
* + "!" to load all symbols globally
11411141
* @param pathsFirst search the paths first before bundled resources
11421142
* @return URLs that point to potential locations of the library
@@ -1150,11 +1150,11 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
11501150
if (libnameversion.endsWith("!")) {
11511151
libnameversion = libnameversion.substring(0, libnameversion.length() - 1);
11521152
}
1153-
if (libnameversion.trim().endsWith("#")) {
1153+
if (libnameversion.trim().endsWith("#") && !libnameversion.trim().endsWith("##")) {
11541154
return new URL[0];
11551155
}
11561156
String[] split = libnameversion.split("#");
1157-
boolean reference = split.length > 1;
1157+
boolean reference = split.length > 1 && split[1].length() > 0;
11581158
String[] s = split[0].split("@");
11591159
String[] s2 = (reference ? split[1] : split[0]).split("@");
11601160
String libname = s[0];
@@ -1263,7 +1263,7 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
12631263
*
12641264
* @param urls the URLs to try loading the library from
12651265
* @param libnameversion ":" to disable prefixes and suffixes + the name of the library + "@" + optional version tag
1266-
* + "#" + a second optional name used at extraction (or empty to prevent it)
1266+
* + "#" + a second optional name used at extraction (or empty to prevent it, unless it is a second "#")
12671267
* + "!" to load all symbols globally
12681268
* @param preloaded libraries for which to create symbolic links in same cache directory
12691269
* @return the full path of the file loaded, or the library name if unknown
@@ -1284,7 +1284,7 @@ public static synchronized String loadLibrary(URL[] urls, String libnameversion,
12841284
}
12851285
String[] split = libnameversion.split("#");
12861286
String libnameversion2 = split[0];
1287-
if (split.length > 1) {
1287+
if (split.length > 1 && split[1].length() > 0) {
12881288
libnameversion2 = split[1];
12891289
}
12901290

@@ -1437,7 +1437,7 @@ public static String createLibraryLink(String filename, ClassProperties properti
14371437
String parent = file.getParent(), name = file.getName(), link = null;
14381438

14391439
String[] split = libnameversion != null ? libnameversion.split("#") : new String[] {""};
1440-
String[] s = (split.length > 1 ? split[1] : split[0]).split("@");
1440+
String[] s = (split.length > 1 && split[1].length() > 0 ? split[1] : split[0]).split("@");
14411441
String libname = s[0];
14421442
String version = s.length > 1 ? s[s.length-1] : "";
14431443

0 commit comments

Comments
 (0)