Initial commit with a working build.

Some of the tests are failing.
This commit is contained in:
sridharv
2016-03-27 19:53:45 +02:00
commit 327d3f573c
7 changed files with 807 additions and 0 deletions

39
LoadJNI.java Normal file
View File

@ -0,0 +1,39 @@
package go;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.InputStream;
import java.io.File;
import java.io.IOException;
public class LoadJNI {
static {
try {
loadLibrary();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
private static void loadLibrary() throws IOException {
File temp = File.createTempFile("gojava", "gojava");
temp.deleteOnExit();
InputStream input = LoadJNI.class.getResourceAsStream("/go/libgojava");
if (input == null) {
throw new RuntimeException("Go JNI library not found in classpath");
}
OutputStream out = new FileOutputStream(temp);
try {
byte[] buffer = new byte[1024];
int readBytes = 0;
while ((readBytes = input.read(buffer)) != -1) {
out.write(buffer, 0, readBytes);
}
} finally {
out.close();
input.close();
}
System.load(temp.getAbsolutePath());
}
}