JFileChooser Win32ShellFolder2 pid

Hello,

I'm frequently experiencing a jvm crash two different winXP machines.

This happens when I open a JFileChooser instrumented with a FileSystemView.

The problem is both on jdk1.5.0_10 and on the new jdk1.6.0 final.

Googling around it seems that this is a quite common problem of the jdk on windows.

Here's an extract of the PID logs I get:

#

# An unexpected error has been detected by HotSpot Virtual Machine:

#

# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=412, tid=1392

#

# Java VM: Java HotSpot(TM) Client VM (1.5.0_10-b03 mixed mode)

# Problematic frame:

# C 0x00000000

#

T H R E A D

Current thread (0x439348e0): JavaThread"AWT-EventQueue-0" [_thread_in_native, id=1392]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:

EAX=0x0015cfb8, EBX=0x45c1e768, ECX=0x0015d1e0, EDX=0x45c1e738

ESP=0x45c1e71c, EBP=0x45c1e75c, ESI=0x774b1a4c, EDI=0x45c1e758

EIP=0x00000000, EFLAGS=0x00010246

Top of Stack: (sp=0x45c1e71c)

0x45c1e71c:774fe75f 0015cfb8 774fe778 45c1e738

0x45c1e72c:45c1e73c 00000000 774b1a60 774fe49d

0x45c1e73c:00000000 00000000 45c1edc4 00000000

0x45c1e74c:00000000 00000000 00000000 0000a390

0x45c1e75c:45c1ef04 774ff1fb 45c1e768 774b4928

0x45c1e76c:774b45f8 774b45e8 00000001 00000338

0x45c1e77c:00000000 000000c0 46000000 00000000

0x45c1e78c:00000000 00000001 00000000 00000000

Instructions: (pc=0x00000000)

0xfffffff0:

Stack: [0x45b20000,0x45c20000), sp=0x45c1e71c, free space=1017k

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)

j sun.awt.shell.Win32ShellFolder2.getNextChild(J)J+0

