lime
lime copied to clipboard
JNI.createMemberField crashes when having nested class as className on Android 8
I came across the problem in the title. Crashes only happen on my Android 8 phone but not on my older devices and Nox.
Here is a sample project: https://drive.google.com/open?id=1z3TL9WQMM5YyZCOrbo-HVAsRJeu4VvjW
And the APK: https://drive.google.com/open?id=1qdt-CCbJqCENXWXdYusmWjnEiHvDHKkW
It gives this error on crash: JNI DETECTED ERROR IN APPLICATION: illegal class name 'test.Foo$Bar'
Is it expecting "test/Foo$Bar"?
Sources:
https://android.googlesource.com/platform/art/+/15fdb8c/src/check_jni.cc#146 https://stackoverflow.com/questions/9949674/jni-findclass-format-for-subclasses
You are right, changing to that stop the problem. So the real issue is I think the incorrect dotted syntax should throw some kind of error on the Haxe side? That syntax still work on older android versions, that can cause confusion and it's better that nobody else going down this path like me...
Edit: Also the dotted syntax still work on android 8 too as long it's not nested.
I think I may have planned (once or twice) to make the JNI code replace "." with "/" just to fix this, but then it would probably force this problem to occur elsewhere as it is incorrect syntax.
Perhaps documentation on the JNI class would help?
I think if the syntax is incorrect then it should just not work for the reason you mentioned. I only learned JNI while working with Lime so when it works for Lime I assumed it's the correct syntax for JNI in general. There might be others like me, it's better to not cause confusion for them I think.
On a second thought, I started using the dotted syntax from copying someone else's codes so there are probably other people using this syntax. It is also used heavily in projects at my job so... yea I may not want it to stop working yet.
So doing the replacement + adding document like you said sounds nice. But I think we should only keep it work temporarily along with a traced warning, then sometime in the future we throw it to where it belongs.
Anyway thank you for informing me. I wish I can contribute but don't have the skill yet. :D
@melonin : bạn cho mình hỏi, lỗi này, phiên bản Lime dev mới nhất đã được commit và fix chưa. Mình sử dụng Admob Ex cũng bị lỗi tương tự giống như bạn trên Android 8. Cám ơn rất nhiều!
@melonin : bạn cho mình hỏi, lỗi này, phiên bản Lime dev mới nhất đã được commit và fix chưa. Mình sử dụng Admob Ex cũng bị lỗi tương tự giống như bạn trên Android 8. Cám ơn rất nhiều!
Lỗi này mình nghĩ cần phải sửa ở bên extension. Lúc nó báo lỗi, bạn search tìm class name nó cho trong source của extension rồi thay cái .
thành /
thử. Ví dụ nó báo:
JNI DETECTED ERROR IN APPLICATION: illegal class name 'test.Foo$Bar'
Thì bạn search và sửa test.Foo$Bar
thành test/Foo$Bar
.
Mình sẽ thử. Cám ơn nhiều nhen. Nếu còn làm về haxe và openfl thì qua forum chơi :)