java - 使用 Intellij 运行时 Desktop.getDesktop() 会使 JVM 崩溃

标签 java intellij-idea jvm jvm-crash

考虑这个代码片段:

import java.awt.*;
import java.io.*;

public class V
{
    public static void main(String[] args)
    {
        if (Desktop.isDesktopSupported())
            try
            {
                Desktop.getDesktop().open(new File("C:\\")); //Or any file/folder
            } catch (IOException ex)
            {
                ex.printStackTrace();
            }
    }
}

如果我通过命令提示符编译并运行它,它可以正常工作并按预期打开文件夹。

但是,如果我随后打开同一个类并通过 Intellij 运行它,则会导致 JVM 崩溃。

即出现此屏幕

enter image description here

错误详细信息

Problem signature:
  Problem Event Name:   BEX
  Application Name: java.exe
  Application Version:  7.0.210.11
  Application Timestamp:    515d68ea
  Fault Module Name:    StackHash_d4e2
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp:   00000000
  Exception Offset: 6a2e6363
  Exception Code:   c0000005
  Exception Data:   00000008
  OS Version:   6.1.7601.2.1.0.256.48
  Locale ID:    5129
  Additional Information 1: d4e2
  Additional Information 2: d4e23849915837b7cd6589c72ebf3a65    
  Additional Information 3: 4c98
  Additional Information 4: 4c989ca1785510040bc407d74228ddb4

hs_err_pidxxxx.log 文件生成此内容

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x4d81ff08, pid=7584, tid=3460
#
# JRE version: 7.0_21-b11
# Java VM: Java HotSpot(TM) Client VM (23.21-b01 mixed mode windows-x86 )
# Problematic frame:
# C  0x4d81ff08
#

---------------  T H R E A D  ---------------

Current thread (0x498af400):  JavaThread "Swing-Shell" daemon [_thread_in_native, id=3460, stack(0x4d550000,0x4d5a0000)]

.
.
.

Stack: [0x4d550000,0x4d5a0000],  sp=0x4d59e9d0,  free space=314k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  0x4d81ff08

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  sun.awt.shell.Win32ShellFolder2.compareIDsByColumn(JJJI)I+0
j  sun.awt.shell.Win32ShellFolder2.access$3300(JJJI)I+6
j  sun.awt.shell.Win32ShellFolder2$ColumnComparator$1.call()Ljava/lang/Integer;+54
j  sun.awt.shell.Win32ShellFolder2$ColumnComparator$1.call()Ljava/lang/Object;+1
J  java.util.concurrent.FutureTask$Sync.innerRun()V
J  java.util.concurrent.FutureTask.run()V
j      java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/concurrent/ThreadPoolExecutor$Worker;)V+95
j  java.util.concurrent.ThreadPoolExecutor$Worker.run()V+5
j  sun.awt.shell.Win32ShellFolderManager2$ComInvoker$3.run()V+7
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub

如果有用的话可以添加更多。

最佳答案

请尝试升级到版本 7 更新 51。跟踪器存在一些有关崩溃的问题。

一般来说,如果您的 JVM 崩溃并且您部署的代码不使用 native 库,请先尝试升级。

关于java - 使用 Intellij 运行时 Desktop.getDesktop() 会使 JVM 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22341464/

相关文章:

java - eclipse java资源泄漏

java - 制作可运行的 jar 时图像不导出

java - JVM——新生代和老年代的比例/分配

java - 文件存在时抛出 FileNotFoundException。文件名可能包含特殊字符

android - 阻止 ADB 输出显示在 Android Studio 中

java - Kotlin 初始化一个对象

java - Connect 4 Java Win 条件检查

java - 连接到 Firebird 数据库时出现错误 "Insufficient memory to allocate page buffer cache"

java - IntelliJ 提示 "for statement does not loop"?

intellij-idea - 如何将 Android Studio 安装到 IntelliJ 中?