cmd/gomobile: call System.loadLibrary for .aar

Change-Id: I3fd099910cfb1fe112ded4386905d370acfea002
Reviewed-on: https://go-review.googlesource.com/11816
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
David Crawshaw
2015-07-06 22:21:32 +00:00
parent ddd9618c5b
commit 5ced61ace7
3 changed files with 23 additions and 2 deletions
+8
View File
@@ -15,6 +15,14 @@ import java.util.concurrent.Executors;
// Used by automatically generated language bindings to talk to Go.
public class Seq {
static {
// Look for the shim class auto-generated by gomobile bind.
// Its only purpose is to call System.loadLibrary.
try {
Class.forName("go.LoadJNI");
} catch (ClassNotFoundException e) {
// Ignore, assume the user will load JNI for it.
}
initSeq();
new Thread("GoSeq") {
public void run() { Seq.receive(); }
-1
View File
@@ -15,7 +15,6 @@ import go.testpkg.Testpkg;
public class SeqTest extends AndroidTestCase {
public SeqTest() {
System.loadLibrary("gojni");
}
public void testAdd() {
+15 -1
View File
@@ -150,8 +150,13 @@ func runBind(cmd *command) error {
return err
}
dst := filepath.Join(androidDir, "src/main/java/go/LoadJNI.java")
if err := ioutil.WriteFile(dst, []byte(loadSrc), 0664); err != nil {
return err
}
src := filepath.Join(repo, "bind/java/Seq.java")
dst := filepath.Join(androidDir, "src/main/java/go/Seq.java")
dst = filepath.Join(androidDir, "src/main/java/go/Seq.java")
rm(dst)
if err := symlink(src, dst); err != nil {
return err
@@ -160,6 +165,15 @@ func runBind(cmd *command) error {
return buildAAR(androidDir, bindPkg)
}
var loadSrc = `package go;
public class LoadJNI {
static {
System.loadLibrary("gojni");
}
}
`
type binder struct {
files []*ast.File
fset *token.FileSet