From: Miguel C. <mc...@de...> - 2013-03-25 15:51:14
|
You're correct, thanks for fixing that:-) Miguel On Mar 20, 2013, at 23:04 , Sergio Castro wrote: > Hi, > > Not sure but I think I found a bug in the InterProlog NativeEngine class. > > Currently the constructor loads the XSB native library with this code: > > public NativeEngine(String XSB_BIN_DIR, String[] XSB_ARGS, boolean debug, boolean loadFromJar) { > super(XSB_BIN_DIR,debug,loadFromJar); > numberOfInstances++; > if (numberOfInstances > 1) > throw new IPException("Can't have more than one instance of NativeEngine"); > // On creation of the first NativeEngine instance, the XSB.dll is loaded. > // First, xsbBinDir and xsbBinDir\xsb.dll are tested for existence. > // If they do exist, then the dll is loaded from this xsb.dll. If > // either do not, then the System Path is used to locate xsb.dll. > > > if (numberOfInstances == 1) { > File xsbDLLFile = null; > if (XSB_BIN_DIR != null) { > File providedBinDirectory = new File(XSB_BIN_DIR); > xsbDLLFile = new File(providedBinDirectory, "xsb.dll"); > } > if (isWindowsOS() && xsbDLLFile != null && xsbDLLFile.exists()) { > System.load(xsbDLLFile.getAbsolutePath()); > } else { > System.loadLibrary("xsb"); > } > } > ... > > } > > > The constructor checks if the library exists in the bin directory sent as first argument. Otherwise it tries to find the library according to the entries in "java.library.path" (with a call to System.loadLibrary("xsb")). > The problem is that this will work only on Windows (given the explicit condition "isWindowsOS()"), otherwise the bin directory sent as argument is just ignored and will go directly to try to load the library according to the entries in "java.library.path". > > Instead, the code should be something like this : > > if (numberOfInstances == 1) { > File libraryFile = null; > if (XSB_BIN_DIR != null) { > File providedBinDirectory = new File(XSB_BIN_DIR); > if(isWindowsOS()) > libraryFile = new File(providedBinDirectory, "xsb.dll"); > else > libraryFile = new File(providedBinDirectory, "xsb"); > } > if (libraryFile != null && libraryFile.exists()) { > System.load(libraryFile.getAbsolutePath()); > } else { > System.loadLibrary("xsb"); > } > } > > --- > > my two cents :) > > cheers, > > Sergio > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_d2d_mar_______________________________________________ > Xsb-development mailing list > Xsb...@li... > https://lists.sourceforge.net/lists/listinfo/xsb-development |