Skip to content

Commit f7a4144

Browse files
committed
fix failing tests after recent changes, introduce private API so that we can determine the bitness of the current process
1 parent 4f54cde commit f7a4144

File tree

8 files changed

+17
-12
lines changed

8 files changed

+17
-12
lines changed

runtime/src/main/java/com/tns/Runtime.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ public class Runtime
4141

4242
private native void passUncaughtExceptionToJsNative(int runtimeId, Throwable ex, String stackTrace);
4343

44-
private native void ClearStartupData(int runtimeId);
44+
private native void clearStartupData(int runtimeId);
45+
46+
// Used to determine the bitness of the current process (32 vs 64)
47+
public static native int getPointerSize();
4548

4649
void passUncaughtExceptionToJs(Throwable ex, String stackTrace)
4750
{
@@ -231,7 +234,7 @@ private void init(Logger logger, Debugger debugger, String appName, File runtime
231234
jsDebugger.start();
232235
}
233236

234-
ClearStartupData(getRuntimeId()); // It's safe to delete the data after the V8 debugger is initialized
237+
clearStartupData(getRuntimeId()); // It's safe to delete the data after the V8 debugger is initialized
235238

236239
if (logger.isEnabled())
237240
{

runtime/src/main/jni/com_tns_Runtime.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ extern "C" void Java_com_tns_Runtime_passUncaughtExceptionToJsNative(JNIEnv *env
301301
}
302302
}
303303

304-
extern "C" void Java_com_tns_Runtime_ClearStartupData(JNIEnv *env, jobject obj, jint runtimeId)
304+
extern "C" void Java_com_tns_Runtime_clearStartupData(JNIEnv *env, jobject obj, jint runtimeId)
305305
{
306306
auto runtime = TryGetRuntime(runtimeId);
307307
if (runtime == nullptr)
@@ -311,3 +311,8 @@ extern "C" void Java_com_tns_Runtime_ClearStartupData(JNIEnv *env, jobject obj,
311311

312312
runtime->ClearStartupData(env, obj);
313313
}
314+
315+
extern "C" jint Java_com_tns_Runtime_getPointerSize(JNIEnv *env, jobject obj)
316+
{
317+
return sizeof(void*);
318+
}

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ describe("Tests exception handling ", function () {
325325
});
326326

327327
it("should successfully catch syntax errors", function () {
328-
329328
var exceptionCaught = false;
330329
var errMsg;
331330
try {
@@ -336,8 +335,8 @@ describe("Tests exception handling ", function () {
336335
}
337336
expect(exceptionCaught).toBe(true);
338337
expect(errMsg).toContain("Cannot compile /data/data/com.tns.android_runtime_testapp/files/app/tests/syntaxErrors.js");
339-
expect(errMsg).toContain("SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode");
340-
expect(errMsg).toContain("File: \"/data/data/com.tns.android_runtime_testapp/files/app/tests/syntaxErrors.js, line: 4, column: 0");
338+
expect(errMsg).toContain("SyntaxError: Unexpected token =");
339+
expect(errMsg).toContain("File: \"/data/data/com.tns.android_runtime_testapp/files/app/tests/syntaxErrors.js, line: 3, column: 10");
341340

342341

343342

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
//this file is required
22

3-
var b = 5;
4-
let a = 5;
3+
var class = "JavaScript class"

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
describe("Tests native modules)", function () {
2-
2+
33
it("should load native module", function () {
44
var x = 12;
55
var y = 34;
66

77
var arch;
8-
var sysArch = java.lang.System.getProperty("os.arch");
8+
var sysArch = java.lang.System.getProperty("os.arch"); // ro.product.cpu.abi
99
var lcArch = sysArch.toLowerCase();
1010
if (lcArch.indexOf("arm") > -1) {
1111
arch = "arm";
1212
} else if (lcArch.indexOf("aarch64") > -1) {
13-
arch = "arm64";
13+
arch = (com.tns.Runtime.getPointerSize() == 4) ? "arm" : "arm64";
1414
} else if (lcArch.indexOf("i686") > -1) {
1515
arch = "x86";
1616
} else {
@@ -23,5 +23,4 @@ describe("Tests native modules)", function () {
2323

2424
expect(sum).toBe(46);
2525
});
26-
2726
});
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)