-
Notifications
You must be signed in to change notification settings - Fork 37
Open
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
I got jni-bind working on Windows but needed to work-around a difference in how Oracle JDK 19 defines jint.
On Linux:
typedef int jint;
On Windows (comment from the JDK preserved):
// 'long' is always 32 bit on windows so this matches what jdk expects
typedef long jint;
If I compile on Windows, I get TMP errors:
src/main/c/jni_bind_release.h:507:19: error: static assertion failed due to requirement 'AllUnique_v<void, unsigned char, bool, signed char, short, long, float, long, long long, char, unsigned short, double, std::string, _jstring *, char *, const char *, std::string_view, jni::RefBaseTag<_jstring *>, _jobject *, jni::RefBaseTag<_jobject *>, jni::LoaderTag, jni::Object, jni::Self, _jarray *, jni::RefBaseTag<_jarray *>, jni::ArrayTag<_jarray *>, _jobjectArray *, jni::RefBaseTag<_jobjectArray *>, jni::ArrayTag<_jobjectArray *>, _jintArray *, jni::RefBaseTag<_jintArray *>, jni::ArrayTag<_jintArray *>, _jbooleanArray *, jni::RefBaseTag<_jbooleanArray *>, jni::ArrayTag<_jbooleanArray *>, _jbyteArray *, jni::RefBaseTag<_jbyteArray *>, jni::ArrayTag<_jbyteArray *>, _jcharArray *, jni::RefBaseTag<_jcharArray *>, jni::ArrayTag<_jcharArray *>, _jshortArray *, jni::RefBaseTag<_jshortArray *>, jni::ArrayTag<_jshortArray *>, _jdoubleArray *, jni::RefBaseTag<_jdoubleArray *>, jni::ArrayTag<_jdoubleArray *>, _jfloatArray *, jni::RefBaseTag<_jfloatArray *>, jni::ArrayTag<_jfloatArray *>, _jlongArray *, jni::RefBaseTag<_jlongArray *>, jni::ArrayTag<_jlongArray *>>': FindIdxOfVal only operates on unique sets.
507 | static_assert(AllUnique_v<Ts...>,
| ^~~~~~~~~~~~~~~~~~
src/main/c/jni_bind_release.h:513:40: note: in instantiation of template class 'jni::metaprogramming::FindIdxOfVal<jni::IsConvertibleKey<void>>::StaticAssertWrapper<void, unsigned char, bool, signed char, short, long, float, long, long long, char, unsigned short, double, std::string, _jstring *, char *, const char *, std::string_view, jni::RefBaseTag<_jstring *>, _jobject *, jni::RefBaseTag<_jobject *>, jni::LoaderTag, jni::Object, jni::Self, _jarray *, jni::RefBaseTag<_jarray *>, jni::ArrayTag<_jarray *>, _jobjectArray *, jni::RefBaseTag<_jobjectArray *>, jni::ArrayTag<_jobjectArray *>, _jintArray *, jni::RefBaseTag<_jintArray *>, jni::ArrayTag<_jintArray *>, _jbooleanArray *, jni::RefBaseTag<_jbooleanArray *>, jni::ArrayTag<_jbooleanArray *>, _jbyteArray *, jni::RefBaseTag<_jbyteArray *>, jni::ArrayTag<_jbyteArray *>, _jcharArray *, jni::RefBaseTag<_jcharArray *>, jni::ArrayTag<_jcharArray *>, _jshortArray *, jni::RefBaseTag<_jshortArray *>, jni::ArrayTag<_jshortArray *>, _jdoubleArray *, jni::RefBaseTag<_jdoubleArray *>, jni::ArrayTag<_jdoubleArray *>, _jfloatArray *, jni::RefBaseTag<_jfloatArray *>, jni::ArrayTag<_jfloatArray *>, _jlongArray *, jni::RefBaseTag<_jlongArray *>, jni::ArrayTag<_jlongArray *>>' requested here
513 | static constexpr std::size_t value = StaticAssertWrapper<Ts...>::value;
| ^
src/main/c/jni_bind_release.h:518:40: note: in instantiation of static data member 'jni::metaprogramming::FindIdxOfVal<jni::IsConvertibleKey<void>>::value<void, unsigned char, bool, signed char, short, long, float, long, long long, char, unsigned short, double, std::string, _jstring *, char *, const char *, std::string_view, jni::RefBaseTag<_jstring *>, _jobject *, jni::RefBaseTag<_jobject *>, jni::LoaderTag, jni::Object, jni::Self, _jarray *, jni::RefBaseTag<_jarray *>, jni::ArrayTag<_jarray *>, _jobjectArray *, jni::RefBaseTag<_jobjectArray *>, jni::ArrayTag<_jobjectArray *>, _jintArray *, jni::RefBaseTag<_jintArray *>, jni::ArrayTag<_jintArray *>, _jbooleanArray *, jni::RefBaseTag<_jbooleanArray *>, jni::ArrayTag<_jbooleanArray *>, _jbyteArray *, jni::RefBaseTag<_jbyteArray *>, jni::ArrayTag<_jbyteArray *>, _jcharArray *, jni::RefBaseTag<_jcharArray *>, jni::ArrayTag<_jcharArray *>, _jshortArray *, jni::RefBaseTag<_jshortArray *>, jni::ArrayTag<_jshortArray *>, _jdoubleArray *, jni::RefBaseTag<_jdoubleArray *>, jni::ArrayTag<_jdoubleArray *>, _jfloatArray *, jni::RefBaseTag<_jfloatArray *>, jni::ArrayTag<_jfloatArray *>, _jlongArray *, jni::RefBaseTag<_jlongArray *>, jni::ArrayTag<_jlongArray *>>' requested here
518 | FindIdxOfVal<Comparator>::template value<Ts...>;
| ^
src/main/c/jni_bind_release.h:760:26: note: in instantiation of variable template specialization 'jni::metaprogramming::FindIdxOfValWithComparator_idx<jni::IsConvertibleKey<void>, void, unsigned char, bool, signed char, short, long, float, long, long long, char, unsigned short, double, std::string, _jstring *, char *, const char *, std::string_view, jni::RefBaseTag<_jstring *>, _jobject *, jni::RefBaseTag<_jobject *>, jni::LoaderTag, jni::Object, jni::Self, _jarray *, jni::RefBaseTag<_jarray *>, jni::ArrayTag<_jarray *>, _jobjectArray *, jni::RefBaseTag<_jobjectArray *>, jni::ArrayTag<_jobjectArray *>, _jintArray *, jni::RefBaseTag<_jintArray *>, jni::ArrayTag<_jintArray *>, _jbooleanArray *, jni::RefBaseTag<_jbooleanArray *>, jni::ArrayTag<_jbooleanArray *>, _jbyteArray *, jni::RefBaseTag<_jbyteArray *>, jni::ArrayTag<_jbyteArray *>, _jcharArray *, jni::RefBaseTag<_jcharArray *>, jni::ArrayTag<_jcharArray *>, _jshortArray *, jni::RefBaseTag<_jshortArray *>, jni::ArrayTag<_jshortArray *>, _jdoubleArray *, jni::RefBaseTag<_jdoubleArray *>, jni::ArrayTag<_jdoubleArray *>, _jfloatArray *, jni::RefBaseTag<_jfloatArray *>, jni::ArrayTag<_jfloatArray *>, _jlongArray *, jni::RefBaseTag<_jlongArray *>, jni::ArrayTag<_jlongArray *>>' requested here
760 | TypeOfNthElement_t<FindIdxOfValWithComparator_idx<Comparator, Keys_...>,
| ^
... etc etc
Full gist here.
I'm not above changing the typedef in the JDK, but if it is possible to make jni-bind tolerant of the types encapsulated by jni_md.h that would be even better.
Either way, for my own edification, what I don't entirely grok is why the template specialization is failing to begin with. I don't see it. The jlong type is on Windows is:
typedef __int64 jlong;
There is no actual difference in the types on Windows and Linux. The types are unique (32-bit and 64-bit literals). Yet AllUnique<> fails.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working