mobile/bind: fix JNI local reference table overflow

The existing implementation has  memory leaks on two local variables
that are not deleted after use. Android app will crash after this issue.

add UnitTest for this issue.

Fixes golang/go#14346

Change-Id: Ic233d15556ac97b35e00e13279a572c48a03049f
Reviewed-on: https://go-review.googlesource.com/19532
Reviewed-by: Elias Naur <elias.naur@gmail.com>
This commit is contained in:
ttyh061
2016-02-17 14:34:31 +00:00
committed by Elias Naur
parent 1fb745cd55
commit 5a8964bd48
3 changed files with 24 additions and 2 deletions
+12 -2
View File
@@ -4,10 +4,9 @@
package go;
import android.util.Log;
import android.test.suitebuilder.annotation.Suppress;
import android.test.AndroidTestCase;
import android.test.MoreAsserts;
import java.util.Arrays;
import java.util.Random;
@@ -386,6 +385,17 @@ public class SeqTest extends AndroidTestCase {
assertEquals("want back the error message we set", want, got);
}
//test if we have JNI local reference table overflow error
public void testLocalReferenceOverflow() {
Testpkg.CallWithCallback(new Testpkg.GoCallback.Stub() {
@Override
public void VarUpdate() {
//do nothing
}
});
}
public void testNullReferences() {
assertTrue(Testpkg.CallWithNull(null, new Testpkg.NullTest.Stub() {
public Testpkg.NullTest Null() {