mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-12 20:28:27 +00:00
added a JniCache objectet for caching jclass, jmethodID, and jfieldID objects
This commit is contained in:
@ -27,6 +27,7 @@
|
||||
|
||||
#include "com_zerotierone_sdk_Node.h"
|
||||
#include "ZT1_jniutils.h"
|
||||
#include "ZT1_jnicache.h"
|
||||
|
||||
#include <ZeroTierOne.h>
|
||||
|
||||
@ -39,6 +40,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// global static JNI Cache Object
|
||||
static JniCache cache;
|
||||
|
||||
namespace {
|
||||
struct JniRef
|
||||
{
|
||||
@ -322,7 +326,7 @@ namespace {
|
||||
LOGD("Calling onDataStoreGet(%s, %p, %lu, %p)",
|
||||
objectName, buffer, bufferIndex, objectSizeObj);
|
||||
|
||||
long retval = env->CallLongMethod(
|
||||
long retval = (long)env->CallLongMethod(
|
||||
ref->dataStoreGetListener, dataStoreGetCallbackMethod,
|
||||
nameStr, bufferObj, (jlong)bufferIndex, objectSizeObj);
|
||||
|
||||
@ -446,6 +450,18 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
{
|
||||
cache.setJavaVM(vm);
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
|
||||
{
|
||||
cache.clearCache();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Class: com_zerotierone_sdk_Node
|
||||
* Method: node_init
|
||||
@ -905,7 +921,7 @@ JNIEXPORT jobject JNICALL Java_com_zerotierone_sdk_Node_multicastSubscribe(
|
||||
|
||||
uint64_t nwid = (uint64_t)in_nwid;
|
||||
uint64_t multicastGroup = (uint64_t)in_multicastGroup;
|
||||
uint64_t multicastAdi = (uint64_t)in_multicastAdi;
|
||||
unsigned long multicastAdi = (unsigned long)in_multicastAdi;
|
||||
|
||||
ZT1_ResultCode rc = ZT1_Node_multicastSubscribe(
|
||||
node, nwid, multicastGroup, multicastAdi);
|
||||
|
Reference in New Issue
Block a user