Closed paulocoutinhox closed 8 months ago
It would make sense for your case, sure. Which part are you having trouble with? First make sure you follow the setup for JNIOnLoad
(https://github.com/google/jni-bind/issues/188).
Glancing at your code, the class definition would probably translate as roughly:
static constexpr jni::Class kClass {
"com/xplpc/proxy/PlatformProxy",
jni::Static {
jni::Method { "onNativeProxyCallback", jni::Return<void>{}, jni::Params {jstring{}, jstring{} },
},
https://github.com/google/jni-bind#methods https://github.com/google/jni-bind#statics
I notice some array manipulation which probably looks like:
jni::LocalArray<jbyte> some_array { size };
auto* ptr_to_do_some_stuff_with some_array.Pin().ptr();
https://github.com/google/jni-bind#arrays
Is there a part specifically I could help with?
Hi,
First, thanks for your time.
Im really confused about what i need change and what i need keep.
PART 1:
The main class between C++ and JNI is this: https://github.com/xplpc/xplpc/blob/main/jni/lib/src/xplpc/proxy/JNIPlatformProxy.cpp
In this class i have:
thread_local JNIEnv
initializePlatform
i need store class loader
initializePlatform
i call kotlin/java method "com/xplpc/proxy/PlatformProxy::onInitializePlatform"
callProxy
, hasMapping
, but these methods i think that is simple like you post abovejniGetThreadEnv
and jniGetOptThreadEnv
. I still need this?jniFindClass
i still need this?PART 2:
I have a helper to convert string between platforms: https://github.com/xplpc/xplpc/blob/main/jni/lib/src/xplpc/jni/support.cpp
jniUTF8FromString
and jniStringFromUTF8
?PART 3:
I have a more part that create some objects: https://github.com/xplpc/xplpc/blob/main/jni/lib/src/xplpc/jni/platform.cpp
JNI_OnLoad
need call jni bind
setup method, correct?JNI_OnUnload
i need call jni bind
something?Java_com_xplpc_proxy_PlatformProxy_callNativeProxy
still need exists correct?Java_com_xplpc_proxy_PlatformProxy_callNativeProxy
will call jni bind methid like your example above, correct?Java_com_xplpc_helper_ByteBufferHelper_getPtrAddress
to something from jni bind?Java_com_xplpc_helper_ByteArrayHelper_getPtrAddress
to something from jni bind?Java_com_xplpc_helper_ByteArrayHelper_createFromPtr
to something from jni bind?I know that is too much things to answer, but glad if you can help me in these questions.
Thanks.
Part 1:
JNIBind
handles JNIEnv*
for you, you don't ever need to worry about it with JNI Bind code.jniGetThreadEnv
, but you do need ThreadGuard
any time you use a new thread: Threading.jniFindClass
is called on your behalf, you will never need to use it.Part 2:
Part 3:
JNIEnv
).Java_com_xplpc_proxy_PlatformProxy_callNativeProxy
yes, this is your C entrypoint, you must still define it. If you want, you can tidy it with a macro like this but it's just for show.Java_com_xplpc_helper_ByteBufferHelper_getPtrAddress
seems to be calling GetDirectBufferAddress
which truthfully I haven't used so I doubt there's a JNI Bind equivalent. It looks useful though, maybe it should.Hi,
Im near to finish the migration, but some errors happen when running the tests, but it is compiling the C++ library.
I need your help only to understand what im doing wrong with jni-bind and my new/old code.
Changes 1: JNIPlatformProxy.hpp
#pragma once
#include "xplpc/jni/jni_bind_release.h"
#include "xplpc/jni/support.hpp"
#include "xplpc/proxy/PlatformProxy.hpp"
#include <memory>
#include <string>
namespace xplpc
{
namespace proxy
{
class JNIPlatformProxy : public PlatformProxy
{
public:
static std::shared_ptr<JNIPlatformProxy> shared();
virtual void initialize() override;
virtual void initializePlatform() override;
virtual void finalize() override;
virtual void finalizePlatform() override;
virtual void callProxy(const std::string &key, const std::string &data) override;
virtual bool hasMapping(const std::string &name) override;
void onNativeProxyCallback(const jstring &key, const std::string &data);
void setPlatformJavaVM(JavaVM *pjvm);
private:
static std::shared_ptr<JNIPlatformProxy> instance;
static constexpr ::jni::Class kPlatformProxy{
"com/xplpc/proxy/PlatformProxy",
::jni::Static{
::jni::Method{"onInitializePlatform", ::jni::Return<void>{}, ::jni::Params{}},
::jni::Method{"onFinalizePlatform", ::jni::Return<void>{}, ::jni::Params{}},
::jni::Method{"onNativeProxyCall", ::jni::Return<void>{}, ::jni::Params<jstring, jstring>{}},
::jni::Method{"onHasMapping", ::jni::Return<jboolean>{}, ::jni::Params<jstring>{}},
::jni::Method{"onNativeProxyCallback", ::jni::Return<void>{}, ::jni::Params<jstring, jstring>{}},
},
};
std::unique_ptr<::jni::JvmRef<::jni::kDefaultJvm>> jvm;
JavaVM *platformJavaVM;
};
} // namespace proxy
} // namespace xplpc
Changes 2: JNIPlatformProxy.cpp
#include "xplpc/proxy/JNIPlatformProxy.hpp"
#include "spdlog/spdlog.h"
#include <cassert>
namespace xplpc
{
namespace proxy
{
std::shared_ptr<JNIPlatformProxy> JNIPlatformProxy::instance = nullptr;
std::shared_ptr<JNIPlatformProxy> JNIPlatformProxy::shared()
{
if (instance == nullptr)
{
instance = std::make_shared<JNIPlatformProxy>();
}
return instance;
}
void JNIPlatformProxy::initialize()
{
initializePlatform();
}
void JNIPlatformProxy::initializePlatform()
{
// reset jvm from platform jvm
jvm.reset(new ::jni::JvmRef<::jni::kDefaultJvm>(platformJavaVM));
// call initialize platform method
::jni::StaticRef<kPlatformProxy>{}("onInitializePlatform");
}
void JNIPlatformProxy::finalize()
{
finalizePlatform();
}
void JNIPlatformProxy::finalizePlatform()
{
::jni::StaticRef<kPlatformProxy>{}("onFinalizePlatform");
// reset
this->jvm = nullptr;
this->platformJavaVM = nullptr;
}
void JNIPlatformProxy::callProxy(const std::string &key, const std::string &data)
{
::jni::StaticRef<kPlatformProxy>{}("onNativeProxyCall", key, data);
}
bool JNIPlatformProxy::hasMapping(const std::string &name)
{
return ::jni::StaticRef<kPlatformProxy>{}("onHasMapping", name);
}
void JNIPlatformProxy::onNativeProxyCallback(const jstring &key, const std::string &data)
{
::jni::StaticRef<kPlatformProxy>{}("onNativeProxyCallback", key, data);
}
void JNIPlatformProxy::setPlatformJavaVM(JavaVM *pjvm)
{
this->platformJavaVM = pjvm;
}
} // namespace proxy
} // namespace xplpc
jvm
::jni::StaticRef<kPlatformProxy>
to call all @Jvmstatic
methods from kotlin classjvm
and platformJavaVM
Changes 3: Java_com_xplpc_proxy_PlatformProxy_callNativeProxy
#include "xplpc/client/Client.hpp"
#include "xplpc/data/CallbackList.hpp"
#include "xplpc/data/PlatformProxyList.hpp"
#include "xplpc/jni/support.hpp"
#include "xplpc/proxy/JNIPlatformProxy.hpp"
#include "xplpc/proxy/NativePlatformProxy.hpp"
#include <cstdint>
#include <memory>
using namespace xplpc::client;
using namespace xplpc::data;
using namespace xplpc::proxy;
using namespace xplpc::jni;
extern "C"
{
JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *jvm, void * /*reserved*/)
{
// initialize cxx platform proxy
auto nativePlatformProxy = std::make_shared<NativePlatformProxy>();
nativePlatformProxy->initialize();
PlatformProxyList::shared()->insert(0, nativePlatformProxy);
// initialize jni platform proxy
auto jniPlatformProxy = JNIPlatformProxy::shared();
jniPlatformProxy->setPlatformJavaVM(jvm);
jniPlatformProxy->initialize();
PlatformProxyList::shared()->insert(0, jniPlatformProxy);
return JNI_VERSION_1_6;
}
JNIEXPORT void JNICALL
JNI_OnUnload(JavaVM * /*jvm*/, void * /*reserved*/)
{
JNIPlatformProxy::shared()->finalize();
}
JNIEXPORT void JNICALL
Java_com_xplpc_proxy_PlatformProxy_callNativeProxy(JNIEnv *env, jclass /*clazz*/, jstring key, jstring data)
{
// clang-format off
Client::call(jniUTF8FromString(env, data), [key](const auto &response) {
auto proxy = JNIPlatformProxy::shared();
proxy->onNativeProxyCallback(key, response);
});
// clang-format on
}
JNIEXPORT void JNICALL
Java_com_xplpc_proxy_PlatformProxy_callNativeProxyCallback(JNIEnv *env, jclass /*clazz*/, jstring key, jstring data)
{
CallbackList::shared()->execute(jniUTF8FromString(env, key), jniUTF8FromString(env, data));
}
JNIEXPORT jlong JNICALL
Java_com_xplpc_helper_ByteBufferHelper_getPtrAddress(JNIEnv *env, jobject /*thiz*/, jobject data)
{
auto pointer = reinterpret_cast<uint8_t *>(env->GetDirectBufferAddress(data));
auto address = reinterpret_cast<std::uintptr_t>(pointer);
return static_cast<jlong>(address);
}
JNIEXPORT jlong JNICALL
Java_com_xplpc_helper_ByteArrayHelper_getPtrAddress(JNIEnv *env, jobject /*thiz*/, jbyteArray data)
{
auto pointer = (jbyte *)env->GetPrimitiveArrayCritical(data, nullptr);
auto address = reinterpret_cast<std::uintptr_t>(pointer);
env->ReleasePrimitiveArrayCritical(data, pointer, 0);
return static_cast<jlong>(address);
}
JNIEXPORT jbyteArray JNICALL
Java_com_xplpc_helper_ByteArrayHelper_createFromPtr(JNIEnv *env, jobject thiz, jlong ptr, jint size)
{
auto byteArray = env->NewByteArray(static_cast<jsize>(size));
auto dataPtr = reinterpret_cast<uint8_t *>(ptr);
env->SetByteArrayRegion(byteArray, 0, size, reinterpret_cast<const jbyte *>(dataPtr));
return byteArray;
}
}
Java_com_xplpc_proxy_PlatformProxy_callNativeProxy
to use a more jni-bind method, but i dont know if i do in the best wayjniUTF8FromString
and jniStringFromUTF8
ERROR:
09-04 16:40:32.696 13254 13254 F DEBUG : backtrace:
09-04 16:40:32.696 13254 13254 F DEBUG : #00 pc 0000000000356db4 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (_JNIEnv::GetStaticMethodID(_jclass*, char const*, char const*)+32) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
09-04 16:40:32.696 13254 13254 F DEBUG : #01 pc 0000000000355b80 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (jni::JniHelper::GetStaticMethodID(_jclass*, char const*, char const*)+40) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
09-04 16:40:32.696 13254 13254 F DEBUG : #02 pc 00000000003596d8 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'()::operator()() const+108) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
09-04 16:40:32.696 13254 13254 F DEBUG : #03 pc 00000000003595d4 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (_jmethodID* jni::metaprogramming::DoubleLockedValue<_jmethodID*>::LoadAndMaybeInit<jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'()>(jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'())+148) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
09-04 16:40:32.696 13254 13254 F DEBUG : #04 pc 00000000003594d0 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)+128) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
09-04 16:40:32.696 13254 13254 F DEBUG : #05 pc 0000000000359390 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (unsigned char jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::Invoke<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(_jclass*, _jobject*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+56) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
09-04 16:40:32.696 13254 13254 F DEBUG : #06 pc 0000000000359348 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (auto jni::StaticRef<xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm>::InvocableMapCall<3ul, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&) const+56) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
09-04 16:40:32.696 13254 13254 F DEBUG : #07 pc 0000000000355444 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (auto jni::metaprogramming::InvocableMapEntry<jni::StaticRef<xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm>, jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>::static_v, jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >, std::__ndk1::tuple<> >, &(jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >, std::__ndk1::tuple<> >::methods_), 3ul>::operator()<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(char const*, 3ul&&...) [enable_if:((std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >)(fp)) == (std::__ndk1::tuple_element<3ul, std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > > >::type const& std::__ndk1::get<3ul, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >(std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > > const&)(jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>::static_v.*&(jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Re
09-04 16:40:32.696 13254 13254 F DEBUG :
09-04 16:40:32.696 13254 13254 F DEBUG : #08 pc 00000000003553c8 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (xplpc::proxy::JNIPlatformProxy::hasMapping(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+52) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
09-04 16:40:32.696 13254 13254 F DEBUG : #09 pc 000000000034f128 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (auto xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&)::operator()<std::__ndk1::shared_ptr<xplpc::proxy::PlatformProxy> >(auto const&) const+52) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
09-04 16:40:32.696 13254 13254 F DEBUG : #10 pc 000000000034d3e4 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (auto std::__ndk1::find_if<std::__ndk1::__wrap_iter<std::__ndk1::shared_ptr<xplpc::proxy::PlatformProxy>*>, xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&)>(auto, auto, xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&))+76) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
09-04 16:40:32.696 13254 13254 F DEBUG : #11 pc 000000000034cc38 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)+392) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
09-04 16:40:32.696 13254 13254 F DEBUG : #12 pc 000000000034ca34 /data/app/~~sd7AUXPDQUqkhR25kc2lBQ==/com.xplpc.library.test-DSsXTi1Ruc8U1m3fqGM_cg==/lib/arm64/libxplpc.so (Java_com_xplpc_proxy_PlatformProxy_callNativeProxy+88) (BuildId: 66ba40cd1950731d9419bd89f9deeeffe1ee3483)
Part 1:
I really need std::unique_ptr<::jni::JvmRef<::jni::kDefaultJvm>> jvm;?
You need to have ::jni::JvmRef<::jni::kDefaultJvm>>
initialised from the OnLoad
call that outlives all other calls (it's fine if it leaks). You could also use a plain old function local static.
Bind code is correct?
Without manually inspecting every method, at a glance it does look correct.
Part 2:
finalizePlatform
only gets called once I hope, right? In your case, it sounds like it's crashing before that point anyways.
Otherwise looks fine.
Part 3:
Your code is crashing when looking up the static method signature. If you try with a non-static method does it work? I just did a quick test with a native => Kotlin static call and it works fine for me. When I double check your signatures, it looks OK.
Are you possibly calling this on a secondary thread? If so, just to make sure you have your signatures correct, can you write a super basic app that just calls a static method on the Java class and see if it works?
As for strings, I think you may need to use a character array or something similar for now, I'm afraid I don't have special support for string types that aren't supported in C++17 (when I add C++20 I will add it). For now supported types are here.
Hi,
Java VM - Initialize
In my JNIPlatformProxy
class i have a property:
std::unique_ptr<::jni::JvmRef<::jni::kDefaultJvm>> jvm
And when initializing on OnLoad
i do:
void JNIPlatformProxy::initializePlatform()
{
// set jvm from platform jvm
jvm.reset(new ::jni::JvmRef<::jni::kDefaultJvm>(platformJavaVM));
// call initialize platform method
::jni::StaticRef<kPlatformProxy>{}("onInitializePlatform");
}
Static Test
If i remove the static from bind the calls StaticRef don't compile. Example:
::jni::StaticRef<kPlatformProxy>{}("onInitializePlatform");
Changing from:
static constexpr ::jni::Class kPlatformProxy{
"com/xplpc/proxy/PlatformProxy",
::jni::Static{
::jni::Method{"onInitializePlatform", ::jni::Return<void>{}, ::jni::Params{}},
::jni::Method{"onFinalizePlatform", ::jni::Return<void>{}, ::jni::Params{}},
::jni::Method{"onNativeProxyCall", ::jni::Return<void>{}, ::jni::Params<jstring, jstring>{}},
::jni::Method{"onHasMapping", ::jni::Return<jboolean>{}, ::jni::Params<jstring>{}},
::jni::Method{"onNativeProxyCallback", ::jni::Return<void>{}, ::jni::Params<jstring, jstring>{}},
},
};
to:
static constexpr ::jni::Class kPlatformProxy{
"com/xplpc/proxy/PlatformProxy",
::jni::Method{"onInitializePlatform", ::jni::Return<void>{}, ::jni::Params{}},
::jni::Method{"onFinalizePlatform", ::jni::Return<void>{}, ::jni::Params{}},
::jni::Method{"onNativeProxyCall", ::jni::Return<void>{}, ::jni::Params<jstring, jstring>{}},
::jni::Method{"onHasMapping", ::jni::Return<jboolean>{}, ::jni::Params<jstring>{}},
::jni::Method{"onNativeProxyCallback", ::jni::Return<void>{}, ::jni::Params<jstring, jstring>{}},
};
It works normally in my project using static when i call it manually from my own code:
bool JNIPlatformProxy::hasMapping(const std::string &name)
{
auto env = jniGetThreadEnv();
jclass clazz = jniFindClass("com/xplpc/proxy/PlatformProxy");
jmethodID methodID = env->GetStaticMethodID(clazz, "onHasMapping", "(Ljava/lang/String;)Z");
return env->CallStaticBooleanMethod(clazz, methodID, xplpc::jni::jniStringFromUTF8(env, name));
}
Ref: https://github.com/xplpc/xplpc/blob/main/jni/lib/src/xplpc/proxy/JNIPlatformProxy.cpp#L75-L81
So, i don't think that the problem is kotlin or java.
Strings
So, from now i will still use mine functions to convert string and jstring until jni-bind have their functions.
The function invocation looks right to me. Because I have run it successfully on Kotlin and Java, and there is E2E testing for this (specifically a static that takes a String), I think your JNI Bind init/teardown is possibly wrong.
Are you able to make any successful calls? Could you try just replacing the StaticRef
call with the following:
printf("Test: %s\n", jni::LocalString{"Testing"}.Pin().ToString().data());
If that fails (I hope it does), it would confirm you somehow haven't setup your JvmRef
properly (this seems to be too complicated for folks, so I'm getting the sense making this easier might be good for 1.0).
Could you try getting rid of your JvmRef
variable completely and just adding the following to your onload to the following:
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* pjvm, void* reserved) {
static jni::JvmRef<jni::kDefaultJvm> jvm{pjvm};
return JNI_VERSION_1_6;
}
Hi,
My tests form your last message.
Initialize
I remove the private variable and use static like you sad:
void JNIPlatformProxy::initializePlatform()
{
// set jvm from platform jvm
static ::jni::JvmRef<::jni::kDefaultJvm> jvm{platformJavaVM};
// call initialize platform method
::jni::StaticRef<kPlatformProxy>{}("onInitializePlatform");
}
When run after this, the same error happen.
09-06 12:17:31.218 15301 15301 F DEBUG : Cause: null pointer dereference
09-06 12:17:31.218 15301 15301 F DEBUG : x0 0000000000000000 x1 0000000000002a02 x2 00000073990f9a3b x3 00000073991043e7
09-06 12:17:31.218 15301 15301 F DEBUG : x4 0000007399104500 x5 b400007430ea67a0 x6 0000000000000000 x7 0000000000000000
09-06 12:17:31.218 15301 15301 F DEBUG : x8 b400007430ea679f x9 fffffffffffffff8 x10 0000000000017000 x11 0000000000000002
09-06 12:17:31.218 15301 15301 F DEBUG : x12 0000000030ea67a7 x13 0000000000000000 x14 0000000000000006 x15 ffffffffffffffff
09-06 12:17:31.218 15301 15301 F DEBUG : x16 00000073993718b0 x17 000000739927b754 x18 00000073936f0000 x19 b400007580b5d5e0
09-06 12:17:31.218 15301 15301 F DEBUG : x20 0000000000000000 x21 b400007580b5d6a0 x22 00000073f4b5b5a4 x23 0000000000002071
09-06 12:17:31.218 15301 15301 F DEBUG : x24 000000740be00880 x25 00000073f3d37dd0 x26 00000073f3d37ddc x27 00000073f3d37dd0
09-06 12:17:31.218 15301 15301 F DEBUG : x28 00000073f3d37cd0 x29 00000073f3d37730
09-06 12:17:31.218 15301 15301 F DEBUG : lr 000000739927a544 sp 00000073f3d37710 pc 000000739927b774 pst 0000000060001000
09-06 12:17:31.218 15301 15301 F DEBUG : backtrace:
09-06 12:17:31.218 15301 15301 F DEBUG : #00 pc 0000000000356774 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (_JNIEnv::GetStaticMethodID(_jclass*, char const*, char const*)+32) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
09-06 12:17:31.218 15301 15301 F DEBUG : #01 pc 0000000000355540 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (jni::JniHelper::GetStaticMethodID(_jclass*, char const*, char const*)+40) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
09-06 12:17:31.218 15301 15301 F DEBUG : #02 pc 0000000000359098 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'()::operator()() const+108) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
09-06 12:17:31.218 15301 15301 F DEBUG : #03 pc 0000000000358f94 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (_jmethodID* jni::metaprogramming::DoubleLockedValue<_jmethodID*>::LoadAndMaybeInit<jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'()>(jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'())+148) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
09-06 12:17:31.218 15301 15301 F DEBUG : #04 pc 0000000000358e90 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)+128) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
09-06 12:17:31.218 15301 15301 F DEBUG : #05 pc 0000000000358d50 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (unsigned char jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::Invoke<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(_jclass*, _jobject*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+56) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
09-06 12:17:31.218 15301 15301 F DEBUG : #06 pc 0000000000358d08 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (auto jni::StaticRef<xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm>::InvocableMapCall<3ul, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&) const+56) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
09-06 12:17:31.218 15301 15301 F DEBUG : #07 pc 0000000000354e24 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (auto jni::metaprogramming::InvocableMapEntry<jni::StaticRef<xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm>, jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>::static_v, jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >, std::__ndk1::tuple<> >, &(jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >, std::__ndk1::tuple<> >::methods_), 3ul>::operator()<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(char const*, 3ul&&...) [enable_if:((std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >)(fp)) == (std::__ndk1::tuple_element<3ul, std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > > >::type const& std::__ndk1::get<3ul, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >(std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > > const&)(jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>::static_v.*&(jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Re
09-06 12:17:31.218 15301 15301 F DEBUG :
09-06 12:17:31.218 15301 15301 F DEBUG : #08 pc 0000000000354da8 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (xplpc::proxy::JNIPlatformProxy::hasMapping(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+52) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
09-06 12:17:31.218 15301 15301 F DEBUG : #09 pc 000000000034e968 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (auto xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&)::operator()<std::__ndk1::shared_ptr<xplpc::proxy::PlatformProxy> >(auto const&) const+52) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
09-06 12:17:31.218 15301 15301 F DEBUG : #10 pc 000000000034cc24 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (auto std::__ndk1::find_if<std::__ndk1::__wrap_iter<std::__ndk1::shared_ptr<xplpc::proxy::PlatformProxy>*>, xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&)>(auto, auto, xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&))+76) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
09-06 12:17:31.218 15301 15301 F DEBUG : #11 pc 000000000034c478 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)+392) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
09-06 12:17:31.218 15301 15301 F DEBUG : #12 pc 000000000034c274 /data/app/~~BoO5QaCeevPMNbkrtsuHSg==/com.xplpc.library.test-K6xiEH2FLrfBHoBL2MUzFw==/lib/arm64/libxplpc.so (Java_com_xplpc_proxy_PlatformProxy_callNativeProxy+88) (BuildId: fed70f30057d920fbbcc6e78b418bd12a2337688)
String test
When i call the string test you suggest i get this:
09-06 12:26:51.481 15525 15525 F DEBUG : Cause: null pointer dereference
09-06 12:26:51.481 15525 15525 F DEBUG : x0 0000000000000000 x1 00000073984c4e57 x2 0000000000000008 x3 0000000000000010
09-06 12:26:51.481 15525 15525 F DEBUG : x4 00000073984cff08 x5 b400007430ea6740 x6 0000000000000000 x7 0000000000000000
09-06 12:26:51.481 15525 15525 F DEBUG : x8 b400007430ea673f x9 fffffffffffffff8 x10 0000000000017000 x11 0000000000000002
09-06 12:26:51.481 15525 15525 F DEBUG : x12 0000000030ea6747 x13 000048060000485a x14 0000000000000006 x15 ffffffffffffffff
09-06 12:26:51.481 15525 15525 F DEBUG : x16 000000739873e198 x17 0000007398647d58 x18 0000007390caa000 x19 b400007580b5d5e0
09-06 12:26:51.481 15525 15525 F DEBUG : x20 0000000000000000 x21 0000000000000000 x22 00000073f4b885a4 x23 0000000000002071
09-06 12:26:51.481 15525 15525 F DEBUG : x24 000000740be00880 x25 00000073f3d32dd0 x26 00000073f3d32ddc x27 00000073f3d32dd0
09-06 12:26:51.481 15525 15525 F DEBUG : x28 00000073f3d32cd0 x29 00000073f3d326e0
09-06 12:26:51.481 15525 15525 F DEBUG : lr 0000007398647d4c sp 00000073f3d326d0 pc 0000007398647d70 pst 0000000060001000
09-06 12:26:51.481 15525 15525 F DEBUG : backtrace:
09-06 12:26:51.481 15525 15525 F DEBUG : #00 pc 0000000000357d70 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (_JNIEnv::NewStringUTF(char const*)+24) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #01 pc 0000000000357d48 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (jni::LifecycleHelper<_jstring*, (jni::LifecycleType)0>::Construct(char const*)+24) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #02 pc 00000000003564a8 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (_jstring* jni::Proxy<_jstring*, void>::ProxyAsArg<char const*, void>(char const*)+20) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #03 pc 00000000003562ac /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (jni::LocalObject<jni::Proxy<_jobject*, void>::Helper<jni::Id<jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)6, 18446744073709551615ul, 0ul, 18446744073709551615ul> >::kClass, jni::Proxy<_jobject*, void>::Helper<jni::Id<jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)6, 18446744073709551615ul, 0ul, 18446744073709551615ul> >::kClassLoader, jni::kDefaultJvm> jni::OverloadRef<jni::Id<jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)5, 18446744073709551615ul, 0ul, 18446744073709551615ul>, (jni::IdType)6>::Invoke<char const (&) [10]>(_jclass*, _jobject*, jni::Id<jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)6, 18446744073709551615ul, 0ul, 18446744073709551615ul>&&...)+100) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #04 pc 00000000003561c4 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (jni::ConstructorValidator<jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul> >::ConstructorValidator<char const (&) [10], 0>(char const (&) [10])+96) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #05 pc 0000000000356154 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (jni::ValidatorProxy<jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul> >::ValidatorProxy<char const (&) [10], 0>(char const (&) [10])+28) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #06 pc 0000000000356128 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (jni::Entry<(jni::LifecycleType)0, jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, jni::ScopedTerminalTag>::Entry<char const (&) [10], 0>(char const (&) [10])+28) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #07 pc 00000000003560fc /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (jni::EntryBase<jni::Entry<(jni::LifecycleType)0, jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, jni::ScopedTerminalTag>, (jni::LifecycleType)0, jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, _jstring*>::EntryBase<char const (&) [10], 0>(char const (&) [10])+28) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #08 pc 00000000003560d0 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (jni::Entry<(jni::LifecycleType)0, jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, _jstring*, jni::ScopedTerminalTag>::Entry<char const (&) [10], 0>(char const (&) [10])+28) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #09 pc 00000000003560a4 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (jni::EntryBase<jni::Entry<(jni::LifecycleType)0, jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, _jstring*, jni::ScopedTerminalTag>, (jni::LifecycleType)0, jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, _jobject*>::EntryBase<char const (&) [10], 0>(char const (&) [10])+28) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #10 pc 0000000000356078 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (jni::Entry<(jni::LifecycleType)0, jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, _jobject*, _jstring*, jni::ScopedTerminalTag>::Entry<char const (&) [10], 0>(char const (&) [10])+28) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #11 pc 000000000035604c /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (jni::Scoped<(jni::LifecycleType)0, jni::JniT<_jstring*, jni::kJavaLangString, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, _jobject*, _jstring*>::Scoped<char const (&) [10], 0>(char const (&) [10])+28) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #12 pc 0000000000355b40 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (jni::LocalString::LocalString<char const (&) [10], 0>(char const (&) [10])+28) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #13 pc 0000000000355e28 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (xplpc::proxy::JNIPlatformProxy::hasMapping(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+48) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #14 pc 000000000034f838 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (auto xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&)::operator()<std::__ndk1::shared_ptr<xplpc::proxy::PlatformProxy> >(auto const&) const+52) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #15 pc 000000000034daf4 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (auto std::__ndk1::find_if<std::__ndk1::__wrap_iter<std::__ndk1::shared_ptr<xplpc::proxy::PlatformProxy>*>, xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&)>(auto, auto, xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&))+76) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #16 pc 000000000034d348 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)+392) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #17 pc 000000000034d144 /data/app/~~9_DDmcNCmk6CysXaR4YoyA==/com.xplpc.library.test-k_dNH4z4aVAN2rTKhK_QoQ==/lib/arm64/libxplpc.so (Java_com_xplpc_proxy_PlatformProxy_callNativeProxy+88) (BuildId: 2fe99f9b44159d6f4b6ec30ba95a4d113b69a0d2)
09-06 12:26:51.481 15525 15525 F DEBUG : #18 pc 0000000000440554 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+148) (BuildId: e24a1818231cfb1649cb83a5d2869598)
Library initialization
My library is initialized inside a ContentProvider
to auto init when android app initialize:
https://github.com/xplpc/xplpc/blob/main/kotlin/android/lib/library/src/main/java/com/xplpc/platform/PlatformInitializer.kt
And the code is changed to this:
void JNIPlatformProxy::initializePlatform()
{
// set jvm from platform jvm
static ::jni::JvmRef<::jni::kDefaultJvm> jvm{platformJavaVM};
// call initialize platform method
printf("Test 1: %s\n", ::jni::LocalString{"Testing 1"}.Pin().ToString().data());
}
void JNIPlatformProxy::finalize()
{
finalizePlatform();
}
void JNIPlatformProxy::finalizePlatform()
{
::jni::StaticRef<kPlatformProxy>{}("onFinalizePlatform");
// reset
this->platformJavaVM = nullptr;
}
void JNIPlatformProxy::callProxy(const std::string &key, const std::string &data)
{
::jni::StaticRef<kPlatformProxy>{}("onNativeProxyCall", key, data);
}
bool JNIPlatformProxy::hasMapping(const std::string &name)
{
printf("Test 2: %s\n", ::jni::LocalString{"Testing 2"}.Pin().ToString().data());
return false;
}
This happens when JNIEnv*
hasn't been captured under the hood. I think I might know what's wrong.
This is maybe happening because the JvmRef
is not being setup correctly, or you are invoking this from another thread and not using ThreadGuard
, or, you are doing it correctly and exposing a bug.
With some digging, I've managed to repro a failure where calling a method on a class for the first time from another thread causes failure (I've filed https://github.com/google/jni-bind/issues/190).
Could you try the following, copy the OnLoad
call from above and get rid of your JvmRef
. If that doesn't work, create a fake call on the proxy class.
Sorry for the pain.
FYI I've created https://github.com/google/jni-bind/pull/191 to add unit testing coverage of static strings. Nothing was broken, but it helps further isolate the cause of the issue.
Hi,
I've created a project to test in a more isolated project: https://github.com/paulocoutinhox/jni-bind-test
It is working.
I will add a ContentProvider initializer/load method like i do in XPLPC to understand what is wrong.
Bah :(
I add content provider and it was initialized and work without problems.
I don't understand what is the difference :(
I add the same classes/structure that im using on xplpc project and it works on sample.
I don't know why it don't work on xplpc project, since i copy from there.
I think it's because your JniEnv
is not initialised because your JvmRef either isn't constructed yet or is destroyed. It's either that or the bug I mentioned in my code.
Sorry, I'm a bit slammed to try diving into a full sample right now, but, did you manage to grok my last response? I think it possibly gave some context that's helpful
Otherwise, just start from the simplest call you can make that fails and build up from there I think is your best bet (like it sounds like you are).
Hi,
Yes, i tried you code:
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* pjvm, void* reserved) {
static jni::JvmRef<jni::kDefaultJvm> jvm{pjvm};
return JNI_VERSION_1_6;
}
I migrate to your code, but the same error happen:
#include "xplpc/proxy/JNIPlatformProxy.hpp"
#include "spdlog/spdlog.h"
#include <cassert>
namespace xplpc
{
namespace proxy
{
std::shared_ptr<JNIPlatformProxy> JNIPlatformProxy::instance = nullptr;
std::shared_ptr<JNIPlatformProxy> JNIPlatformProxy::shared()
{
if (instance == nullptr)
{
instance = std::make_shared<JNIPlatformProxy>();
}
return instance;
}
void JNIPlatformProxy::initialize()
{
initializePlatform();
}
void JNIPlatformProxy::initializePlatform()
{
// set jvm from platform jvm
static ::jni::JvmRef<::jni::kDefaultJvm> jvm{platformJavaVM};
// call initialize platform method
::jni::StaticRef<kPlatformProxy>{}("onInitializePlatform");
}
void JNIPlatformProxy::finalize()
{
finalizePlatform();
}
void JNIPlatformProxy::finalizePlatform()
{
::jni::StaticRef<kPlatformProxy>{}("onFinalizePlatform");
// reset
this->platformJavaVM = nullptr;
}
void JNIPlatformProxy::callProxy(const std::string &key, const std::string &data)
{
::jni::StaticRef<kPlatformProxy>{}("onNativeProxyCall", key, data);
}
bool JNIPlatformProxy::hasMapping(const std::string &name)
{
return ::jni::StaticRef<kPlatformProxy>{}("onHasMapping", name);
}
void JNIPlatformProxy::onNativeProxyCallback(const jstring &key, const std::string &data)
{
::jni::StaticRef<kPlatformProxy>{}("onNativeProxyCallback", key, data);
}
void JNIPlatformProxy::setPlatformJavaVM(JavaVM *pjvm)
{
this->platformJavaVM = pjvm;
}
} // namespace proxy
} // namespace xplpc
Error:
09-11 15:17:09.261 14833 14833 F DEBUG : Cause: null pointer dereference
09-11 15:17:09.261 14833 14833 F DEBUG : x0 0000000000000000 x1 0000000000002e6a x2 00000072abc41a3b x3 00000072abc4c3e7
09-11 15:17:09.261 14833 14833 F DEBUG : x4 00000072abc4c500 x5 b400007345a87150 x6 0000000000000000 x7 0000000000000000
09-11 15:17:09.261 14833 14833 F DEBUG : x8 b400007345a8714f x9 fffffffffffffff8 x10 0000000000017000 x11 0000000000000002
09-11 15:17:09.261 14833 14833 F DEBUG : x12 0000000045a87157 x13 0000000000000000 x14 0000000000000000 x15 0000000000000000
09-11 15:17:09.261 14833 14833 F DEBUG : x16 00000072abeb98b0 x17 00000072abdc3754 x18 00000072a5c14000 x19 b4000074957021b0
09-11 15:17:09.261 14833 14833 F DEBUG : x20 0000000000000000 x21 0000000000000000 x22 00000072afb775a4 x23 0000000000002071
09-11 15:17:09.261 14833 14833 F DEBUG : x24 0000007321000880 x25 00000072a6b16db0 x26 00000072a6b16dbc x27 00000072a6b16db0
09-11 15:17:09.261 14833 14833 F DEBUG : x28 00000072a6b16cb0 x29 00000072a6b16710
09-11 15:17:09.261 14833 14833 F DEBUG : lr 00000072abdc2544 sp 00000072a6b166f0 pc 00000072abdc3774 pst 0000000060001000
09-11 15:17:09.261 14833 14833 F DEBUG : backtrace:
09-11 15:17:09.261 14833 14833 F DEBUG : #00 pc 0000000000356774 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (_JNIEnv::GetStaticMethodID(_jclass*, char const*, char const*)+32) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
09-11 15:17:09.261 14833 14833 F DEBUG : #01 pc 0000000000355540 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (jni::JniHelper::GetStaticMethodID(_jclass*, char const*, char const*)+40) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
09-11 15:17:09.261 14833 14833 F DEBUG : #02 pc 0000000000359098 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'()::operator()() const+108) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
09-11 15:17:09.261 14833 14833 F DEBUG : #03 pc 0000000000358f94 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (_jmethodID* jni::metaprogramming::DoubleLockedValue<_jmethodID*>::LoadAndMaybeInit<jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'()>(jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'())+148) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
09-11 15:17:09.261 14833 14833 F DEBUG : #04 pc 0000000000358e90 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)+128) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
09-11 15:17:09.261 14833 14833 F DEBUG : #05 pc 0000000000358d50 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (unsigned char jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::Invoke<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(_jclass*, _jobject*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+56) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
09-11 15:17:09.261 14833 14833 F DEBUG : #06 pc 0000000000358d08 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (auto jni::StaticRef<xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm>::InvocableMapCall<3ul, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&) const+56) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
09-11 15:17:09.261 14833 14833 F DEBUG : #07 pc 0000000000354e24 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (auto jni::metaprogramming::InvocableMapEntry<jni::StaticRef<xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm>, jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>::static_v, jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >, std::__ndk1::tuple<> >, &(jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >, std::__ndk1::tuple<> >::methods_), 3ul>::operator()<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(char const*, 3ul&&...) [enable_if:((std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >)(fp)) == (std::__ndk1::tuple_element<3ul, std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > > >::type const& std::__ndk1::get<3ul, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >(std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > > const&)(jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>::static_v.*&(jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Re
09-11 15:17:09.261 14833 14833 F DEBUG :
09-11 15:17:09.261 14833 14833 F DEBUG : #08 pc 0000000000354da8 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (xplpc::proxy::JNIPlatformProxy::hasMapping(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+52) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
09-11 15:17:09.261 14833 14833 F DEBUG : #09 pc 000000000034e968 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (auto xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&)::operator()<std::__ndk1::shared_ptr<xplpc::proxy::PlatformProxy> >(auto const&) const+52) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
09-11 15:17:09.261 14833 14833 F DEBUG : #10 pc 000000000034cc24 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (auto std::__ndk1::find_if<std::__ndk1::__wrap_iter<std::__ndk1::shared_ptr<xplpc::proxy::PlatformProxy>*>, xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&)>(auto, auto, xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&))+76) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
09-11 15:17:09.261 14833 14833 F DEBUG : #11 pc 000000000034c478 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)+392) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
09-11 15:17:09.261 14833 14833 F DEBUG : #12 pc 000000000034c274 /data/app/~~wCBehQspoKabaoHmbg5sWQ==/com.xplpc.library.test-uTgQu08Unz_yXYW9N2QkDg==/lib/arm64/libxplpc.so (Java_com_xplpc_proxy_PlatformProxy_callNativeProxy+88) (BuildId: 937e757925631fb69baefbb1dcd05f6210bafb12)
Hi,
One thing that i discover now is that it is working on XPLPC sample project, but not on tests.
Have any different between run a sample android project or run the tests when use this library?
2023-09-11 16:24:11.410 15998-15998 XPLPC com.xplpc.runner D [XPLPC : initialize]
2023-09-11 16:24:11.411 15998-15998 XPLPC com.xplpc.runner D [NativeLib : initialize] Loading XPLPC native library...
2023-09-11 16:24:11.442 15998-15998 XPLPC com.xplpc.runner D [2023-09-11 16:24:11.441] [android] [debug] [JNIPlatformProxy : initializePlatform] 1
2023-09-11 16:24:11.442 15998-15998 XPLPC com.xplpc.runner D [2023-09-11 16:24:11.442] [android] [debug] [JNIPlatformProxy : initializePlatform] 2
2023-09-11 16:24:11.443 15998-15998 XPLPC com.xplpc.runner D [2023-09-11 16:24:11.443] [android] [debug] [JNIPlatformProxy : initializePlatform] 3
2023-09-11 16:24:11.452 15998-15998 XPLPC com.xplpc.runner E XPLPC::onInitializePlatform - OK
2023-09-11 16:24:11.452 15998-15998 XPLPC com.xplpc.runner D [2023-09-11 16:24:11.452] [android] [debug] [JNIPlatformProxy : initializePlatform] 4
2023-09-11 16:24:11.452 15998-15998 XPLPC com.xplpc.runner D [NativeLib : initialize] XPLPC native library loaded
2023-09-11 16:24:11.457 15998-15998 XPLPC com.xplpc.runner D [Application : onCreate]
2023-09-11 16:24:11.458 15998-15998 XPLPC com.xplpc.runner D [Application : initializeStrictMode] Initializing strict mode...
2023-09-11 16:24:11.466 15998-15998 XPLPC com.xplpc.runner D [Application : initializeXPLPC]
On sample application
run is load the library in the correct sequence, see (1 to 7) and when i press a button to call native method it show number 8 without problems:
2023-09-11 16:59:14.961 4430-4430 ForceDarkHelperStubImpl com.xplpc.runner I initialize for com.xplpc.runner , ForceDarkOrigin
2023-09-11 16:59:14.963 4430-4430 om.xplpc.runner com.xplpc.runner D JNI_OnLoad success
2023-09-11 16:59:14.964 4430-4430 MiuiForceDarkConfig com.xplpc.runner I setConfig density:2.750000, mainRule:0, secondaryRule:0, tertiaryRule:0
2023-09-11 16:59:14.969 4430-4430 NetworkSecurityConfig com.xplpc.runner D No Network Security Config specified, using platform default
2023-09-11 16:59:14.970 4430-4430 NetworkSecurityConfig com.xplpc.runner D No Network Security Config specified, using platform default
2023-09-11 16:59:14.974 4430-4430 MultiDex com.xplpc.runner I VM with version 2.1.0 has multidex support
2023-09-11 16:59:14.974 4430-4430 MultiDex com.xplpc.runner I Installing application
2023-09-11 16:59:14.974 4430-4430 MultiDex com.xplpc.runner I VM has multidex support, MultiDex support library is disabled.
2023-09-11 16:59:14.975 4430-4430 Compatibil...geReporter com.xplpc.runner D Compat change id reported: 183155436; UID 10506; state: ENABLED
2023-09-11 16:59:15.001 4430-4430 XPLPC com.xplpc.runner D [XPLPC : initialize]
2023-09-11 16:59:15.001 4430-4430 XPLPC com.xplpc.runner D [NativeLib : initialize] Loading XPLPC native library...
2023-09-11 16:59:15.007 4430-4430 XPLPC com.xplpc.runner D [2023-09-11 16:59:15.006] [android] [debug] [JNIPlatformProxy : setPlatformJavaVM] 1
2023-09-11 16:59:15.007 4430-4430 XPLPC com.xplpc.runner D [2023-09-11 16:59:15.007] [android] [debug] [JNIPlatformProxy : initializePlatform] 2
2023-09-11 16:59:15.008 4430-4430 XPLPC com.xplpc.runner D [2023-09-11 16:59:15.008] [android] [debug] [JNIPlatformProxy : initializePlatform] 3
2023-09-11 16:59:15.009 4430-4430 XPLPC com.xplpc.runner E XPLPC::onInitializePlatform - OK
2023-09-11 16:59:15.009 4430-4430 XPLPC com.xplpc.runner D [2023-09-11 16:59:15.009] [android] [debug] [JNIPlatformProxy : initializePlatform] 4
2023-09-11 16:59:15.009 4430-4430 XPLPC com.xplpc.runner D [NativeLib : initialize] XPLPC native library loaded
2023-09-11 16:59:15.011 4430-4430 XPLPC com.xplpc.runner D [Application : onCreate]
2023-09-11 16:59:15.011 4430-4430 XPLPC com.xplpc.runner D [Application : initializeStrictMode] Initializing strict mode...
2023-09-11 16:59:15.011 4430-4430 XPLPC com.xplpc.runner D [Application : initializeXPLPC]
Button press:
2023-09-11 17:00:17.746 4430-4430 XPLPC com.xplpc.runner D [2023-09-11 17:00:17.746] [android] [debug] [JNIPlatformProxy : hasMapping] 8
2023-09-11 17:00:17.747 4430-4430 XPLPC com.xplpc.runner D [2023-09-11 17:00:17.747] [android] [debug] [callbackLogin] Not logged
2023-09-11 17:00:17.747 4430-4430 XPLPC com.xplpc.runner D [2023-09-11 17:00:17.747] [android] [debug] [JNIPlatformProxy : onNativeProxyCallback] 7
On tests it load the library in the correct sequence, see (1 to 7) but when run the test it will call the number 8 and crash:
2023-09-11 16:55:57.526 4021-4021 ForceDarkHelperStubImpl com.xplpc.library.test I initialize for com.xplpc.library.test , ForceDarkOrigin
2023-09-11 16:55:57.528 4021-4021 pc.library.test com.xplpc.library.test D JNI_OnLoad success
2023-09-11 16:55:57.528 4021-4021 MiuiForceDarkConfig com.xplpc.library.test I setConfig density:2.750000, mainRule:0, secondaryRule:0, tertiaryRule:0
2023-09-11 16:55:57.532 4021-4021 NetworkSecurityConfig com.xplpc.library.test D No Network Security Config specified, using platform default
2023-09-11 16:55:57.533 4021-4021 NetworkSecurityConfig com.xplpc.library.test D No Network Security Config specified, using platform default
2023-09-11 16:55:57.533 4021-4021 MonitoringInstr com.xplpc.library.test I newApplication called!
2023-09-11 16:55:57.534 4021-4021 Compatibil...geReporter com.xplpc.library.test D Compat change id reported: 183155436; UID 10525; state: ENABLED
2023-09-11 16:55:57.540 4021-4021 XPLPC com.xplpc.library.test D [XPLPC : initialize]
2023-09-11 16:55:57.540 4021-4021 XPLPC com.xplpc.library.test D [NativeLib : initialize] Loading XPLPC native library...
2023-09-11 16:55:57.546 4021-4021 XPLPC com.xplpc.library.test D [2023-09-11 16:55:57.546] [android] [debug] [JNIPlatformProxy : setPlatformJavaVM] 1
2023-09-11 16:55:57.546 4021-4021 XPLPC com.xplpc.library.test D [2023-09-11 16:55:57.546] [android] [debug] [JNIPlatformProxy : initializePlatform] 2
2023-09-11 16:55:57.547 4021-4021 XPLPC com.xplpc.library.test D [2023-09-11 16:55:57.547] [android] [debug] [JNIPlatformProxy : initializePlatform] 3
2023-09-11 16:55:57.547 4021-4021 XPLPC com.xplpc.library.test E XPLPC::onInitializePlatform - OK
2023-09-11 16:55:57.548 4021-4021 XPLPC com.xplpc.library.test D [2023-09-11 16:55:57.547] [android] [debug] [JNIPlatformProxy : initializePlatform] 4
2023-09-11 16:55:57.548 4021-4021 XPLPC com.xplpc.library.test D [NativeLib : initialize] XPLPC native library loaded
2023-09-11 16:55:57.550 4021-4021 MonitoringInstr com.xplpc.library.test I Instrumentation started!
2023-09-11 16:55:57.563 4021-4021 AndroidJUnitRunner com.xplpc.library.test I onCreate Bundle[{testTimeoutSeconds=31536000, class=com.xplpc.library.ClientTest#batteryLevel, debug=true, additionalTestOutputDir=/sdcard/Android/media/com.xplpc.library.test/additional_test_output}]
2023-09-11 16:55:57.563 4021-4021 AndroidJUnitRunner com.xplpc.library.test I Waiting for debugger to connect...
2023-09-11 16:55:57.563 4021-4021 System.out com.xplpc.library.test I Sending WAIT chunk
2023-09-11 16:55:57.763 4021-4021 System.out com.xplpc.library.test I Debugger has connected
2023-09-11 16:55:57.763 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:55:57.964 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:55:58.164 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:55:58.365 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:55:58.565 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:55:58.766 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:55:58.966 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:55:59.167 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:55:59.368 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:55:59.569 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:55:59.769 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:55:59.970 4021-4021 System.out com.xplpc.library.test I waiting for debugger to settle...
2023-09-11 16:56:00.170 4021-4021 System.out com.xplpc.library.test I debugger has settled (1393)
2023-09-11 16:56:00.171 4021-4021 AndroidJUnitRunner com.xplpc.library.test I Debugger connected.
2023-09-11 16:56:00.181 4021-4021 TestEventClient com.xplpc.library.test V No service name argument was given (testDiscoveryService, testRunEventService or orchestratorService)
2023-09-11 16:56:00.221 4021-4049 AndroidJUnitRunner com.xplpc.library.test D onStart is called.
2023-09-11 16:56:00.232 4021-4021 FileUtils com.xplpc.library.test E err open mi_exception_log errno=2
2023-09-11 16:56:00.233 4021-4021 FileUtils com.xplpc.library.test E err write to mi_exception_log
2023-09-11 16:56:00.239 4021-4021 MonitoringInstr com.xplpc.library.test I No JSBridge.
2023-09-11 16:56:00.299 4021-4049 TestRequestBuilder com.xplpc.library.test D Skipping class path scanning and directly running [com.xplpc.library.ClientTest]
2023-09-11 16:56:00.363 4021-4049 AndroidJUnitRunner com.xplpc.library.test D Use the raw file system for managing file I/O.
2023-09-11 16:56:00.389 4021-4049 TestExecutor com.xplpc.library.test D Adding listener androidx.test.internal.runner.listener.LogRunListener
2023-09-11 16:56:00.390 4021-4049 TestExecutor com.xplpc.library.test D Adding listener androidx.test.internal.runner.listener.InstrumentationResultPrinter
2023-09-11 16:56:00.390 4021-4049 TestExecutor com.xplpc.library.test D Adding listener androidx.test.internal.runner.listener.ActivityFinisherRunListener
2023-09-11 16:56:00.390 4021-4049 TestExecutor com.xplpc.library.test D Adding listener androidx.test.internal.runner.listener.TraceRunListener
2023-09-11 16:56:00.400 4021-4049 TestRunner com.xplpc.library.test I run started: 1 tests
2023-09-11 16:56:00.404 4021-4049 TestRunner com.xplpc.library.test I started: batteryLevel(com.xplpc.library.ClientTest)
2023-09-11 16:56:00.484 4021-4049 XPLPC com.xplpc.library.test D [2023-09-11 16:56:00.484] [android] [debug] [JNIPlatformProxy : hasMapping] 8
2023-09-11 16:56:00.484 4021-4049 libc com.xplpc.library.test A Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 4049 (roidJUnitRunner), pid 4021 (pc.library.test)
2023-09-11 16:56:01.389 4067-4067 DEBUG crash_dump64 A Cmdline: com.xplpc.library.test
2023-09-11 16:56:01.389 4067-4067 DEBUG crash_dump64 A pid: 4021, tid: 4049, name: roidJUnitRunner >>> com.xplpc.library.test <<<
2023-09-11 16:56:01.389 4067-4067 DEBUG crash_dump64 A #00 pc 0000000000357270 /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (_JNIEnv::GetStaticMethodID(_jclass*, char const*, char const*)+32) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.389 4067-4067 DEBUG crash_dump64 A #01 pc 000000000035603c /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (jni::JniHelper::GetStaticMethodID(_jclass*, char const*, char const*)+40) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.389 4067-4067 DEBUG crash_dump64 A #02 pc 0000000000359b94 /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'()::operator()() const+108) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.389 4067-4067 DEBUG crash_dump64 A #03 pc 0000000000359a90 /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (_jmethodID* jni::metaprogramming::DoubleLockedValue<_jmethodID*>::LoadAndMaybeInit<jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'()>(jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)::'lambda'())+148) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #04 pc 000000000035998c /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::GetMethodID(_jclass*)+128) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #05 pc 000000000035984c /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (unsigned char jni::OverloadRef<jni::Id<jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>, (jni::IdType)2, 3ul, 0ul, 18446744073709551615ul>, (jni::IdType)3>::Invoke<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(_jclass*, _jobject*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+56) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #06 pc 0000000000359804 /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (auto jni::StaticRef<xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm>::InvocableMapCall<3ul, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(char const*, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&) const+56) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #07 pc 00000000003558a4 /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (auto jni::metaprogramming::InvocableMapEntry<jni::StaticRef<xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm>, jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>::static_v, jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >, std::__ndk1::tuple<> >, &(jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >, std::__ndk1::tuple<> >::methods_), 3ul>::operator()<std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&>(char const*, 3ul&&...) [enable_if:((std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >)(fp)) == (std::__ndk1::tuple_element<3ul, std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > > >::type const& std::__ndk1::get<3ul, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > >(std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<unsigned char> >, std::__ndk1::tuple<jni::Params<_jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > > > const&)(jni::JniT<_jobject*, xplpc::proxy::JNIPlatformProxy::kPlatformProxy, jni::kDefaultClassLoader, jni::kDefaultJvm, 0ul, 18446744073709551615ul, 18446744073709551615ul>::static_v.*&(jni::Static<std::__ndk1::tuple<jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<> > >, jni::Method<std::__ndk1::tuple<jni::Return<void> >, std::__ndk1::tuple<jni::Params<_jstring*, _jstring*> > >, jni::Method<std::__ndk1::tuple<jni::Re
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #08 pc 0000000000355800 /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (xplpc::proxy::JNIPlatformProxy::hasMapping(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)+64) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #09 pc 000000000034f328 /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (auto xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&)::operator()<std::__ndk1::shared_ptr<xplpc::proxy::PlatformProxy> >(auto const&) const+52) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #10 pc 000000000034d5e4 /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (auto std::__ndk1::find_if<std::__ndk1::__wrap_iter<std::__ndk1::shared_ptr<xplpc::proxy::PlatformProxy>*>, xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&)>(auto, auto, xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)::'lambda'(auto const&))+76) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #11 pc 000000000034ce38 /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (xplpc::client::Client::call(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::function<void (std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)>)+392) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #12 pc 000000000034cc34 /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/lib/arm64/libxplpc.so (Java_com_xplpc_proxy_PlatformProxy_callNativeProxy+88) (BuildId: f56b89a490c20df89e635c837fe74a59ea9e3034)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #15 pc 00000000001abf64 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (com.xplpc.proxy.PlatformProxy$Companion.callNativeProxy+0)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #17 pc 00000000001a9db6 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (com.xplpc.library.ClientTest.batteryLevel+146)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #23 pc 00000000002c24e4 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.model.FrameworkMethod$1.runReflectiveCall+20)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #25 pc 00000000002ba504 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.internal.runners.model.ReflectiveCallable.run+0)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #27 pc 00000000002c273e [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.model.FrameworkMethod.invokeExplosively+10)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #29 pc 00000000002bb50a [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.internal.runners.statements.InvokeMethod.evaluate+14)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #31 pc 00000000002c1104 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner$3.evaluate+4)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #33 pc 00000000002bfefc [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.BlockJUnit4ClassRunner$1.evaluate+16)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #35 pc 00000000002c1b4c [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner.runLeaf+16)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #37 pc 00000000002c061e [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.BlockJUnit4ClassRunner.runChild+38)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #39 pc 00000000002c05de [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.BlockJUnit4ClassRunner.runChild+6)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #41 pc 00000000002c116c [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner$4.run+12)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #43 pc 00000000002c1088 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner$1.schedule+0)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #45 pc 00000000002c1b02 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner.runChildren+50)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #47 pc 00000000002c17a0 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner.access$100+0)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #49 pc 00000000002c10c8 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner$2.evaluate+8)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #51 pc 00000000002c1104 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner$3.evaluate+4)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #53 pc 00000000002c1a70 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner.run+32)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #55 pc 000000000017360c [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (androidx.test.ext.junit.runners.AndroidJUnit4.run+4)
2023-09-11 16:56:01.390 4067-4067 DEBUG crash_dump64 A #57 pc 00000000002c222c [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.Suite.runChild+0)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #59 pc 00000000002c2212 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.Suite.runChild+6)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #61 pc 00000000002c116c [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner$4.run+12)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #63 pc 00000000002c1088 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner$1.schedule+0)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #65 pc 00000000002c1b02 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner.runChildren+50)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #67 pc 00000000002c17a0 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner.access$100+0)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #69 pc 00000000002c10c8 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner$2.evaluate+8)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #71 pc 00000000002c1104 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner$3.evaluate+4)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #73 pc 00000000002c1a70 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runners.ParentRunner.run+32)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #75 pc 00000000002be0f2 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runner.JUnitCore.run+50)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #77 pc 00000000002be0a4 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (org.junit.runner.JUnitCore.run+8)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #79 pc 000000000017997c [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (androidx.test.internal.runner.TestExecutor.execute+16)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #81 pc 0000000000179a28 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (androidx.test.internal.runner.TestExecutor.execute+20)
2023-09-11 16:56:01.391 4067-4067 DEBUG crash_dump64 A #83 pc 0000000000184626 [anon:dalvik-classes.dex extracted in memory from /data/app/~~Kp0YwmVfZdv7cRfEwK-rfw==/com.xplpc.library.test-AvRzofzX9WkVj0FFtD8sRA==/base.apk] (androidx.test.runner.AndroidJUnitRunner.onStart+274)
2023-09-11 16:56:01.451 1780-4081 PowerHalWrapper system_server I <NotifyAppCrash> pack:com.xplpc.library.test ,pid:com.xplpc.library.test == myPid:1780
The source is:
#include "xplpc/proxy/JNIPlatformProxy.hpp"
#include "spdlog/spdlog.h"
#include <cassert>
namespace xplpc
{
namespace proxy
{
std::shared_ptr<JNIPlatformProxy> JNIPlatformProxy::instance = nullptr;
std::shared_ptr<JNIPlatformProxy> JNIPlatformProxy::shared()
{
if (instance == nullptr)
{
instance = std::make_shared<JNIPlatformProxy>();
}
return instance;
}
void JNIPlatformProxy::initialize()
{
initializePlatform();
}
void JNIPlatformProxy::initializePlatform()
{
spdlog::debug("[JNIPlatformProxy : initializePlatform] 2");
// set jvm from platform jvm
static ::jni::JvmRef<::jni::kDefaultJvm> jvm{platformJavaVM};
spdlog::debug("[JNIPlatformProxy : initializePlatform] 3");
// call initialize platform method
::jni::StaticRef<kPlatformProxy>{}("onInitializePlatform");
spdlog::debug("[JNIPlatformProxy : initializePlatform] 4");
}
void JNIPlatformProxy::finalize()
{
finalizePlatform();
}
void JNIPlatformProxy::finalizePlatform()
{
spdlog::debug("[JNIPlatformProxy : finalizePlatform] 5");
::jni::StaticRef<kPlatformProxy>{}("onFinalizePlatform");
// reset
this->platformJavaVM = nullptr;
}
void JNIPlatformProxy::callProxy(const std::string &key, const std::string &data)
{
spdlog::debug("[JNIPlatformProxy : callProxy] 6");
::jni::StaticRef<kPlatformProxy>{}("onNativeProxyCall", key, data);
}
bool JNIPlatformProxy::hasMapping(const std::string &name)
{
spdlog::debug("[JNIPlatformProxy : hasMapping] 8");
return ::jni::StaticRef<kPlatformProxy>{}("onHasMapping", name);
}
void JNIPlatformProxy::onNativeProxyCallback(const jstring &key, const std::string &data)
{
spdlog::debug("[JNIPlatformProxy : onNativeProxyCallback] 7");
::jni::StaticRef<kPlatformProxy>{}("onNativeProxyCallback", key, data);
}
void JNIPlatformProxy::setPlatformJavaVM(JavaVM *pjvm)
{
spdlog::debug("[JNIPlatformProxy : setPlatformJavaVM] 1");
this->platformJavaVM = pjvm;
}
} // namespace proxy
} // namespace xplpc
There is anything special i need do in TEST envrionment?
Unfortunately it's really hard for me to read code without being able to run it and compile it :(
I'm pretty confident that you're seeing the null pointer because your JNIEnv
is set to null
but I don't see a reason for it. Without being able to compile and run your code it's not that easy for me to digest.
The top reasons I can think of are:
ThreadGuard
If you can submit a toy example as a pull request to JNI Bind of an existing test I can play with it, but I'm afraid I'm just not setup to build your project.
I assume this happens right away in the program? If you want, try setting the JniEnv manually with JniEnv::SetEnv
. I'm afraid the only alternative I can suggest is working backwards from a good state. and adding piecewise until it breaks.
Hi @jwhpryor,
The PR is simple: https://github.com/xplpc/xplpc/pull/46/files
It change few files and only about JNI.
To compile you can open it in Android Studio after compile:
Step 1:
git clone https://github.com/xplpc/xplpc.git -b "google-jni-bind"
cd xplpc
python3 xplpc.py kotlin-build --platform=android --build=debug
Step 2:
Open folder "kotlin/android/lib" in Android Studio and run the tests.
Hello! I think I've resolved as much as I can from this bug. It might be helpful if there's anything outstanding to please file a new bug since this one has gotten pretty large.
Per the secondary thread issue, I have a workaround coming shortly (it's actually intended behaviour on Android).
I’m still with the same problem.
I generate a new header using your bazel task, but the problem persist only with jni-bind.
Can you give some minutes of your time to help me?
Em sex., 5 de jan. de 2024 às 21:13, Jamieson @.***> escreveu:
Closed #188 https://github.com/google/jni-bind/issues/188 as completed.
— Reply to this email directly, view it on GitHub https://github.com/google/jni-bind/issues/188#event-11406239149, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADAOWBZ5EDNI7BKXZLA33TYNCJKHAVCNFSM6AAAAAA4DX7ZL2VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRGQYDMMRTHEYTIOI . You are receiving this because you authored the thread.Message ID: @.***>
Sorry, are you referring to the crash on the secondary thread? If so, please call SetFallbackLoader
with an instance of your activity and it will do the rest.
I just realised that folks don't have documentation to run off and sadly the Android samples aren't public (and that's where I duplicated that crash).
FYI I uploaded the Android test that I used to test this fix here.
Sadly, I haven't managed to get these tests running under Bazel, but it at least shows the correct flow.
In my case, i initialize the main class with JVM on JNI_Onload method:
https://github.com/xplpc/xplpc/blob/google-jni-bind/jni/lib/src/xplpc/jni/platform.cpp#L26-L29
And it call "initializePlatform" that call jni-bind library:
I don't understand what is the problem and why i will need have access to any activity, it don't make sense to me.
Can you help me?
I am sorry for slow response, I am in the middle of many work things 😓
Try calling jvm->SetFallbackClassLoaderFromJObject(fixture);
like I do in the sample code for thread_test.
I agree it seems really stupid your JNI code should have anything to do with your Activity
, but actually, there is complex behaviour behind the scene.
Android is different from Java because it has its own classloader. In regular Java, when a new thread is spawned it shares the same bootloader on other threads, so new classes are found, but on Android, not so. By setting a "fallback loader", native threads have an opportunity to capture a backdoor instance of the application classloader.
TBH I think it's kind of idiotic this is the behaviour, but I can only work around what exists, and this was the absolute best I could come up with (I tried really hard). Given the constraints, it's pretty good (but I still hate that you have to do it at all).
Hi,
What need be fixture, any jobject?
In my case, the only way to get a valid jobject that don't be released is the old code:
auto env = jniGetThreadEnv();
jclass ourClass = env->FindClass("com/xplpc/core/XPLPC");
jclass classClass = env->GetObjectClass(ourClass);
jmethodID getClassLoaderMethod = env->GetMethodID(classClass, "getClassLoader", "()Ljava/lang/ClassLoader;");
jobject tmp = env->CallObjectMethod(ourClass, getClassLoaderMethod);
classLoader = (jobject)env->NewGlobalRef(tmp);
But, if i need back and use the old code only to do it, i think that jni-bind is don't usable to Android (since i need use the old code).
Can you help me?
It just needs to be any Activity
(or Application
probably). You don't need to do the manual calls your highlighting above, that's basically what SetFallbackClassLoaderFromJObject
is doing.
Hi,
How can i use it inside my project XPLPC: https://github.com/xplpc/xplpc
Basically is only some functions: https://github.com/xplpc/xplpc/blob/main/jni/lib/src/xplpc/jni/platform.cpp and https://github.com/xplpc/xplpc/blob/main/jni/lib/src/xplpc/jni/support.cpp
Can anyone help me to migrate for JNI Bind?
Make sense in my case?
Thanks.