bind/java: custom int-keyed hashmap

This removes the last dependency on an Android class in the running
gobind code. (Tests still need some work before they will run on the
desktop.)

Change-Id: I49bfb545d4587c6f430c0938fa1ca4d513b56d77
Reviewed-on: https://go-review.googlesource.com/17252
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
David Crawshaw
2015-12-02 14:48:43 +00:00
parent 2454c829c1
commit e154aff74e
2 changed files with 141 additions and 4 deletions
+36
View File
@@ -316,6 +316,42 @@ public class SeqTest extends AndroidTestCase {
assertFalse("want obj to be kept live by Go", finalizedAnI);
}
private int countI = 0;
private class CountI extends Testpkg.I.Stub {
public void F() { countI++; }
public void E() throws Exception {}
public Testpkg.I I() { return null; }
public Testpkg.S S() { return null; }
public String StoString(Testpkg.S s) { return ""; }
public long V() { return 0; }
public long VE() throws Exception { return 0; }
public String String() { return ""; }
}
public void testGoRefMapGrow() {
CountI obj = new CountI();
Testpkg.Keep(obj);
// Push active references beyond base map size.
for (int i = 0; i < 24; i++) {
CountI o = new CountI();
Testpkg.CallF(o);
if (i%3==0) {
Testpkg.Keep(o);
}
}
runGC();
for (int i = 0; i < 128; i++) {
Testpkg.CallF(new CountI());
}
Testpkg.CallF(obj); // original object needs to work.
assertEquals(countI, 1+24+128);
}
private void runGC() {
System.gc();
System.runFinalization();