Mac version never loads of JNI library fat binary because 10.4 version preceeds x86_64 version

Issue #50 resolved
Former user created an issue

Originally reported on Google Code with ID 50

It seems that the code that searches for the JNI library always includes the architecture
in the name string, thus it will always search for sqlite4java-osx-x86_64.jnilib or
sqlite4java-osx-i386.jnilib, and will never match to the fat binary. On my (x86_64)
machine this code always ends up using sqlite4java-osx-10.4.jnilib, which doesn't seem
ideal.

I would suggest adding the following to collectBaseLibraryNames:
if ("osx".equals(os)) {
      r.add(base);
}

Reported by patrickkonsor on 2012-12-12 18:28:56

Comments (4)

  1. Igor Sereda
    But it does check base name - see collectBaseLibraryNames just two lines further. Please
    try running this: 
       java -jar sqlite4java.jar -d
    to make it try to load all variants of the binary and output the results.
    

    Reported by sereda on 2012-12-12 20:26:15

  2. Former user Account Deleted
    You're right, it does, but in this case it's after the check for -10.4, which causes
    it to match to -10.4 rather than the fat binary. r.add(base) should be moved up a few
    lines.
    
    java -jar sqlite4java.jar -d
    sqlite4java 282
    121212:134119.239 FINE [sqlite] Internal: loading library
    121212:134119.239 FINE [sqlite] Internal: java.library.path=/Users/XXXXX/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
    121212:134119.240 FINE [sqlite] Internal: sqlite4java.library.path=null
    121212:134119.240 FINE [sqlite] Internal: cwd=XXXXX
    121212:134119.240 FINE [sqlite] Internal: default path=XXXXX
    121212:134119.240 FINE [sqlite] Internal: forced path=null 
    121212:134119.240 FINE [sqlite] Internal: os.name=mac os x; os=osx
    121212:134119.240 FINE [sqlite] Internal: os.arch=x86_64
    121212:134119.240 FINE [sqlite] Internal: trying to load sqlite4java-osx-x86_64
    121212:134119.243 FINE [sqlite] Internal: cannot load sqlite4java-osx-x86_64: java.lang.UnsatisfiedLinkError:
    no sqlite4java-osx-x86_64 in java.library.path
    121212:134119.243 FINE [sqlite] Internal: trying to load sqlite4java-osx-amd64
    121212:134119.244 FINE [sqlite] Internal: cannot load sqlite4java-osx-amd64: java.lang.UnsatisfiedLinkError:
    no sqlite4java-osx-amd64 in java.library.path
    121212:134119.244 FINE [sqlite] Internal: trying to load sqlite4java-osx-10.4
    121212:134119.249 INFO [sqlite] Internal: loaded sqlite4java-osx-10.4 from system path
    121212:134119.252 INFO [sqlite] Internal: loaded sqlite 3.7.10, wrapper 0.2
    SQLite 3.7.10
    Compile-time options: ENABLE_COLUMN_METADATA ENABLE_FTS3 ENABLE_FTS3_PARENTHESIS ENABLE_LOCKING_STYLE=0
    ENABLE_MEMORY_MANAGEMENT ENABLE_RTREE OMIT_DEPRECATED TEMP_STORE=1 THREADSAFE=1
    

    Reported by patrickkonsor on 2012-12-12 21:44:42

  3. Igor Sereda
    The files are tried in the order of more specific to less specific. So the order is
    correct. 
    
    The problem is that there's no more specific binary - so we might need to rename libsqlite4java-osx.jnilib
    to libsqlite4java-osx-amd64.jnilib.
    
    The workaround in your case is to do that manually - rename the file, or remove 10.4
    binary.
    

    Reported by sereda on 2012-12-14 10:18:25 - Status changed: Accepted

  4. Log in to comment