为什么 Java 在我尝试使用 ImageIO 时挂在我的 Mac 上?

Why does Java hang on my Mac when I try to use ImageIO?

昨天下午突然,我的 Java(实际上是 Groovy)在尝试调用 ImageIO.read(文件)时开始挂在 ClassLoader.load(字符串,布尔值)中。堆栈跟踪表明它正在尝试加载 AWT 相关代码。

如果是 IntelliJ 或 Gradle 问题,我尝试了命令行,它仍然挂起,但如果我指定 -Djava.awt.headless= 则成功 运行 超过了那个点是的,显然与 -XstartOnFirstThread SWT 2013 错误有关,但这当然意味着我无法从程序中显示 windows。

这甚至可以通过一个简单的 'only load an image' 程序获得。

相反,现有的基于 Java 的应用程序 运行 很高兴,而同一台机器上的 b运行d 新用户则没有问题。

移动我所有帐户的 .与 b运行d 新用户相比,文件和日志记录 out/in,并检查我的环境变量是否有可疑之处都没有效果。

我不知道为什么会发生这种情况,但这与之前遭受本机崩溃直接相关:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x0000000131099b1b, pid=11165, tid=4867
#
# JRE version: Java(TM) SE Runtime Environment (8.0_31-b13) (build 1.8.0_31-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.31-b07 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libtesseract.dylib+0x156b1b]  ELIST::length() const+0x5
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/tim/git/t4jhack/hs_err_pid11165.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

因为我刚刚又触发了,问题立马复活了

应用崩溃显示

AppMain quit unexpectedly.
Click reopen to open the application again.
This report will be sent to Apple automatically
[show details] [OK] [Reopen]

我点击了不同的 'OK' 和 'Reopen' - 都是问题所在。

我偶然发现的'fix':

在系统偏好设置中,打开 Java 控制面板,它会显示:

The last time you opened Java, it unexpectedly quit while reopening windows.
Do you want to try to reopen its windows again?
If you choose not to reopen windows, you may have to open and
position the windows yourself.
[don't reopen] [reopen]

你想要 'Reopen',然后就可以得到结果 window。