luajava icon indicating copy to clipboard operation
luajava copied to clipboard

luajava.new(...) produce error on Android ART

Open nirhal opened this issue 8 years ago • 6 comments

Calling luajava.new(...) produce the following error on Android ART: A/art: art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN APPLICATION: can't call static int org.keplerproject.luajava.LuaJavaAPI.javaNew(int, java.lang.Class) with class java.lang.Class<java.lang.Class> A/art: art/runtime/java_vm_ext.cc:410] in call to CallStaticIntMethod

After some code review, I figured out the problem. In luajava.c, line 1377: ret = ( *javaEnv )->CallStaticIntMethod( javaEnv , clazz , method , (jint)stateIndex , classInstance ); "clazz" is not the object we want here. It should be: ret = ( *javaEnv )->CallStaticIntMethod( javaEnv , luajava_api_class , method , (jint)stateIndex , classInstance );

Moreover, I think, line 1371: if ( clazz == NULL || method == NULL ) should be: if ( luajava_api_class == NULL || method == NULL )

Nir.

nirhal avatar Oct 12 '16 21:10 nirhal

Yes, I got this bug too.

wangdong avatar Apr 22 '17 12:04 wangdong

I've faced the same problem. Thanks for the solution, but this project looks like it's no longer being maintained

Lee-swifter avatar Oct 24 '17 11:10 Lee-swifter

Thanks, that worked for me as well.

vadi2 avatar Dec 20 '17 08:12 vadi2

Since this project is no longer being maintained, I have forked this project and fixed some bugs. See here: https://github.com/nirhal/JLua

nirhal avatar Jan 25 '18 11:01 nirhal

@nirhal , your fork has too much in one commit :( Do you think new users should go on patching this luajava code or jump right into your JLua? guys?

ildar avatar Jun 16 '20 11:06 ildar

BTW looks like @stevedonovan and @mkottman took care of this in AndroLua project. I adapted their works to luajava layout.

ildar avatar Jul 13 '20 20:07 ildar