Skip to content

JNI Crash when calling JS method with char #64

@mhofman

Description

@mhofman

When overriding a method that has an Object type argument and calling it with a char argument, the runtime crashes from a JNI failure caused by NoSuchMethodError.
Calling the method with int, String or Object works ok.

Java

package org.nativescript.tester;

public class Crasher {
    public static class Logger  {
        public void print(Object value) {}
    }

    public static void crash(Logger logger) {
        assert logger != null;

        int i = 3; 
        char c = 'a';
        String s = "Hello";
        Object o = new Object();

        logger.print(i);
        logger.print(o);
        logger.print(s);
        logger.print(c);
    }
}

Javascript

javascript
function print(value) {
console.log('type=', typeof value, 'value=', value);
}

var Crasher = org.nativescript.tester.Crasher;
var CrasherLogger = Crasher.Logger.extend({
print: print
});

Crasher.crash(new CrasherLogger());


D/TNS.Native( 5589): MetadataNode::GetterCallback: prop 'Crasher' for node 'tester' called, nodeType=0, hash=701528294
D/TNS.Native( 5589): ExtendsCallMethodHandler: called with
D/TNS.Native( 5589): ExtendsCallMethodHandler: extend full name org/nativescript/tester/Crasher$Logger-f--main-view-model-l53-c40--
D/TNS.Native( 5589): RegisterInstance called for 'com/tns/gen/org/nativescript/tester/Crasher$Logger-f--main-view-model-l53-c40--'
D/TNS.Native( 5589): RegisterInstance: Linking new instance
D/TNS.Native( 5589): Linking js object: 265967389 and java instance id: 111
D/TNS.Native( 5589): CreateJavaInstance: com/tns/gen/org/nativescript/tester/Crasher$Logger-f--main-view-model-l53-c40--
D/TNS.Native( 5589): ObjectManager::GetJSInstanceInfo: called
D/TNS.Native( 5589): GetJSInstanceInfo: need to check prototype :99521698
D/TNS.Native( 5589): superValue.GetPrototype=47186496
D/TNS.Java( 5589): Looking for proxy file: /data/data/org.nativescript.helloworld/code_cache/secondary-dexes/org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40---1431064267381-1.dex Result: NOT Found. Proxy Gen needed. ClassName: com.tns.gen.org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40--
D/TNS.Java( 5589): generating proxy in place
D/TNS.Rungime.Proxy.Generator( 5589): generatingMethod print
D/Generator( 5589): Saving proxy with file name: org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40---1431064267381-1
D/TNS.Java( 5589): Finished inplace gen took: 4.369822ms
D/TNS.Java( 5589): TotalGenTime: 121.380661ms
I/dex2oat ( 5636): /system/bin/dex2oat --runtime-arg -classpath --runtime-arg --instruction-set=x86 --instruction-set-features=default --runtime-arg -Xrelocate --boot-image=/system/framework/boot.art --dex-file=/data/data/org.nativescript.helloworld/code_cache/secondary-dexes/org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40---1431064267381-1.dex --oat-fd=28 --oat-location=/data/data/org.nativescript.helloworld/code_cache/secondary-dexes/odex/org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40---1431064267381-1.dex --runtime-arg -Xms64m --runtime-arg -Xmx512m
I/dex2oat ( 5636): dex2oat took 13.141ms (threads: 1) arena alloc=31KB java alloc=12KB native alloc=468KB free=3MB
D/TNS.Java( 5589): Finished injecting into multidex: /data/data/org.nativescript.helloworld/code_cache/secondary-dexes/org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40---1431064267381-1.dex took: 37.937203ms
D/TNS.Java( 5589): TotalMultiDexTime: 373.053665ms
D/TNS.Java( 5589): Finished loading class : com.tns.gen.org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40-- took: 37.937203ms
D/TNS.Java( 5589): TotalLoadDexTime: 2.428795ms
D/TNS.Native( 5589): GetCachedConstructorId: encodedCtorArgs=com/tns/gen/org/nativescript/tester/Crasher$Logger-f--main-view-model-l53-c40--.I..0, ctorId=17
D/TNS.Java( 5589): MakeInstanceStrong (111, class com.tns.gen.org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40--)
D/TNS.Java( 5589): MakeInstanceStrong (111, class com.tns.gen.org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40--)
D/TNS.Java( 5589): Platform.getJavaObjectByID:111
D/TNS.Native( 5589): RegisterInstance: Updating linked instance with its real class
D/TNS.Native( 5589): SetClass called
D/TNS.Native( 5589): ObjectManager::GetJSInstanceInfo: called
D/TNS.Native( 5589): CallJavaMethod called org/nativescript/tester/Crasher.crash. static method
D/TNS.Native( 5589): ObjectManager::GetJSInstanceInfo: called
D/TNS.Java( 5589): Platform.CallJSMethod: calling js method print with javaObjectID 111 type=com.tns.gen.org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40--
D/TNS.Native( 5589): CallJSMethodNative called javaObjectID=111
D/TNS.Native( 5589): CallJSMethodNative called jsObject=265967389
D/TNS.Native( 5589): implementationObject->GetIdentityHash()=265967389
D/TNS.Native( 5589): CallJavaMethod called android/util/Log.v. static method
V/JS ( 5589): type= number value= 3
D/TNS.Java( 5589): Platform.CallJSMethod: calling js method print with javaObjectID 111 type=com.tns.gen.org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40--
D/TNS.Java( 5589): MakeInstanceStrong (112, class java.lang.Object)
D/TNS.Native( 5589): CallJSMethodNative called javaObjectID=111
D/TNS.Native( 5589): CallJSMethodNative called jsObject=265967389
D/TNS.Native( 5589): Linking js object: 954449237 and java instance id: 112
D/TNS.Native( 5589): implementationObject->GetIdentityHash()=265967389
D/TNS.Native( 5589): CallJavaMethod called java/lang/Object.toString. Instance id: 954449237, isSuper=0
D/TNS.Native( 5589): ObjectManager::GetJSInstanceInfo: called
D/TNS.Java( 5589): Platform.getJavaObjectByID:112
D/TNS.Native( 5589): CallJavaMethod called android/util/Log.v. static method
V/JS ( 5589): type= object value= java.lang.Object@122992a4
D/TNS.Java( 5589): Platform.CallJSMethod: calling js method print with javaObjectID 111 type=com.tns.gen.org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40--
D/TNS.Native( 5589): CallJSMethodNative called javaObjectID=111
D/TNS.Native( 5589): CallJSMethodNative called jsObject=265967389
D/TNS.Native( 5589): implementationObject->GetIdentityHash()=265967389
D/TNS.Native( 5589): CallJavaMethod called android/util/Log.v. static method
V/JS ( 5589): type= string value= Hello
D/TNS.Java( 5589): Platform.CallJSMethod: calling js method print with javaObjectID 111 type=com.tns.gen.org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40--
D/TNS.Native( 5589): CallJSMethodNative called javaObjectID=111
D/TNS.Native( 5589): CallJSMethodNative called jsObject=265967389
E/art ( 5589): invalid stream - problem with parameter iterator in /data/data/org.nativescript.helloworld/code_cache/secondary-dexes/org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40---1431064267381-1.dex for method void com.tns.gen.org.nativescript.tester.Crasher_Logger-f--main-view-model-l53-c40--.print(java.lang.Object)
E/art ( 5589): invalid stream - problem with parameter iterator in /data/data/org.nativescript.helloworld/code_cache/secondary-dexes/android.view.View_OnClickListener-fui-button-l27-c42---1431064267381-1.dex for method void com.tns.gen.android.view.View_OnClickListener-fui-button-l27-c42--.onClick(android.view.View)
F/art ( 5589): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI CallCharMethodV called with pending exception 'java.lang.NoSuchMethodError' thrown in java.lang.Object com.tns.Platform.callJSMethodNative(int, java.lang.String, boolean, java.lang.Object[]):-2
F/art ( 5589): art/runtime/check_jni.cc:65] in call to CallCharMethodV
F/art ( 5589): art/runtime/check_jni.cc:65] from java.lang.Object com.tns.Platform.callJSMethodNative(int, java.lang.String, boolean, java.lang.Object[])

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions