mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-02 08:43:20 +00:00
Realized that the jclass and jmethodID variables in the callbacks cannot be static
There's no guarantee that ALL calls to the callbacks will be on the same class as they're just interfaces and user defined
This commit is contained in:
parent
dc00ce4f44
commit
5e1fb4e253
@ -77,20 +77,15 @@ namespace {
|
|||||||
|
|
||||||
JNIEnv *env = ref->env;
|
JNIEnv *env = ref->env;
|
||||||
|
|
||||||
static jclass configListenerClass = NULL;
|
jclass configListenerClass = NULL;
|
||||||
static jmethodID callbackMethod = NULL;
|
jmethodID callbackMethod = NULL;
|
||||||
|
|
||||||
if(configListenerClass == NULL)
|
|
||||||
{
|
|
||||||
configListenerClass = env->GetObjectClass(ref->configListener);
|
configListenerClass = env->GetObjectClass(ref->configListener);
|
||||||
if(configListenerClass == NULL)
|
if(configListenerClass == NULL)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(callbackMethod == NULL)
|
|
||||||
{
|
|
||||||
callbackMethod = env->GetMethodID(configListenerClass,
|
callbackMethod = env->GetMethodID(configListenerClass,
|
||||||
"onNetworkConfigurationUpdated",
|
"onNetworkConfigurationUpdated",
|
||||||
"(JLcom/zerotierone/sdk/VirtualNetworkConfigOperation;Lcom/zerotierone/sdk/VirtualNetworkConfig;)I");
|
"(JLcom/zerotierone/sdk/VirtualNetworkConfigOperation;Lcom/zerotierone/sdk/VirtualNetworkConfig;)I");
|
||||||
@ -98,7 +93,6 @@ namespace {
|
|||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
jobject operationObject = createVirtualNetworkConfigOperation(env, operation);
|
jobject operationObject = createVirtualNetworkConfigOperation(env, operation);
|
||||||
if(operationObject == NULL)
|
if(operationObject == NULL)
|
||||||
@ -129,27 +123,21 @@ namespace {
|
|||||||
|
|
||||||
JNIEnv *env = ref->env;
|
JNIEnv *env = ref->env;
|
||||||
|
|
||||||
static jclass frameListenerClass = NULL;
|
jclass frameListenerClass = NULL;
|
||||||
static jmethodID callbackMethod = NULL;
|
jmethodID callbackMethod = NULL;
|
||||||
|
|
||||||
if(frameListenerClass == NULL)
|
|
||||||
{
|
|
||||||
frameListenerClass = env->GetObjectClass(ref->frameListener);
|
frameListenerClass = env->GetObjectClass(ref->frameListener);
|
||||||
if(frameListenerClass == NULL)
|
if(frameListenerClass == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(callbackMethod == NULL)
|
|
||||||
{
|
|
||||||
callbackMethod = env->GetMethodID(frameListenerClass,
|
callbackMethod = env->GetMethodID(frameListenerClass,
|
||||||
"onVirtualNetworkFrame", "(JJJJJ[B)V");
|
"onVirtualNetworkFrame", "(JJJJJ[B)V");
|
||||||
if(callbackMethod == NULL)
|
if(callbackMethod == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
jbyteArray dataArray = env->NewByteArray(frameLength);
|
jbyteArray dataArray = env->NewByteArray(frameLength);
|
||||||
env->SetByteArrayRegion(dataArray, 0, frameLength, (jbyte*)frameData);
|
env->SetByteArrayRegion(dataArray, 0, frameLength, (jbyte*)frameData);
|
||||||
@ -178,20 +166,15 @@ namespace {
|
|||||||
|
|
||||||
JNIEnv *env = ref->env;
|
JNIEnv *env = ref->env;
|
||||||
|
|
||||||
static jclass dataStoreGetClass = NULL;
|
jclass dataStoreGetClass = NULL;
|
||||||
static jmethodID callbackMethod = NULL;
|
jmethodID callbackMethod = NULL;
|
||||||
|
|
||||||
if(dataStoreGetClass == NULL)
|
|
||||||
{
|
|
||||||
dataStoreGetClass = env->GetObjectClass(ref->dataStoreGetListener);
|
dataStoreGetClass = env->GetObjectClass(ref->dataStoreGetListener);
|
||||||
if(dataStoreGetClass == NULL)
|
if(dataStoreGetClass == NULL)
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(callbackMethod == NULL)
|
|
||||||
{
|
|
||||||
callbackMethod = env->GetMethodID(dataStoreGetClass,
|
callbackMethod = env->GetMethodID(dataStoreGetClass,
|
||||||
"onDataStoreGet",
|
"onDataStoreGet",
|
||||||
"(Ljava/lang/String;[BJ[J)J");
|
"(Ljava/lang/String;[BJ[J)J");
|
||||||
@ -199,7 +182,6 @@ namespace {
|
|||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
jstring nameStr = env->NewStringUTF(objectName);
|
jstring nameStr = env->NewStringUTF(objectName);
|
||||||
jbyteArray bufferObj = env->NewByteArray(bufferSize);
|
jbyteArray bufferObj = env->NewByteArray(bufferSize);
|
||||||
@ -227,21 +209,17 @@ namespace {
|
|||||||
|
|
||||||
JNIEnv *env = ref->env;
|
JNIEnv *env = ref->env;
|
||||||
|
|
||||||
static jclass dataStorePutClass = NULL;
|
jclass dataStorePutClass = NULL;
|
||||||
static jmethodID callbackMethod = NULL;
|
jmethodID callbackMethod = NULL;
|
||||||
static jmethodID deleteMethod = NULL;
|
jmethodID deleteMethod = NULL;
|
||||||
|
|
||||||
|
|
||||||
if(dataStorePutClass == NULL)
|
|
||||||
{
|
|
||||||
dataStorePutClass = env->GetObjectClass(ref->dataStorePutListener);
|
dataStorePutClass = env->GetObjectClass(ref->dataStorePutListener);
|
||||||
if(dataStorePutClass == NULL)
|
if(dataStorePutClass == NULL)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(callbackMethod == NULL)
|
|
||||||
{
|
|
||||||
callbackMethod = env->GetMethodID(dataStorePutClass,
|
callbackMethod = env->GetMethodID(dataStorePutClass,
|
||||||
"onDataStorePut",
|
"onDataStorePut",
|
||||||
"(Ljava/lang/String;[BZ)I");
|
"(Ljava/lang/String;[BZ)I");
|
||||||
@ -249,17 +227,13 @@ namespace {
|
|||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(deleteMethod == NULL)
|
|
||||||
{
|
|
||||||
deleteMethod = env->GetMethodID(dataStorePutClass,
|
deleteMethod = env->GetMethodID(dataStorePutClass,
|
||||||
"onDelete", "(Ljava/lang/String;)I");
|
"onDelete", "(Ljava/lang/String;)I");
|
||||||
if(deleteMethod == NULL)
|
if(deleteMethod == NULL)
|
||||||
{
|
{
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
jstring nameStr = env->NewStringUTF(objectName);
|
jstring nameStr = env->NewStringUTF(objectName);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user