对于字段double d = 2.2250738585072012e-308的类,编译挂起 [英] Compilation hangs for a class with field double d = 2.2250738585072012e-308

查看:287
本文介绍了对于字段double d = 2.2250738585072012e-308的类,编译挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个有趣的情况。同事提交了一些更改,不会从IDE(Eclipse)或命令行(Maven)在我的机器上编译。编译过程占用100%的CPU并且只杀死进程的问题将有助于阻止它。经过一些分析,问题的原因被找到并解决。原来是一行double d = 2.2250738585072012e-308(在末尾没有分号)在其中一个接口。以下剪辑重复它。

I have come across an interesting situation. A coworker committed some changes, which would not compile on my machine neither from the IDE (Eclipse) nor from a command line (Maven). The problem manifested in the compilation process taking 100% CPU and only killing the process would help to stop it. After some analysis the cause of the problem was located and resolved. It turned out be a line "double d = 2.2250738585072012e-308" (without semicolon at the end) in one of the interfaces. The following snipped duplicates it.

public class WeirdCompilationIssue {
   double d = 2.2250738585072012e-308
}

为什么编译器会挂起?一个语言边缘情况?

Why would compiler hang? A language edge case?

推荐答案

这是JVM的字符串到双精度转换算法中的一个错误:http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308 /

It's a bug in the String-to-double conversion algorithm of the JVM: http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/

如果您尝试在运行时解析该字符串,您可以得到相同的挂起。编译器挂起,因为它使用相同的代码(毕竟它是一个Java程序)。

You can get the same hang if you try to parse that string at runtime. The compiler hangs because it uses the same code (it's a Java program after all).

更新:现在有一个< =http://en.wikipedia.org/wiki/Common_Vulnerabilities_and_Exposures> CVE 标识符( CVE-2010-4476 )和 a patch (对于Oracle JVM,也适用于OpenJDK)。

Update: the issue now has a CVE identifier (CVE-2010-4476) and a patch (for Oracle JVMs, also works on OpenJDK).

根据补丁,这一切都归结为一个一个一个的错误。

According to the patch it all boils down to an off-by-one error.

这篇关于对于字段double d = 2.2250738585072012e-308的类,编译挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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