Skip to content

Commit e264a35

Browse files
committed
try harder to fix sip issue for java
Signed-off-by: Andrey Parfenov <[email protected]>
1 parent 062218c commit e264a35

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

java-package/brainflow/src/main/java/brainflow/BoardShim.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55
import java.io.InputStream;
66
import java.nio.file.Files;
7+
import java.nio.file.Path;
78
import java.util.Arrays;
89

910
import org.apache.commons.lang3.SystemUtils;
@@ -92,7 +93,11 @@ int get_current_board_data (int num_samples, double[] data_buf, int[] returned_s
9293
} else if (SystemUtils.IS_OS_MAC)
9394
{
9495
lib_name = "libBoardController.dylib";
95-
unpack_from_jar ("libneurosdk-shared.dylib");
96+
Path location = unpack_from_jar ("libneurosdk-shared.dylib");
97+
if (location != null)
98+
{
99+
System.load (location.toString ());
100+
}
96101
}
97102

98103
// need to extract libraries from jar
@@ -102,7 +107,7 @@ int get_current_board_data (int num_samples, double[] data_buf, int[] returned_s
102107
instance = (DllInterface) Native.loadLibrary (lib_name, DllInterface.class);
103108
}
104109

105-
private static void unpack_from_jar (String lib_name)
110+
private static Path unpack_from_jar (String lib_name)
106111
{
107112
try
108113
{
@@ -111,9 +116,11 @@ private static void unpack_from_jar (String lib_name)
111116
file.delete ();
112117
InputStream link = (BoardShim.class.getResourceAsStream (lib_name));
113118
Files.copy (link, file.getAbsoluteFile ().toPath ());
119+
return file.getAbsoluteFile ().toPath ();
114120
} catch (Exception io)
115121
{
116-
System.err.println ("native library: " + lib_name + " is not found in jar file");
122+
System.err.println ("file: " + lib_name + " is not found in jar file");
123+
return null;
117124
}
118125
}
119126

0 commit comments

Comments
 (0)