jni.hpp icon indicating copy to clipboard operation
jni.hpp copied to clipboard

Incorrect wrapping code

Open haelix888 opened this issue 6 years ago • 1 comments

The code at native_method:328 seems incorrect, why would you do std::decay_t<Args>&?

Comment mine: auto wrapper = [field, initializer] (JNIEnv& e, Object<TagType>& obj, /std::decay_t<Args>&/Args... args) // TODO why reference?

This causes wrapping of constructors to fail.

haelix888 avatar Nov 22 '18 15:11 haelix888

Not a maintainer or contributor, but I've been working with this library a bit lately. My thoughts:

This is intended - there is a distinction between jni::Constructor and jni::Method. Constructors require creating a new local reference, while any objects returned from Java via a non-constructor method will already have been created.

Use jni::Class<TagType>::GetConstructor<Constructor args...>() if you have a high-level struct exposing public static const char* Name(){ return "java/class/path"; }

this-kirke avatar Feb 16 '19 13:02 this-kirke