Skip to content

Commit aeafa4a

Browse files
committed
merged from release
2 parents 2ab7271 + 12a5682 commit aeafa4a

5 files changed

Lines changed: 47 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
5.2.1
2+
==
3+
4+
## Bug Fixes
5+
- [Breakpoint stop to hit when you have two open tabs and close one(#1247)](https://github.com/NativeScript/android-runtime/issues/1247)
6+
17
5.2.0
28
==
39

@@ -13,8 +19,6 @@
1319
- [ClassNotFound exception when calling nested static class with correct argument(#1195)](https://github.com/NativeScript/android-runtime/issues/1195)
1420
- [If you refresh or close the chrome dev tools window an error will be log in the console (#1202)](https://github.com/NativeScript/android-runtime/issues/1202)
1521
- [Debug on Android fails when stopped on breakpoint and change in .xml/.css/.html is applied(#1243)](https://github.com/NativeScript/android-runtime/issues/1243)
16-
- [Breakpoint stop to hit when you have two open tabs and close one(#1247)](https://github.com/NativeScript/android-runtime/issues/1247)
17-
- [ClassNotFound exception when calling nested static class with correct argument(#1195)](https://github.com/NativeScript/android-runtime/issues/1195)
1822
- [Upgrade V8 to v7 to fix unstable sort() method(#1176)](https://github.com/NativeScript/android-runtime/issues/1176)
1923
- [CodeCache option is broken since Android Runtime 4.1.0(#1235)](https://github.com/NativeScript/android-runtime/issues/1235)
2024
- [Snapshots with ABI splits do not work since Android Runtime 4.1.0(#1234)](https://github.com/NativeScript/android-runtime/issues/1234)

test-app/app/src/main/assets/app/tests/testReleaseNativeCounterpart.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ describe("Test native counterpart release", function () {
2525
expect(errorMessage).toBe("Failed calling toString on a java/lang/Object instance. The JavaScript instance no longer has available Java instance counterpart.");
2626
});
2727

28+
it("Calling the indexer operator on a released native array should throw an exception", function(){
29+
var errorMessage = "";
30+
31+
try{
32+
var arr = new java.lang.reflect.Array.newInstance(java.lang.Object.class, 10);
33+
global.__releaseNativeCounterpart(arr);
34+
arr[1];
35+
} catch(e){
36+
errorMessage = e.message;
37+
}
38+
39+
expect(errorMessage).toBe("Failed calling indexer operator on native array. The JavaScript instance no longer has available Java instance counterpart.");
40+
41+
});
42+
2843
it("Calling release on a non native object should throw exception", function () {
2944

3045
var errorMessage = "";

test-app/app/src/main/java/com/tns/AndroidJsV8Inspector.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,22 @@ protected Response serveHttp(IHTTPSession session) {
231231
return super.serveHttp(session);
232232
}
233233

234+
private JsV8InspectorWebSocket webSocket;
235+
234236
@Override
235237
protected WebSocket openWebSocket(IHTTPSession handshake) {
236-
return new JsV8InspectorWebSocket(handshake, currentRuntimeLogger);
238+
// close the previous webSocket
239+
if(this.webSocket != null) {
240+
try {
241+
this.webSocket.close(WebSocketFrame.CloseCode.NormalClosure, "New browser connection is open", false);
242+
} catch (IOException ioException) {
243+
if(this.webSocket.getState() != State.CLOSED) {
244+
Log.e("{N}.v8-inspector", "Error closing previous connection", ioException);
245+
}
246+
}
247+
}
248+
this.webSocket = new JsV8InspectorWebSocket(handshake, currentRuntimeLogger);
249+
return this.webSocket;
237250
}
238251
}
239252

test-app/runtime/src/main/cpp/ArrayElementAccessor.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Local<Value> ArrayElementAccessor::GetArrayElement(Isolate* isolate, const Local
1818

1919
auto arr = objectManager->GetJavaObjectByJsObject(array);
2020

21+
assertNonNullNativeArray(arr);
22+
2123
Local<Value> value;
2224
jsize startIndex = index;
2325
const jsize length = 1;
@@ -85,7 +87,9 @@ void ArrayElementAccessor::SetArrayElement(Isolate* isolate, const Local<Object>
8587
auto objectManager = runtime->GetObjectManager();
8688
auto context = isolate->GetCurrentContext();
8789

88-
auto arr = objectManager->GetJavaObjectByJsObject(array);
90+
tns::JniLocalRef arr = objectManager->GetJavaObjectByJsObject(array);
91+
92+
assertNonNullNativeArray(arr);
8993

9094
const string elementSignature = arraySignature.substr(1);
9195
jboolean isCopy = false;
@@ -198,3 +202,9 @@ Local<Value> ArrayElementAccessor::ConvertToJsValue(Isolate* isolate, ObjectMana
198202

199203
return jsValue;
200204
}
205+
206+
void ArrayElementAccessor::assertNonNullNativeArray(tns::JniLocalRef& arrayReference) {
207+
if(arrayReference.IsNull()){
208+
throw NativeScriptException("Failed calling indexer operator on native array. The JavaScript instance no longer has available Java instance counterpart.");
209+
}
210+
}

test-app/runtime/src/main/cpp/ArrayElementAccessor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ArrayElementAccessor {
1515

1616
private:
1717
v8::Local<v8::Value> ConvertToJsValue(v8::Isolate* isolate, ObjectManager* objectManager, JEnv& env, const std::string& elementSignature, const void* value);
18+
void assertNonNullNativeArray(tns::JniLocalRef& arrayReference);
1819
};
1920
}
2021

0 commit comments

Comments
 (0)