You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-java/jssc/files/jssc-2.8.0-library-load.patch

118 lines
4.5 KiB

--- src/java/jssc/SerialNativeInterface.java.orig 2016-03-13 16:35:20.521644430 -0400
+++ src/java/jssc/SerialNativeInterface.java 2016-03-13 16:38:00.022571256 -0400
@@ -44,7 +44,7 @@
public static final int OS_SOLARIS = 2;//since 0.9.0
public static final int OS_MAC_OS_X = 3;//since 0.9.0
- private static int osType = -1;
+ private static int osType = OS_LINUX;
/**
* @since 2.3.0
@@ -77,104 +77,11 @@
public static final String PROPERTY_JSSC_PARMRK = "JSSC_PARMRK";
static {
- String libFolderPath;
- String libName;
-
- String osName = System.getProperty("os.name");
- String architecture = System.getProperty("os.arch");
- String userHome = System.getProperty("user.home");
- String fileSeparator = System.getProperty("file.separator");
- String tmpFolder = System.getProperty("java.io.tmpdir");
-
- //since 2.3.0 ->
- String libRootFolder = new File(userHome).canWrite() ? userHome : tmpFolder;
- //<- since 2.3.0
-
- String javaLibPath = System.getProperty("java.library.path");//since 2.1.0
-
- if(osName.equals("Linux")){
- osName = "linux";
- osType = OS_LINUX;
- }
- else if(osName.startsWith("Win")){
- osName = "windows";
- osType = OS_WINDOWS;
- }//since 0.9.0 ->
- else if(osName.equals("SunOS")){
- osName = "solaris";
- osType = OS_SOLARIS;
- }
- else if(osName.equals("Mac OS X") || osName.equals("Darwin")){//os.name "Darwin" since 2.6.0
- osName = "mac_os_x";
- osType = OS_MAC_OS_X;
- }//<- since 0.9.0
-
- if(architecture.equals("i386") || architecture.equals("i686")){
- architecture = "x86";
- }
- else if(architecture.equals("amd64") || architecture.equals("universal")){//os.arch "universal" since 2.6.0
- architecture = "x86_64";
- }
- else if(architecture.equals("arm")) {//since 2.1.0
- String floatStr = "sf";
- if(javaLibPath.toLowerCase().contains("gnueabihf") || javaLibPath.toLowerCase().contains("armhf")){
- floatStr = "hf";
- }
- else {
- try {
- Process readelfProcess = Runtime.getRuntime().exec("readelf -A /proc/self/exe");
- BufferedReader reader = new BufferedReader(new InputStreamReader(readelfProcess.getInputStream()));
- String buffer = "";
- while((buffer = reader.readLine()) != null && !buffer.isEmpty()){
- if(buffer.toLowerCase().contains("Tag_ABI_VFP_args".toLowerCase())){
- floatStr = "hf";
- break;
- }
- }
- reader.close();
- }
- catch (Exception ex) {
- //Do nothing
- }
- }
- architecture = "arm" + floatStr;
- }
-
- libFolderPath = libRootFolder + fileSeparator + ".jssc" + fileSeparator + osName;
- libName = "jSSC-" + libVersion + "_" + architecture;
- libName = System.mapLibraryName(libName);
-
- if(libName.endsWith(".dylib")){//Since 2.1.0 MacOSX 10.8 fix
- libName = libName.replace(".dylib", ".jnilib");
- }
-
- boolean loadLib = false;
-
- if(isLibFolderExist(libFolderPath)){
- if(isLibFileExist(libFolderPath + fileSeparator + libName)){
- loadLib = true;
- }
- else {
- if(extractLib((libFolderPath + fileSeparator + libName), osName, libName)){
- loadLib = true;
- }
- }
- }
- else {
- if(new File(libFolderPath).mkdirs()){
- if(extractLib((libFolderPath + fileSeparator + libName), osName, libName)){
- loadLib = true;
- }
- }
- }
-
- if (loadLib) {
- System.load(libFolderPath + fileSeparator + libName);
+ System.loadLibrary("jssc");
String versionBase = getLibraryBaseVersion();
String versionNative = getNativeLibraryVersion();
if (!versionBase.equals(versionNative)) {
System.err.println("Warning! jSSC Java and Native versions mismatch (Java: " + versionBase + ", Native: " + versionNative + ")");
- }
}
}