Author: remm Date: Thu Jun 28 11:15:33 2018 New Revision: 1834595 URL: http://svn.apache.org/viewvc?rev=1834595&view=rev Log: 56676: Use bin/native as a default location for the native libraries. bin/native is already used by the testsuite, and it can be useful for development and embedded. I don't plan to backport the change.
Modified: tomcat/trunk/java/org/apache/tomcat/jni/Library.java tomcat/trunk/webapps/docs/changelog.xml Modified: tomcat/trunk/java/org/apache/tomcat/jni/Library.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/jni/Library.java?rev=1834595&r1=1834594&r2=1834595&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/jni/Library.java (original) +++ tomcat/trunk/java/org/apache/tomcat/jni/Library.java Thu Jun 28 11:15:33 2018 @@ -34,12 +34,13 @@ public final class Library { private Library() throws Exception { boolean loaded = false; - String path = System.getProperty("java.library.path"); - String [] paths = path.split(File.pathSeparator); StringBuilder err = new StringBuilder(); + File binLib = new File(System.getProperty("catalina.home"), "bin"); + File nativeLib = new File(binLib, "native"); for (int i = 0; i < NAMES.length; i++) { + File library = new File(nativeLib, System.mapLibraryName(NAMES[i])); try { - System.loadLibrary(NAMES[i]); + System.load(library.getPath()); loaded = true; } catch (ThreadDeath t) { throw t; @@ -48,13 +49,9 @@ public final class Library { // the JNI code identical between Tomcat 6/7/8/9 throw t; } catch (Throwable t) { - String name = System.mapLibraryName(NAMES[i]); - for (int j = 0; j < paths.length; j++) { - java.io.File fd = new java.io.File(paths[j] , name); - if (fd.exists()) { - // File exists but failed to load - throw t; - } + if (library.exists()) { + // File exists but failed to load + throw t; } if (i > 0) { err.append(", "); @@ -66,6 +63,38 @@ public final class Library { } } if (!loaded) { + String path = System.getProperty("java.library.path"); + String [] paths = path.split(File.pathSeparator); + for (int i = 0; i < NAMES.length; i++) { + try { + System.loadLibrary(NAMES[i]); + loaded = true; + } catch (ThreadDeath t) { + throw t; + } catch (VirtualMachineError t) { + // Don't use a Java 7 multiple exception catch so we can keep + // the JNI code identical between Tomcat 6/7/8/9 + throw t; + } catch (Throwable t) { + String name = System.mapLibraryName(NAMES[i]); + for (int j = 0; j < paths.length; j++) { + java.io.File fd = new java.io.File(paths[j] , name); + if (fd.exists()) { + // File exists but failed to load + throw t; + } + } + if (i > 0) { + err.append(", "); + } + err.append(t.getMessage()); + } + if (loaded) { + break; + } + } + } + if (!loaded) { StringBuilder names = new StringBuilder(); for (String name : NAMES) { names.append(name); Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1834595&r1=1834594&r2=1834595&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Thu Jun 28 11:15:33 2018 @@ -64,6 +64,10 @@ reduce the use of ThreadLocals and to increase the use of caching. (markt) </scode> + <fix> + <bug>56676</bug>: Add a default location for the native library, as + bin/native, which the testsuite already uses. (remm) + </fix> </changelog> </subsection> <subsection name="Other"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org