fusesource / hawtjni

A JNI code generator based on the JNI generator used by the eclipse SWT project
http://fusesource.github.io/hawtjni/
Apache License 2.0
165 stars 61 forks source link

Generator broken for jbyteArray return type #82

Open thedeadliestcatch opened 1 month ago

thedeadliestcatch commented 1 month ago

Suppose a wrapper like so:

  private final native byte[] get_some_bytes(JNIEnv env, @JniArg(cast = "void*") long nativep);
    public byte[] getBytes(long nativep) {
        return get_some_bytes(null, nativep);
    }

And on the wrapper side:

static jbyteArray
get_some_bytes(JNIEnv *env, void *v) {
    jbyteArray value;

    if (!v) {
        return 0;
    }

    value = (*env)->NewByteArray(env, ...);
    if (value == NULL)
        return NULL;

    (*env)->SetByteArrayRegion(env, value, 0, ..., ...);

    return value;
}

Despite the "correct" JNI typing, the following error occurs:

#error Warning: bad return type. :private final native byte[] blah.get_some_bytes(org.fusesource.hawtjni.runtime.JNIEnv,long)

After going through every reference I could find, and reading the 'clazz' implementation in hawtjni, I believe this is currently broken and not a manifestation of a problem in the source code above.