在Java代码中设置-noverify标志 [英] Set -noverify flag in java code
本文介绍了在Java代码中设置-noverify标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想通过Java代码将-noverify设置为VM参数.我找不到在线任何资源来帮助解决这个问题.
I would like to set -noverify as a VM argument through java code. I could not find any resource online to help with this.
如果我使用System.setProperty(..,..)
,该如何设置值或键?
If I use System.setProperty(..,..)
, what do I set as the value or perhaps the key?
我尝试使用System.property("Xverify","none")
,但这似乎不起作用.
I have tried using System.property("Xverify","none")
but this doesn't seem to work.
注意:这只是为了运行一些测试用例.由于这个问题,我正在关闭字节码验证-链接
Note: This is just to run some test cases. I am turning off byte code verification because of this issue - link
谢谢.
推荐答案
让我总结一下此答案中的评论.
Let me summarize comments in this answer.
- 关闭字节码验证很危险,尤其是当您知道应用程序抛出
VerifyError
时.这意味着应用程序生成无效的字节码,并且当JVM执行它时,结果是不可预测的.例如,JVM可能会崩溃,例如这个问题. - 没有合法的方法以编程方式关闭字节码验证.否则,这将是严重的安全漏洞,允许在没有显式权限的情况下运行不安全的代码.
- 您提到的PowerMock问题的链接确认存在 Javassist库中的错误.解决此问题的正确方法是,更新到已修复此错误的Javassist新版本.
- It is dangerous to turn the bytecode verification off, especially when you know the application throws
VerifyError
. This means that the application generates invalid bytecode, and when JVM executes it, the results are unpredictable. For example, JVM may crash like in this question. - There is no legal way to turn the bytecode verification off programmatically. Otherwise this would be a serious security breach that allows to run unsafe code without explicit permissions.
- The link to PowerMock issue you've mentioned confirms that there was a bug in Javassist library. The right way to solve the issue is to update to newer Javassist version where this bug has been fixed.
这篇关于在Java代码中设置-noverify标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文