summaryrefslogtreecommitdiff
blob: 829a18af69bdfbe27ac0026e69890adeb9cd9bfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
--- 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 + ")");
-            }
         }
     }