使用-XX:-UseSplitVerifier有多安全? [英] How safe is it to use -XX:-UseSplitVerifier?

查看:225
本文介绍了使用-XX:-UseSplitVerifier有多安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用检测的JDK7编译代码存在已知的兼容性问题。
至于 http://www.oracle.com/ technetwork / java / javase / compatibility-417013.html

There are known compatibility issues with JDK7 compiled code using instrumentation. As for http://www.oracle.com/technetwork/java/javase/compatibility-417013.html


版本号为51的类文件仅使用类型检查进行验证验证程序,因此方法必须在适当时具有StackMapTable属性。对于版本为50的类文件,如果文件中的堆栈映射丢失或不正确,Hotspot JVM将(并继续)故障转移到类型推断验证程序。对于版本为51的类文件(Java SE 7的默认版本),不会发生此故障转移行为。
修改版本51类文件中字节码的任何工具必须确保更新stackmap信息以与字节码保持一致才能通过验证。

Classfiles with version number 51 are exclusively verified using the type-checking verifier, and thus the methods must have StackMapTable attributes when appropriate. For classfiles with version 50, the Hotspot JVM would (and continues to) failover to the type-inferencing verifier if the stackmaps in the file were missing or incorrect. This failover behavior does not occur for classfiles with version 51 (the default version for Java SE 7). Any tool that modifies bytecode in a version 51 classfile must be sure to update the stackmap information to be consistent with the bytecode in order to pass verification.

解决方案是使用 -XX:-UseSplitVerifier ,如下所述:
https://community.oracle.com/blogs/fabriziogiudici/2012/05/ 07 /理解 - 微妙的新行为-jdk-7

The solution is to use -XX:-UseSplitVerifier as summarised here: https://community.oracle.com/blogs/fabriziogiudici/2012/05/07/understanding-subtle-new-behaviours-jdk-7

它有多安全?我想Oracle已将此检查置于原因之中。如果我不使用它,我可能会冒一些其他问题。

How safe it is? I suppose Oracle has put this check in for a reason. If I don't use it, I may be risking some other issues.

使用 -XX会产生什么后果:-UseSplitVerifier

谢谢,

Piotr。

推荐答案

简而言之,它非常安全。

In short, it's perfectly safe.

从Java 6开始,Oracle的编译器使用StackMapTable创建了类文件。基本思想是编译器可以显式指定对象的类型,而不是让运行时执行它。这在运行时提供了微小的加速,换取了编译期间的一些额外时间以及编译的类文件(前面提到的StackMapTable)中的一些复杂性。

Since Java 6, Oracle's compiler has made class files with a StackMapTable. The basic idea is that the compiler can explicitly specify what the type of an object is, instead of making the runtime do it. That provides a tiny speedup in the runtime, in exchange for some extra time during compile and some complexity in the compiled class file (the aforementioned StackMapTable).

作为一项实验性功能,Java 6编译器默认不启用它。如果不存在StackMapTable,则运行时默认为验证对象类型本身。

As an experimental feature, it was not enabled by default in the Java 6 compiler. The runtime defaults to verifying the object types itself if no StackMapTable exists.

直到Java 7. Oracle强制要求:编译器生成它们,运行时验证它们。如果StackMapTable不存在,它仍然使用旧的验证程序...但仅限于Java 6或更早版本(版本50)的类文件。 Java 7类文件(版本51)需要使用StackMapTable,因此运行时不会减少它们相同的松弛。

Until Java 7. Oracle made it mandatory: the compiler generates them, and the runtime verifies them. It still uses the old verifier if the StackMapTable isn't there... but only on class files from Java 6 or earlier (version 50). Java 7 class files (version 51) are required to use the StackMapTable, and so the runtime won't cut them the same slack.

如果你的类文件只是一个问题没有StackMapTable生成。例如,如果您使用的是非Oracle JVM。或者如果你之后搞乱了字节码 - 比如将其用于调试器,优化器或代码覆盖率分析器。

That's only a problem if your classfiles were generated without a StackMapTable. For instance, if you used a non-Oracle JVM. Or if you messed with bytecode afterwards -- like instrumenting it for use with a debugger, optimizer, or code coverage analyzer.

但你可以解决它! Oracle的JVM提供了-XX:+ UseSplitVerifier来强制运行时回退到旧的类型验证程序。它并不关心StackMapTable。

But you can get around it! Oracle's JVM provides the -XX:+UseSplitVerifier to force the runtime to fallback to the old type verifier. It doesn't care about StackMapTable.

在实践中,运行速度和效率的希望优化没有实现:如果存在,它还没有实现足以让任何人注意到。由于新型验证器不提供任何新功能(只是优化),因此关闭它是完全安全的。

In practice, the hoped-for optimization in runtime speed and efficiency hasn't materialized: if it exists, it hasn't been enough for anyone to notice. As the new type verifier doesn't provide any new features (just the optimization), it's perfectly safe to shut it off.

Oracle的解释是在 http://www.oracle.com/technetwork/java/javase/compatibility-417013.html 如果您搜索JSR 202。

Oracle's explanation is at http://www.oracle.com/technetwork/java/javase/compatibility-417013.html if you search for JSR 202.

这篇关于使用-XX:-UseSplitVerifier有多安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