有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java确实需要接口指针来提供多个版本的JNI函数表吗

在JNI规范中,它说:

The JNI interface is organized like a C++ virtual function table or a COM interface. The advantage to using an interface table, rather than hard-wired function entries, is that the JNI namespace becomes separate from the native code. A VM can easily provide multiple versions of JNI function tables. For example, the VM may support two JNI function tables:

one performs thorough illegal argument checks, and is suitable for debugging; the other performs the minimal amount of checking required by the JNI specification and is therefore more efficient.

但真的需要吗?毕竟,接口指针是指向指针的指针。在经济衰退中,它的成本更高


共 (1) 个答案

  1. # 1 楼答案

    不,他们(太阳)可以想出其他的设计。由于历史原因,这个JniEnv与我们在一起,并且确实会增加JNI开销,尽管这并不重要

    其想法是让Java端控制是否在每个线程的运行时使用调试函数集。我不相信这个想法曾经帮助过一些人调试他们的本地代码

    注意,C++包装器显著减少了麻烦(当然,这只是语法;开销不去)。p>