1. The Java Native Interface (JNI) allows Java applications to call native methods, which are special methods written in native programming languages such as C or C++.
2. Native methods have had three main uses. They provided access to platform-specific facilities such as registries and file locks. They provided access to libraries of legacy code, which could in turn provide access to legacy data. Finally, native methods were used to write performance-critical parts of applications in native languages for improved performance.
3. java.util.prefs, added in release 1.4, offers the functionality of a registry, and java.awt.SystemTray, added in release 1.6, offers access to the desktop system tray area.
4. It is rarely advisable to use native methods for improved performance. JVM implementations have gotten much faster. For most tasks, it is now possible to obtain comparable performance without resorting to native methods.
5. The use of native methods has serious disadvantages. Applications using native methods are no longer immune to memory corruption errors. Since native languages are platform dependent, applications using native methods are far less portable. Applications using native code are far more difficult to debug. There is a fixed cost associated with going into and out of native code, so native methods can decrease performance if they do only a small amount of work. Finally, native methods require “glue code” that is difficult to read and tedious to write.
相关推荐
Item 66: Use native methods judiciously Item 67: Optimize judiciously Item 68: Adhere to generally accepted naming conventions 10 Exceptions Item 69: Use exceptions only for exceptional conditions ...
- **Function Overloading:** Use function overloading judiciously to provide a clear API. - **Default Arguments:** Default arguments can make functions more flexible but can also introduce ambiguity. -...
条款54:让自己熟悉包括tr1在内的标准程序库 familiarize yourself with the standard library, including tr1. 条款55:让自己熟悉boost familiarize yourself with boost. a 本书之外 b 新旧版条款对映 索引
2. **条目2:考虑为静态工厂方法而不是构造器(Consider Static Factory Methods Instead of Constructors)** 静态工厂方法有命名灵活性,不需创建新类就能返回实例,还可以返回原类型的子类型,或者在不需要时...
Judiciously chosen observables lead to physically interpretable spatio-temporal features of the complex system under consideration and provide a connection to manifold learning methods. Our method ...
Use logging judiciously to ensure that only relevant information is recorded. 3. **Utilize Configuration Files:** Configure Log4j using external configuration files rather than hardcoding settings ...
Used judiciously, StructureMap can greatly enhance the opportunities for code reuse by minimizing direct coupling between classes and configuration mechanisms; ☆ 文件清单:☆ StructureMap2.6.1.7z ...
其他建议还包括尝试打破你的电路(Try to Break Your Circuits),审慎使用角点建模(Use Corner Modeling Judiciously),以及使用寄生参数的后注释(Use Back-Annotation of Parasitics)等。 总结来说,模拟电路...
augmenting it judiciously, cross-referencing everything, and organizing it according to the most common needs of web developers. The result is a handy book that offers the bare essentials on web ...
This book introduces you to the Scala programming language its object ...judiciously used for critical business applications by leading companies such as Twitter LinkedIn Foursquare the Guardian Morgan ...
speed, and therefore, must be used judiciously. We present techniques for dual-output LUT packing that lead to improved area-efficiency, with minimal performance degradation. We then describe packing ...
The proposed optimization method is achieved by judiciously configuring the FWM operational condition and exploiting the nonlinear phase shift induced by self- and cross-phase modulations to properly...