--- old/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java 2015-05-25 17:34:31.432106200 +0300 +++ new/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java 2015-05-25 17:34:30.915157900 +0300 @@ -29,6 +29,7 @@ import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.util.*; import java.util.concurrent.*; @@ -1129,6 +1130,8 @@ private static final int LVCFMT_CENTER = 2; public ShellFolderColumnInfo[] getFolderColumns() { + ShellFolder library = resolveLibrary(this); + if (library != null) return library.getFolderColumns(); return invoke(new Callable() { public ShellFolderColumnInfo[] call() { ShellFolderColumnInfo[] columns = doGetColumnInfo(getIShellFolder()); @@ -1159,6 +1162,10 @@ } public Object getFolderColumnValue(final int column) { + if(isFileSystem()) { + ShellFolder library = resolveLibrary(this); + if (library != null) return library.getFolderColumnValue(column); + } return invoke(new Callable() { public Object call() { return doGetColumnValue(getParentIShellFolder(), getRelativePIDL(), column); @@ -1166,6 +1173,21 @@ }); } + private static ShellFolder resolveLibrary(ShellFolder folder) { + for (ShellFolder f = folder; f != null; f = f.parent) { + if (!f.isFileSystem()) { + if(f.getPath() != null && "Library".equals(f.getFolderType())) { + try { + return getShellFolder(new File(folder.getPath())); + } catch (FileNotFoundException e) { + } + } + break; + } + } + return null; + } + // NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details private native ShellFolderColumnInfo[] doGetColumnInfo(long iShellFolder2); --- /dev/null 2015-05-25 17:34:34.000000000 +0300 +++ new/test/java/awt/FileDialog/8017487/bug8017487.java 2015-05-25 17:34:33.774871900 +0300 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + @bug 8017487 + @summary filechooser in Windows-Libraries folder: columns are mixed up + @author Semyon Sadetsky + @library /lib/testlibrary + @build jdk.testlibrary.OSInfo + @run main bug8017487 + */ + + +import jdk.testlibrary.OSInfo; + +import sun.awt.shell.ShellFolder; +import sun.awt.shell.ShellFolderColumnInfo; +import javax.swing.filechooser.FileSystemView; +import java.io.File; + +public class bug8017487 +{ + public static void main(String[] p_args) throws Exception { + if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS && + OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_VISTA) > 0 ) { + test(); + System.out.println("ok"); + } + } + + private static void test() throws Exception { + FileSystemView fsv = FileSystemView.getFileSystemView(); + File def = new File(fsv.getDefaultDirectory().getAbsolutePath()); + ShellFolderColumnInfo[] defColumns = + ShellFolder.getShellFolder(def).getFolderColumns(); + + File[] files = fsv.getHomeDirectory().listFiles(); + for (File file : files) { + if( "Libraries".equals(ShellFolder.getShellFolder( file ).getDisplayName())) { + File[] libs = file.listFiles(); + for (File lib : libs) { + ShellFolder libFolder = + ShellFolder.getShellFolder(lib); + if( "Library".equals(libFolder.getFolderType() ) ) { + ShellFolderColumnInfo[] folderColumns = + libFolder.getFolderColumns(); + + for (int i = 0; i < defColumns.length; i++) { + if (!defColumns[i].getTitle() + .equals(folderColumns[i].getTitle())) + throw new RuntimeException("Columnn " + + folderColumns[i].getTitle() + + " doesn't match " + + defColumns[i].getTitle()); + } + } + } + } + } + } + +}