Hello:I'm trouble using BridJ to load a dll in a JNAerator produced code, so I tried using minimum test classes (see attached) to troubleshoot the problem. The strange thing is the same dll loads without problems through JNA, fails without further information in BridJ. I am using bridj 0.6.2 jna 3.4.0 and jdk1.6.0_38 (brtdll.dll, CheckUsability.dll)Does somebody have any ideas why BridJ would fail to load the library or how to troubleshoot the problem?Thanks***********Bridj**************@Library("CheckUsability")@org.bridj.ann.Runtime(CRuntime.class)public class LoadLibraryTest2 {static {System.setProperty("java.library.path", ".\\src\\main\\resources");System.setProperty("bridj.veryVerbose", "true");System.setProperty("bridj.debug", "true");System.setProperty("bridj.logCalls", "true");System.setProperty("bridj.direct", "true");BridJ.register();}***********JNA**************--public class LoadLibraryTest {public static final String JNA_LIBRARY_NAME = "CheckUsability";static {System.setProperty("jna.library.path", ".\\src\\main\\resources");NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(JNA_LIBRARY_NAME);System.err.print(JNA_NATIVE_LIB.toString());}
You received this message because you are subscribed to the Google Groups "NativeLibs4Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nativelibs4ja...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Csaba:Thanks for your quick answer.The properties in the static initializer seem to be recognized properly, both by the dll locator and by the debugger (see attached bridj log)I've played with different ways to locate the dlls () and they all seem to find the file properly. I stepped all the way down to the org.bridj.NativeLibrary.load(String path) method, and the path string is correct (full path to the dll). Nevertheless the JNI.loadLibrary(path); returns a 0 handle, with no errors or any further information.In fact I did another quick test to verify the dll was properly located: This dll only works with Java 32 bits, so I did change the JRE from x86 to x64 and I got the expected error:# BridJ: LoadLibrary error when loading C:\Users\mventura\AppData\Local\Temp\BridJExtractedLibraries7057517034870956580\CheckUsability.dll : %1 is not a valid Win32 application.So it looks like the library is properly located, but not loaded in X86. I thought it might be due to other dll dependencies, but JNA loads it properly and the dependency walker doesn't show anything missing.By the way, I'm surprised the code uses that JNI implementation, since it seems to be deprecated (as per the java docs * @deprecated These methods can cause serious issues (segmentation fault, system crashes) if used without care : there are little to no checks performed on the arguments.)Cheers
Csaba:Thanks for your quick answer.The properties in the static initializer seem to be recognized properly, both by the dll locator and by the debugger (see attached bridj log)I've played with different ways to locate the dlls () and they all seem to find the file properly. I stepped all the way down to the org.bridj.NativeLibrary.load(String path) method, and the path string is correct (full path to the dll). Nevertheless the JNI.loadLibrary(path); returns a 0 handle, with no errors or any further information.In fact I did another quick test to verify the dll was properly located: This dll only works with Java 32 bits, so I did change the JRE from x86 to x64 and I got the expected error:# BridJ: LoadLibrary error when loading C:\Users\mventura\AppData\Local\Temp\BridJExtractedLibraries7057517034870956580\CheckUsability.dll : %1 is not a valid Win32 application.So it looks like the library is properly located, but not loaded in X86. I thought it might be due to other dll dependencies, but JNA loads it properly and the dependency walker doesn't show anything missing.By the way, I'm surprised the code uses that JNI implementation, since it seems to be deprecated (as per the java docs * @deprecated These methods can cause serious issues (segmentation fault, system crashes) if used without care : there are little to no checks performed on the arguments.)Cheers