Loading...
Searching...
No Matches
npe.hpp
Go to the documentation of this file.
#pragma once
#include <jni/functions.hpp>
namespace jni
{
[[noreturn]] inline void ThrowNullPointerException(JNIEnv& env, const char* message = nullptr)
{
ThrowNew(env, FindClass(env, "java/lang/NullPointerException"), message);
}
template < class T >
void NullCheck(JNIEnv& env, T* ptr, const char* message = nullptr)
{
if (!ptr) ThrowNullPointerException(env, message);
}
template < class T >
T& SafeDereference(JNIEnv& env, T* ptr, const char* message = nullptr)
{
NullCheck(env, ptr, message);
return *ptr;
}
}
functions.hpp
jni
Definition advanced_ownership.hpp:6
jni::SafeDereference
T & SafeDereference(JNIEnv &env, T *ptr, const char *message=nullptr)
Definition npe.hpp:19
jni::ThrowNullPointerException
void ThrowNullPointerException(JNIEnv &env, const char *message=nullptr)
Definition npe.hpp:7
jni::FindClass
jclass & FindClass(JNIEnv &env, const char *name)
Definition functions.hpp:34
jni::ThrowNew
void ThrowNew(JNIEnv &env, jclass &clazz, const char *msg=nullptr)
Definition functions.hpp:84
jni::NullCheck
void NullCheck(JNIEnv &env, T *ptr, const char *message=nullptr)
Definition npe.hpp:13