diff --git a/src/jdk.jpackage/windows/native/libjpackage/JniUtils.h b/src/jdk.jpackage/windows/native/libjpackage/JniUtils.h index b37b19bab49..afd5797aaa8 100644 --- a/src/jdk.jpackage/windows/native/libjpackage/JniUtils.h +++ b/src/jdk.jpackage/windows/native/libjpackage/JniUtils.h @@ -26,6 +26,7 @@ #ifndef JNIUTILS_H #define JNIUTILS_H +#include #include #include "jni.h" #include "tstrings.h" @@ -41,6 +42,9 @@ struct JniObjWithEnv { JniObjWithEnv(JNIEnv *env, jobject obj) : env(env), obj(obj) { } + JniObjWithEnv(const std::nullptr_t ptr) : env(ptr), obj(ptr) { + } + bool operator == (const JniObjWithEnv& other) const { return env == other.env && obj == other.obj; } @@ -49,6 +53,14 @@ struct JniObjWithEnv { return ! operator == (other); } + bool operator == (const std::nullptr_t ptr) const { + return env == ptr || obj == ptr; + } + + bool operator != (const std::nullptr_t ptr) const { + return env != ptr && obj != ptr; + } + explicit operator bool() const { return env && obj; }