j sun.awt.shell.Win32ShellFolder2.listFiles(Z)[Ljava/io/File;+82

j sun.awt.shell.ShellFolder.listFiles()[Ljava/io/File;+2

j sun.awt.shell.Win32ShellFolderManager2.get(Ljava/lang/String;)Ljava/lang/Object;+181

j sun.awt.shell.ShellFolder.get(Ljava/lang/String;)Ljava/lang/Object;+4

j javax.swing.plaf.metal.MetalFileChooserUI.updateUseShellFolder()V+55

j javax.swing.plaf.metal.MetalFileChooserUI.installComponents(Ljavax/swing/JFileChooser;)V+67

j javax.swing.plaf.basic.BasicFileChooserUI.installUI(Ljavax/swing/JComponent;)V+47

j javax.swing.plaf.metal.MetalFileChooserUI.installUI(Ljavax/swing/JComponent;)V+2

j javax.swing.JComponent.setUI(Ljavax/swing/plaf/ComponentUI;)V+42

j javax.swing.JFileChooser.updateUI()V+40

j javax.swing.JFileChooser.setup(Ljavax/swing/filechooser/FileSystemView;)V+73

j javax.swing.JFileChooser.<init>(Ljava/io/File;Ljavax/swing/filechooser/FileSystemView;)V+133

j javax.swing.JFileChooser.<init>()V+9

#

# An unexpected error has been detected by HotSpot Virtual Machine:

#

# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=1532, tid=1228

#

# Java VM: Java HotSpot(TM) Client VM (1.5.0_10-b03 mixed mode)

# Problematic frame:

# C 0x00000000

#

T H R E A D

Current thread (0x439348e0): JavaThread"AWT-EventQueue-0" [_thread_in_native, id=1228]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:

EAX=0x0015ce88, EBX=0x45c1e70c, ECX=0x0015d0b0, EDX=0x45c1e6dc

ESP=0x45c1e6c0, EBP=0x45c1e700, ESI=0x774b1a4c, EDI=0x45c1e6fc

EIP=0x00000000, EFLAGS=0x00010246

Top of Stack: (sp=0x45c1e6c0)

0x45c1e6c0:774fe75f 0015ce88 774fe778 45c1e6dc

0x45c1e6d0:45c1e6e0 00000000 774b1a60 774fe49d

0x45c1e6e0:00000000 00000000 45c1ed68 00000000

0x45c1e6f0:00000000 00000000 00000000 000092da

0x45c1e700:45c1eea8 774ff1fb 45c1e70c 774b4928

0x45c1e710:774b45f8 774b45e8 00000001 00000338

0x45c1e720:00000000 000000c0 46000000 00000000

0x45c1e730:00000000 00000001 00000000 00000000

Instructions: (pc=0x00000000)

0xfffffff0:

Stack: [0x45b20000,0x45c20000), sp=0x45c1e6c0, free space=1017k

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)

j sun.awt.shell.Win32ShellFolder2.getNextChild(J)J+0

j sun.awt.shell.Win32ShellFolder2.listFiles(Z)[Ljava/io/File;+82

j sun.awt.shell.ShellFolder.listFiles()[Ljava/io/File;+2

j sun.awt.shell.Win32ShellFolderManager2.get(Ljava/lang/String;)Ljava/lang/Object;+181

j sun.awt.shell.ShellFolder.get(Ljava/lang/String;)Ljava/lang/Object;+4

j javax.swing.plaf.metal.MetalFileChooserUI.updateUseShellFolder()V+55

j javax.swing.plaf.metal.MetalFileChooserUI.installComponents(Ljavax/swing/JFileChooser;)V+67

j javax.swing.plaf.basic.BasicFileChooserUI.installUI(Ljavax/swing/JComponent;)V+47

j javax.swing.plaf.metal.MetalFileChooserUI.installUI(Ljavax/swing/JComponent;)V+2

j javax.swing.JComponent.setUI(Ljavax/swing/plaf/ComponentUI;)V+42

j javax.swing.JFileChooser.updateUI()V+40

j javax.swing.JFileChooser.setup(Ljavax/swing/filechooser/FileSystemView;)V+73

j javax.swing.JFileChooser.<init>(Ljava/io/File;Ljavax/swing/filechooser/FileSystemView;)V+133

j javax.swing.JFileChooser.<init>()V+9

#

# An unexpected error has been detected by Java Runtime Environment:

#

# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00000000, pid=3912, tid=648

#

# Java VM: Java HotSpot(TM) Client VM (1.6.0-b105 mixed mode)

# Problematic frame:

# C 0x00000000

#

# If you would like to submit a bug report, please visit:

#http://java.sun.com/webapps/bugreport/crash.jsp

#

T H R E A D

Current thread (0x43ab3000): JavaThread"AWT-EventQueue-0" [_thread_in_native, id=648]

siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

Registers:

EAX=0x0015c810, EBX=0x45cadab8, ECX=0x0015ca38, EDX=0x45cada88

ESP=0x45cada6c, EBP=0x45cadaac, ESI=0x774b1a4c, EDI=0x45cadaa8

EIP=0x00000000, EFLAGS=0x00010246

Top of Stack: (sp=0x45cada6c)

0x45cada6c:774fc07a 0015c810 774bc4e8 45cada88

0x45cada7c:45cada8c 00000000 774b1a60 774fbdb8

0x45cada8c:00000000 00000000 45cae114 00000000

0x45cada9c:00000000 00000000 00000000 00002ec5

0x45cadaac:45cae254 774fcae5 45cadab8 774bca10

0x45cadabc:774bc6e0 774bc6d0 00000001 00000338

0x45cadacc:00000000 000000c0 46000000 00000000

0x45cadadc:00000000 00000001 00000000 00000000

Instructions: (pc=0x00000000)

0xfffffff0:

Stack: [0x45bb0000,0x45cb0000), sp=0x45cada6c, free space=1014k

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)

j sun.awt.shell.Win32ShellFolder2.getDisplayNameOf(JJI)Ljava/lang/String;+0

j sun.awt.shell.Win32ShellFolder2.getFileSystemPath(JJ)Ljava/lang/String;+66

j sun.awt.shell.Win32ShellFolder2.<init>(Lsun/awt/shell/Win32ShellFolder2;J)V+7

j sun.awt.shell.Win32ShellFolder2.listFiles(Z)[Ljava/io/File;+171

j sun.awt.shell.ShellFolder.listFiles()[Ljava/io/File;+2

j sun.awt.shell.Win32ShellFolderManager2.get(Ljava/lang/String;)Ljava/lang/Object;+181

j sun.awt.shell.ShellFolder.get(Ljava/lang/String;)Ljava/lang/Object;+4

j javax.swing.plaf.metal.MetalFileChooserUI.updateUseShellFolder()V+55

j javax.swing.plaf.metal.MetalFileChooserUI.installComponents(Ljavax/swing/JFileChooser;)V+67

j javax.swing.plaf.basic.BasicFileChooserUI.installUI(Ljavax/swing/JComponent;)V+47

j javax.swing.plaf.metal.MetalFileChooserUI.installUI(Ljavax/swing/JComponent;)V+2

J javax.swing.JComponent.setUI(Ljavax/swing/plaf/ComponentUI;)V

j javax.swing.JFileChooser.updateUI()V+40

j javax.swing.JFileChooser.setup(Ljavax/swing/filechooser/FileSystemView;)V+18

j javax.swing.JFileChooser.<init>(Ljava/io/File;Ljavax/swing/filechooser/FileSystemView;)V+133

j javax.swing.JFileChooser.<init>()V+9

Can someone please give me a hint on how to avoid that bad crashes ?

Cheers,

Mik

[8218 byte] By [Mika] at [2007-11-26 14:35:43]
# 1

Your error seems very similar to mine, http://forum.java.sun.com/thread.jspa?threadID=5118746&messageID=9411204#9411204

It抯 a very weird error. But I think I抳e sorted it. I抣l talk you through, shall I?

Ok, first I defined a single global JFileChooser like this:

// The open file chooser

private JFileChooser chooser = new JFileChooser();

Before, I had a local one for each method that uses the file chooser.

Then at the end of the method were the chooser is use, take my open() for example, I reset all the values that had changed. I抣l show you what I mean.

public void open() throws

FileNotFoundException,IOException,ClassNotFoundException

{

// Can't choose all

chooser.setAcceptAllFileFilterUsed(false);

// Set mutable selection

chooser.setMultiSelectionEnabled(true);

// Add the file fiter

chooser.addChoosableFileFilter(new Track.TrackFilter());

// Add the track list filter

chooser.addChoosableFileFilter(new TrackListFilter());

// If the show result it accept

if (chooser.showOpenDialog(null)==JFileChooser.APPROVE_OPTION)

{

// . . .

}

// Reset for next time around

chooser.setSelectedFile(null);

chooser.setCurrentDirectory(null);

chooser.resetChoosableFileFilters();

}

Note at the top of the method, I have added a couple file filters, and at the bottom, I reset them. I also reset the selected file and current directory.

The current directory and selected file are changed in the showOpenDialog() and so must be reset.

I don抰 know you have to reset them, but it seems you have to.

Also note, if you are using a FileView, you properly have to reset that to null at the bottom as well. The same might apply to any other attribute you change.

Please try out these ideas and see if they work for you.

Luke

dfgstga at 2007-7-8 8:16:38 > top of Java-index,Desktop,Core GUI APIs...
# 2

Thanks Luke,

sadly your mods can't be applied to my case, as

1) the crash happens just before the JFileChooser shows.

2) I create a new "fresh" JFileChooser each time.

I've searched in the bug database and it seems there's a lot of work and fixes to do for the JFC-Swing folks around the JFileChooser, still on JDK6.0.

The problem is that I'll have to explain my customers to be careful when selecting a file from disk as it may crash the application.. :-(

I don't want to flame here, but there's a MAJOR problem with the JfileChooser on windows and I would like to get it fixed asap..

Cheers,

Mik

--

Mika at 2007-7-8 8:16:38 > top of Java-index,Desktop,Core GUI APIs...
# 3

Has anyone else been seeing this or figured out a way to stop it from happening? I've been experiencing the same problem throughout my application everywhere that I create JFileChooser objects. I pretty much have the exact same crash report as the other two posters here. I've also noticed that it happens on the second or third time I open a JFileChooser object. I've tried to create a simple test case that will reproduce the problem but haven't been able to. Any insight would be greatly appreciated.

SStephensona at 2007-7-8 8:16:38 > top of Java-index,Desktop,Core GUI APIs...