The JNI lets you accomplish these tasks.
JNI允许您完成这些任务。
Only valid Pointers are passed to JNI methods.
传递给JNI方法的指针都是有效的。
JNI code does not read past the ends of arrays.
JNI代码未读取超过数组结束部分之外的内容。
Validating new code against the JNI specification
根据JNI规范验证新代码
JNI programming pitfalls fall into two categories.
JNI编程缺陷可以分为两类。
A string representing the method's signature in JNI syntax.
以jni语法表示方法签名的字符串。
The parameters passed to JNI methods are of the correct types.
传递给JNI方法的参数属于正确的类型。
List all the occurrences of JNI references in your application.
列出应用程序中出现的所有JNI引用。
The JNI specification states that each JNIEnv is local to a thread.
JNI规范规定每个JNIEnv 对于线程来说都是本地的。
Local references are created for any object returned by a JNI function.
jni函数返回的任何对象都会创建本地引用。
Jni is of little use except when working with jni and native libraries.
jni很少使用,除了使用jni或本地库时。
This leads to nine times as many JNI calls for each byte read or written.
这会导致读取或写入的每个字节的JNI调用变成原来的9倍。
For example, Listing 1 shows the JNI code required to call a static method.
举例来说,清单1展示了调用静态方法所需的JNI代码。
Not all the findings the JNI check reports are necessarily errors in the code.
JNI检测报告的所有结论并不一定都是代码中的错误。
Thus, you have to modify the signatures of existing functions to work with JNI.
因而,您不得不修改现有函数的署名以便使用JNI。
The native code that runs in the same process space as the invoking JVM under JNI.
本机代码是作为JNI中的调用JVM运行在相同的进程空间内的。
The first parameter is the JNI environment, frequently used with helper functions.
第一个参数是JNI环境,它与helper 函数会被频繁调用。
Don't think that you need to be an expert in native code or JNI or must know every OS.
不要认为自己必须是一名本机代码或JNI专家,或者必须知道每个操作系统。
Many JNI methods have a return value that indicates whether the call succeeded or not.
许多JNI方法都通过返回值来指示调用成功与否。
Then, to pass the result back, you can use a JNI helper function called NewStringUTF .
然后,为了传回结果,你可以使用一个叫作newstringutf的JNIhelper函数。
Note that it is beyond the scope of this article to provide a complete description of JNI.
注意,提供JNI的完整描述不在本文范围之内。
Many of the JNI methods that natives can call can raise exceptions on the executing thread.
本机能调用的许多JNI方法都会引起与执行线程相关的异常。
As we pointed out in our introduction, the use of JNI isn't sufficient to meet these needs.
正如我们在引言中所指出的,JNI的使用并不能满足这些需求。
This article covers the 10 most common coding and design errors that users of the JNI make.
本文介绍JNI用户最常遇到的10大编码和设计错误。
The native may not make any JNI calls between these methods and may not block for any reason.
本机可能不会在这些方法之间发起任何调用,并且可能不会由于任何原因而阻塞。
The sumValues2() method requires six JNI callbacks and takes 3,572 ms to run 10,000,000 times.
sumValues2()方法需要6 个JNI回调,并且运行 10,000,000次需要 3,572ms。
This generates a trace of the native methods called as well as the JNI callbacks that they make.
这将生成对已调用的本机方法以及它们发起的JNI回调的跟踪。
Validate that there is a check for an exception after all JNI calls that can raise an exception.
验证在所有可能引起异常的JNI调用之前都检测了异常。
At the top level of this project, create a directory called "jni" - this is where you'll put your native code.
在这个项目的顶层创建一个叫做“jni”的目录——这是你放置原生代码的地方。
IBM's JVM implementation includes an option that turns on automatic JNI checks, at the cost of slower execution.
IBM的JVM实现包括开启自动JNI检测的选项,其代价是较慢的执行速度。
应用推荐