@@ -1125,13 +1125,18 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
11251125 *
11261126 * @param cls the Class whose package name and {@link ClassLoader} are used to extract from resources
11271127 * @param properties contains the directories to scan for if we fail to extract the library from resources
1128- * @param libnameversion the name of the library + "@" + optional version tag
1128+ * @param libnameversion ":" to disable prefixes and suffixes + the name of the library + "@" + optional version tag
11291129 * + "#" + a second optional name used at extraction (or empty to prevent it)
11301130 * + "!" to load all symbols globally
11311131 * @param pathsFirst search the paths first before bundled resources
11321132 * @return URLs that point to potential locations of the library
11331133 */
11341134 public static URL [] findLibrary (Class cls , ClassProperties properties , String libnameversion , boolean pathsFirst ) {
1135+ boolean nostyle = false ;
1136+ if (libnameversion .startsWith (":" )) {
1137+ nostyle = true ;
1138+ libnameversion = libnameversion .substring (1 );
1139+ }
11351140 if (libnameversion .endsWith ("!" )) {
11361141 libnameversion = libnameversion .substring (0 , libnameversion .length () - 1 );
11371142 }
@@ -1176,6 +1181,10 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
11761181 styles2 [3 * i + 2 ] = prefix + libname2 + suffixes [i ]; // without version
11771182 }
11781183 }
1184+ if (nostyle ) {
1185+ styles = new String [] {libname };
1186+ styles2 = new String [] {libname2 };
1187+ }
11791188
11801189 List <String > paths = new ArrayList <String >();
11811190 paths .addAll (properties .get ("platform.linkpath" ));
@@ -1241,7 +1250,7 @@ public static URL[] findLibrary(Class cls, ClassProperties properties, String li
12411250 * Finally, if all fails, falls back on {@link System#loadLibrary(String)}.
12421251 *
12431252 * @param urls the URLs to try loading the library from
1244- * @param libnameversion the name of the library + "@" + optional version tag
1253+ * @param libnameversion ":" to disable prefixes and suffixes + the name of the library + "@" + optional version tag
12451254 * + "#" + a second optional name used at extraction (or empty to prevent it)
12461255 * + "!" to load all symbols globally
12471256 * @param preloaded libraries for which to create symbolic links in same cache directory
@@ -1253,6 +1262,9 @@ public static synchronized String loadLibrary(URL[] urls, String libnameversion,
12531262 if (!isLoadLibraries ()) {
12541263 return null ;
12551264 }
1265+ if (libnameversion .startsWith (":" )) {
1266+ libnameversion = libnameversion .substring (1 );
1267+ }
12561268 boolean loadGlobally = false ;
12571269 if (libnameversion .endsWith ("!" )) {
12581270 loadGlobally = true ;
@@ -1355,7 +1367,10 @@ public static synchronized String loadLibrary(URL[] urls, String libnameversion,
13551367 return filename ;
13561368 } else if (!libnameversion .trim ().endsWith ("#" )) {
13571369 // ... or as last resort, try to load it via the system.
1358- String libname = libnameversion .split ("#" )[0 ].split ("@" )[0 ].split ("!" )[0 ];
1370+ String libname = libnameversion .split ("#" )[0 ].split ("@" )[0 ];
1371+ if (libname .endsWith ("!" )) {
1372+ libname = libname .substring (0 , libname .length () - 1 );
1373+ }
13591374 if (logger .isDebugEnabled ()) {
13601375 logger .debug ("Loading library " + libname );
13611376 }
@@ -1400,7 +1415,10 @@ public static synchronized String loadLibrary(URL[] urls, String libnameversion,
14001415 * @return the version-less filename (or null on failure), a symbolic link only if needed
14011416 */
14021417 public static String createLibraryLink (String filename , ClassProperties properties , String libnameversion , String ... paths ) {
1403- if (libnameversion .endsWith ("!" )) {
1418+ if (libnameversion != null && libnameversion .startsWith (":" )) {
1419+ libnameversion = libnameversion .substring (1 );
1420+ }
1421+ if (libnameversion != null && libnameversion .endsWith ("!" )) {
14041422 libnameversion = libnameversion .substring (0 , libnameversion .length () - 1 );
14051423 }
14061424 File file = new File (filename );
0 commit comments