boolean loadCandidateLibrary ( String aLibraryName , Long aMajorVersion , List < String > aLibCandidates ) { boolean retval = false ; for ( String candidate : aLibCandidates ) { log . trace ( "Attempt: library load of library: {}; version: {}: relative path: {}" , new Object [ ] { aLibraryName , aMajorVersion == null ? "<unspecified>" : aMajorVersion . longValue ( ) , candidate } ) ; File candidateFile = new File ( candidate ) ; if ( candidateFile . exists ( ) ) { String absPath = candidateFile . getAbsolutePath ( ) ; try { log . trace ( "Attempt: library load of library: {}; version: {}: absolute path: {}" , new Object [ ] { aLibraryName , aMajorVersion == null ? "<unspecified>" : aMajorVersion . longValue ( ) , absPath } ) ; // Here's where we attempt the actual load. System . load ( absPath ) ; log . trace ( "Success: library load of library: {}; version: {}: absolute path: {}" , new Object [ ] { aLibraryName , aMajorVersion == null ? "<unspecified>" : aMajorVersion . longValue ( ) , absPath } ) ; // if we got here, we loaded successfully setLoadedLibrary ( aLibraryName , aMajorVersion ) ; retval = true ; break ; } catch ( UnsatisfiedLinkError e ) { log . warn ( "Failure: library load of library: {}; version: {}: absolute path: {}; error: {}" , new Object [ ] { aLibraryName , aMajorVersion == null ? "<unspecified>" : aMajorVersion . longValue ( ) , absPath , e } ) ; } catch ( SecurityException e ) { log . warn ( "Failure: library load of library: {}; version: {}: absolute path: {}; error: {}" , new Object [ ] { aLibraryName , aMajorVersion == null ? "<unspecified>" : aMajorVersion . longValue ( ) , absPath , e } ) ; } } } return retval ; }
Iterates through the set of aLibCandidates until it succeeds in loading a library . If it succeeds it lets the cache know .