JSSE: new helper functions to throw exceptions (throwWolfSSLJNIException, throwWolfSSLException), avoids calling FindClass unnecessarily, improves performance
parent
767a289113
commit
3aa056c607
|
@ -181,6 +181,32 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved)
|
||||||
g_verifyCallbackMethodId = NULL;
|
g_verifyCallbackMethodId = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throw WolfSSLJNIException
|
||||||
|
*/
|
||||||
|
void throwWolfSSLJNIException(JNIEnv* jenv, const char* msg)
|
||||||
|
{
|
||||||
|
jclass excClass = (*jenv)->FindClass(jenv, "com/wolfssl/WolfSSLJNIException");
|
||||||
|
if (excClass == NULL) {
|
||||||
|
/* Unable to find exception class, give up trying to throw */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(*jenv)->ThrowNew(jenv, excClass, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throw WolfSSLException
|
||||||
|
*/
|
||||||
|
void throwWolfSSLException(JNIEnv* jenv, const char* msg)
|
||||||
|
{
|
||||||
|
jclass excClass = (*jenv)->FindClass(jenv, "com/wolfssl/WolfSSLException");
|
||||||
|
if (excClass == NULL) {
|
||||||
|
/* Unable to find exception class, give up trying to throw */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(*jenv)->ThrowNew(jenv, excClass, msg);
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSL_init
|
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSL_init
|
||||||
(JNIEnv* jenv, jobject jcl)
|
(JNIEnv* jenv, jobject jcl)
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -50,4 +50,8 @@ unsigned int NativePskClientCb(WOLFSSL* ssl, const char* hint, char* identity,
|
||||||
unsigned int NativePskServerCb(WOLFSSL* ssl, const char* identity,
|
unsigned int NativePskServerCb(WOLFSSL* ssl, const char* identity,
|
||||||
unsigned char* key, unsigned int max_key_len);
|
unsigned char* key, unsigned int max_key_len);
|
||||||
|
|
||||||
|
/* Helper functions to throw exceptions */
|
||||||
|
void throwWolfSSLJNIException(JNIEnv* jenv, const char* msg);
|
||||||
|
void throwWolfSSLException(JNIEnv* jenv, const char* msg);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue