如何获取在 jni 中返回泛型类型的函数的方法 ID?

how can I get method id for a function returning a generic type in jni?

    jclass queueCls = (jclass)(*env)->FindClass(env, "java/util/concurrent/LinkedBlockingQueue");
    if(queueCls == NULL) {
        LOGE("can not get class for blocking queue");
                return;
    }
    jmethodID take = (*env)->GetMethodID(env, queueCls, "take",
            "()[B");
    if (take == NULL) {
        LOGE("can not get take method for blocking queue");
        return;
    }

并且 take 的值始终为 NULL。参见 this。我正在使用 LinkedBlockingQueue<byte[]>.

感谢提供任何示例。

看看 this 答案。

您应该将 LinkedBlockingQueue<byte[]> 对象视为 JNI 端的简单 LinkedBlockingQueue,因为 Java 泛型 在编译时解析。

我建议您使用 javah 从已编译的 class 开始生成具有正确 JNI 签名的正确本机头文件。