Opened 3 years ago

Closed 13 months ago

#4086 closed defect (fixed)

JsValue.isNumber() crashes

Reported by: asmirnov Assignee: asmirnov
Priority: P3 Milestone:
Module: Libadblockplus-Android Keywords:
Cc: rjeschke Blocked By: #4031
Blocking: Platform: Android
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://codereview.adblockplus.org/29345353/

Description

JsValue.isNumber() throws UnsatisfiedLinkError.

Assume we have the following test case:

@Test
    public void testUndefinedValue() {
        final JsValue value = jsEngine.evaluate("undefined");
        assertTrue(value.isUndefined());
        assertFalse(value.isNull());
        assertFalse(value.isString());
        assertFalse(value.isBoolean());
        assertFalse(value.isNumber());
        assertFalse(value.isObject());
        assertFalse(value.isArray());
        assertEquals("undefined", value.asString());
        try {
            value.asList();
            fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
        } catch (AdblockPlusException e) {
            // ignored
        }
        try {
            value.getProperty("foo");
            fail(AdblockPlusException.class.getSimpleName() + " is expected to be thrown");
        } catch (AdblockPlusException e) {
            // ignored
        }
    }

then we will have an exception:

05-30 06:49:31.610    1909-1923/org.adblockplus.libadblockplus.tests I/TestRunner﹕ failed: testUndefinedValue(org.adblockplus.libadblockplus.tests.JsTest)
05-30 06:49:31.610    1909-1923/org.adblockplus.libadblockplus.tests I/TestRunner﹕ ----- begin exception -----
05-30 06:49:31.610    1909-1923/org.adblockplus.libadblockplus.tests I/TestRunner﹕ java.lang.UnsatisfiedLinkError: Native method not found: org.adblockplus.libadblockplus.JsValue.isNumber:(J)Z
            at org.adblockplus.libadblockplus.JsValue.isNumber(Native Method)
            at org.adblockplus.libadblockplus.JsValue.isNumber(JsValue.java:62)
            at org.adblockplus.libadblockplus.tests.JsTest.testUndefinedValue(JsTest.java:37)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at junit.framework.TestCase.runTest(TestCase.java:168)
            at junit.framework.TestCase.runBare(TestCase.java:134)
            at junit.framework.TestResult$1.protect(TestResult.java:115)
            at junit.framework.TestResult.runProtected(TestResult.java:133)
            at junit.framework.TestResult.run(TestResult.java:118)
            at junit.framework.TestCase.run(TestCase.java:124)
            at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
            at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
            at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
            at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
05-30 06:49:31.610    1909-1923/org.adblockplus.libadblockplus.tests I/TestRunner﹕ ----- end exception -----
05-30 06:49:31.610    1909-1923/org.adblockplus.libadblockplus.tests I/TestRunner﹕ finished: testUndefinedValue(org.adblockplus.libadblockplus.tests.JsTest)
05-30 06:49:31.610    1899-1899/? D/AndroidRuntime﹕ Shutting down VM

it seems that the method is just not registered:
https://hg.adblockplus.org/adblockplusandroid/file/tip/jni/JniJsValue.cpp#l191

Change History (5)

comment:1 Changed 3 years ago by asmirnov

  • Platform changed from Unknown / Cross platform to Android

comment:2 Changed 3 years ago by asmirnov

  • Owner changed from Anton to asmirnov

comment:3 Changed 3 years ago by abpbot

A commit referencing this issue has landed:
Issue 4086 - JsValue.isNumber() crashes

comment:4 Changed 3 years ago by asmirnov

  • Review URL(s) modified (diff)

comment:5 Changed 13 months ago by asmirnov

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.