Effective Java 54 Use native methods judiciously
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++.
Historical usages of native methods
- Access to platform-specific facilities such as registries and file locks.
- Access to libraries of legacy code.
- Access to native methods written for performance-critical part of application.
Disadvantage of native methods
- Native language are not safe (Item 39), native methods are no longer immune to memory corruption errors.
- Since native languages are platform dependent, application use them are far less possible.
- Difficult to debug.
- Fixed cost associated with going into and out of native code.
- It requires "glue code" that is difficult to read and tedious to write.
Summary
Think twice before using native methods. Rarely, if ever, use them for improved performance. If you must use native methods to access low-level resources or legacy libraries, use as little native code as possible and test it thoroughly. A single bug in the native code can corrupt your entire application.
Effective Java 54 Use native methods judiciously的更多相关文章
- Effective Java 27 Favor generic methods
Static utility methods are particularly good candidates for generification. The type parameter list, ...
- Effective Java 76 Write readObject methods defensively
Principle readObject method is effectively another public constructor, and it demands all of the sam ...
- Effective Java 71 Use lazy initialization judiciously
Lazy initialization - It decreases the cost of initializing a class or creating an instance, at the ...
- Effective Java Index
Hi guys, I am happy to tell you that I am moving to the open source world. And Java is the 1st langu ...
- 《Effective Java》读书笔记 - 8.通用编程
Chapter 8 General Programming Item 45: Minimize the scope of local variables local variables应该在他们要被用 ...
- Effective Java 目录
<Effective Java>目录摘抄. 我知道这看起来很糟糕.当下,自己缺少实际操作,只能暂时摘抄下目录.随着,实践的增多,慢慢填充更多的示例. Chapter 2 Creating ...
- 【Effective Java】阅读
Java写了很多年,很惭愧,直到最近才读了这本经典之作<Effective Java>,按自己的理解总结下,有些可能还不够深刻 一.Creating and Destroying Obje ...
- [Effective Java]第八章 通用程序设计
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- Effective Java通俗理解(下)
Effective Java通俗理解(上) 第31条:用实例域代替序数 枚举类型有一个ordinal方法,它范围该常量的序数从0开始,不建议使用这个方法,因为这不能很好地对枚举进行维护,正确应该是利用 ...
随机推荐
- 在Kibana上格式化字段,更好的在dashboard上展示
一.为什么要格式化? 接着之前的文章-利用 ELK系统分析Nginx日志并对数据进行可视化展示.下面是http访问的日志,里面有一个字段,bytes 传输的字节,如下图: 绿色框框内选中的就是本次请求 ...
- CentOS6.5菜鸟之旅:安装VirtualBox4.3
一.下载VirtualBox的RHEL软件库配置文件 cd /etc/yum.repos.d wget http://download.virtualbox.org/virtualbox/rpm/rh ...
- Gradle学习系列之一——Gradle快速入门
这是一个关于Gradle的学习系列,其中包含以下文章: Gradle快速入门 创建Task的多种方法 读懂Gradle语法 增量式构建 自定义Property 使用java Plugin 依赖管理 构 ...
- Sprint回顾-0525
1.回顾组织 主题:“我们下次怎么样才能更加认真对待?” 时间:设定为1小时. 参与者:整个团队. 场所:宿舍走廊. 秘书:团队队长秘书,筹备.记录.整理. 2.回顾流程 Sprint总结: ...
- ADO.NET常用对象的基础概念强化
1.Command对象 1.1 ExcuteNonquery---执行非查询语句,返回受影响的行数,在新增,删除,修改的时候,如果我们要返回结果集那么就不能使用它了: 1.2 ExcuteScalar ...
- 组合数学 - 母函数的变形 --- hdu 1171:Big Event in HDU
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- 可拖动FPS显示框(UGUI)
简介 本来是想往上找一个可拖动FPS显示框的(我记得以前有人写过),然而搜了一个多小时都没搜到,索性自己写了一个,花费不到20分钟,看来还是自己动手丰衣足食啊 o(╯□╰)o 效果 上下的Toast不 ...
- 关于PS激活的一些感想(附上PS CC2015)
最近跟着慕课学了一些前端的必备PS技能,就顺道把PS CC2015装上. 安装的过程没什么大问题,最要命的是激活环节!各种踩坑,但万万没想到,最终我还是成功的把它激活了. 本人所安装PS版本信息 好了 ...
- 重新想象 Windows 8.1 Store Apps (74) - 新增控件: Flyout, MenuFlyout, SettingsFlyout
[源码下载] 重新想象 Windows 8.1 Store Apps (74) - 新增控件: Flyout, MenuFlyout, SettingsFlyout 作者:webabcd 介绍重新想象 ...
- 51Node 1035----最长的循环节
51Node 1035----最长的循环节 正整数k的倒数1/k,写为10进制的小数如果为无限循环小数,则存在一个循环节,求<=n的数中,倒数循环节长度最长的那个数. 1/6= 0.1 ...