Skip to content

Commit 9956784

Browse files
author
Mihail Slavchev
committed
Merge branch 'release'
2 parents e533125 + 5afd954 commit 9956784

File tree

7 files changed

+70
-3
lines changed

7 files changed

+70
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
- [[Proposal] Static binding generator specification. (#363)](https://github.com/NativeScript/android-runtime/issues/363)
88
- [Android Runtime Support for older Android versions (#357)](https://github.com/NativeScript/android-runtime/issues/357)
99
- [Data Marshalling: Support for typed arrays (#65)](https://github.com/NativeScript/android-runtime/issues/65)
10-
10+
- [Support Android Widgets](https://github.com/NativeScript/android-runtime/issues/69)
11+
- [Add support for caching already compiled JS code](https://github.com/NativeScript/android-runtime/issues/257)
12+
- [Additional Intents Crashes app](https://github.com/NativeScript/android-runtime/issues/218)
13+
- [Enable Multidex support](https://github.com/NativeScript/android-runtime/issues/344)
14+
1115
## Bug Fixes
1216

1317
- [Wrong object lifecycle management (#382)](https://github.com/NativeScript/android-runtime/issues/382)

src/src/com/tns/NativeScriptHashMap.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,8 @@ public V put(K key, V value)
417417
int index = hash & (tab.length - 1);
418418
for (HashMapEntry<K, V> e = tab[index]; e != null; e = e.next)
419419
{
420-
if (e.hash == hash && key.equals(e.key))
420+
K eKey = e.key;
421+
if (eKey == key || (e.hash == hash && key.equals(eKey)))
421422
{
422423
preModify(e);
423424
V oldValue = e.value;
@@ -689,7 +690,8 @@ public V remove(Object key)
689690
int index = hash & (tab.length - 1);
690691
for (HashMapEntry<K, V> e = tab[index], prev = null; e != null; prev = e, e = e.next)
691692
{
692-
if (e.hash == hash && key.equals(e.key))
693+
K eKey = e.key;
694+
if (eKey == key || (e.hash == hash && key.equals(eKey)))
693695
{
694696
if (prev == null)
695697
{

test-app/assets/app/tests/testGC.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,4 +264,32 @@ describe("Tests garbage collection", function () {
264264
gc();
265265
java.lang.System.gc();
266266
});
267+
268+
it("should properly reintroduce Java object back in a callback", function () {
269+
function getTestObject() {
270+
return new com.tns.tests.BadEqualsTest(
271+
new com.tns.tests.BadEqualsTest.BadEqualsObject(),
272+
new com.tns.tests.BadEqualsTest.Callback({
273+
onFinish: function(o) {
274+
__log(">>o=" + o.toString());
275+
}
276+
}));
277+
}
278+
279+
var test = getTestObject();
280+
281+
// flush LRU cache
282+
for (var i=0; i<65536; i++) {
283+
new java.lang.Object().hashCode();
284+
}
285+
286+
gc();
287+
java.lang.Runtime.getRuntime().gc();
288+
gc();
289+
java.lang.Runtime.getRuntime().gc();
290+
gc();
291+
java.lang.Runtime.getRuntime().gc();
292+
293+
test.postCallback();
294+
});
267295
});
-1.79 KB
Binary file not shown.
-94.7 KB
Binary file not shown.
-92.6 KB
Binary file not shown.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.tns.tests;
2+
3+
import android.os.Handler;
4+
import android.os.Looper;
5+
6+
public class BadEqualsTest {
7+
public static final class BadEqualsObject {
8+
public boolean equals(Object o) {
9+
return false;
10+
}
11+
}
12+
13+
public interface Callback {
14+
void onFinish(BadEqualsObject obj);
15+
}
16+
17+
private final BadEqualsObject obj;
18+
private final Callback callback;
19+
20+
public BadEqualsTest(BadEqualsObject obj, Callback callback) {
21+
this.obj = obj;
22+
this.callback = callback;
23+
}
24+
25+
public void postCallback() {
26+
new Handler(Looper.getMainLooper()).post(new Runnable() {
27+
@Override
28+
public void run() {
29+
callback.onFinish(obj);
30+
}
31+
});
32+
}
33+
}

0 commit comments

Comments
 (0)