Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch exception in jsb.reflection.callStaticMethod #2706

Merged

Conversation

PatriceJiang
Copy link
Contributor

@PatriceJiang PatriceJiang commented Aug 20, 2020

JNI CallStaticObjectMethod 可能抛出异常, 需要捕获

F/art     ( 2666): art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: java_string == null
F/art     ( 2666): art/runtime/check_jni.cc:65]     in call to GetStringChars
F/art     ( 2666): art/runtime/check_jni.cc:65]     from void org.cocos2dx.lib.Cocos2dxRenderer.nativeRender()
F/art     ( 2666): art/runtime/check_jni.cc:65] "GLThread 122" prio=5 tid=14 Runnable
F/art     ( 2666): art/runtime/check_jni.cc:65]   | group="main" sCount=0 dsCount=0 obj=0x12c23a30 self=0xb4434000
F/art     ( 2666): art/runtime/check_jni.cc:65]   | sysTid=2685 nice=0 cgrp=default sched=0/0 handle=0xb4454f00
F/art     ( 2666): art/runtime/check_jni.cc:65]   | state=R schedstat=( 3434188421 253084888 9006 ) utm=270 stm=72 core=2 HZ=100
F/art     ( 2666): art/runtime/check_jni.cc:65]   | stack=0xa3ac5000-0xa3ac7000 stackSize=1036KB
F/art     ( 2666): art/runtime/check_jni.cc:65]   | held mutexes= "mutator lock"(shared held)
F/art     ( 2666): art/runtime/check_jni.cc:65]   native: #00 pc 000063eb  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+91)
F/art     ( 2666): art/runtime/check_jni.cc:65]   native: #01 pc 00002f31  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+33)
F/art     ( 2666): art/runtime/check_jni.cc:65]   native: #02 pc 0042c44a  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+122)
F/art     ( 2666): art/runtime/check_jni.cc:65]   native: #03 pc 003e7fb7  /system/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+263)
F/art     ( 2666): art/runtime/check_jni.cc:65]   native: #04 pc 000f9724  /system/lib/libart.so (art::JniAbort(char const*, char const*)+1588)
F/art     ( 2666): art/runtime/check_jni.cc:65]   native: #05 pc 000fa272  /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+98)
F/art     ( 2666): art/runtime/check_jni.cc:65]   native: #06 pc 002fcf61  /system/lib/l

@PatriceJiang
Copy link
Contributor Author

PatriceJiang commented Aug 20, 2020

@minggo @wuzhiming 麻烦review

@minggo
Copy link
Contributor

minggo commented Aug 20, 2020

那一层的异常?JS,c++ 还是 Java?

@holycanvas holycanvas requested a review from wuzhiming Aug 20, 2020
@PatriceJiang
Copy link
Contributor Author

PatriceJiang commented Aug 21, 2020

Java 的异常. 没有 Clear, 会导致后续的崩溃.

if(m_env->ExceptionCheck()) {
m_env->ExceptionDescribe();
m_env->ExceptionClear();
m_retjstring = nullptr;
Copy link
Contributor

@minggo minggo Aug 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样捕获后,异常的消息有打印吗?

Copy link
Contributor Author

@PatriceJiang PatriceJiang Aug 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExceptionDescribe 会打印

minggo
minggo approved these changes Aug 21, 2020
@holycanvas holycanvas merged commit 014c039 into cocos:v2.4.3-release Aug 24, 2020
1 check passed
@PatriceJiang PatriceJiang deleted the v2.4.3-release-fix-jni-exception branch Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants