问题描述
有人知道为什么JSR / RET字节码对在Java 6中被弃用了吗?
Does anyone know why the JSR/RET bytecode pair is deprecated in Java 6?
我在网上找到的唯一有意义的解释是他们通过以下方式进行代码分析运行时越来越难以执行。有没有人知道另一个原因?
The only meaningful explanation I found on the net was that they made code analysis by the runtime harder and slower to perform. Does anyone know another reason?
推荐答案
JSR和RET使得字节码验证比由于放松而更难以实现一些正常的字节码约束(例如在进入JSR时具有一致的堆栈形状)。好处很小(在某些情况下可能会稍微小一点的方法),并且验证程序在处理奇怪的JSR / RET模式(以及潜在的安全漏洞以及完整验证的相关运行时成本)方面的持续困难使其成为一个无用的功能继续拥有。
JSR and RET make bytecode verification a lot more difficult than it might otherwise be due to the relaxation of some normal bytecode constraints (such as having a consistent stack shape on entry to a JSR). The upside is very minor (potentially slightly smaller methods in some cases) and the continuing difficulties in the verifier dealing with odd JSR/RET patterns (and potential security vulnerabilities, and the associated runtime cost of full verification) make it a non-useful feature to continue having.
由于数据的原因而启用的堆栈映射和轻量级验证器在类加载过程中获得了巨大的性能提升,不会牺牲安全性。
Stack maps and the lighter-weight verifier that is enabled as a result of the data are a big performance win during class loading for no sacrifice in safety.
这篇关于为什么JSR / RET不推荐使用Java字节码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!