您的位置:首页 > 移动开发

sun.zip.disableMemoryMapping

2018-02-11 14:22 1101 查看
有时候你如果修改了JVM正在load的jar文件,会导致JVM crash。stacktrace是在java.util.zip.ZipFile.getEntry() 时发生的。

There are three possible scenarios here:
1. While a class is in use it is dynamically reloaded from a jar file.
2. While a jar file is being accessed by the class loader, the jar file is being modified.
3. A Jarfile which was bigger than 4GB was accessed (applies to Java 6 and earlier only)

那么解决办法就是要确保当JVM在装载jar文件的时候,jar文件不要被其它程序更新或者修改。后来JVM就引入了一个新的性质sun.zip.disableMemoryMapping,如果在JVM启动时加上参数-Dsun.zip.disableMemoryMapping=true,然后JVM在遇到这种情况下的时候就不crash。

当然不能过度依赖这个性质,因为jar文件在被load的时候被更新可能会导致程序执行异常,更容易出bug等问题。
原文:http://blog.csdn.net/hongchangfirst/article/details/78950369作者:hongchangfirsthongchangfirst的主页:http://blog.csdn.net/hongchangfirst
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: