2332N/A/*
2362N/A * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
2332N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2332N/A *
2332N/A * This code is free software; you can redistribute it and/or modify it
2332N/A * under the terms of the GNU General Public License version 2 only, as
2332N/A * published by the Free Software Foundation.
2332N/A *
2332N/A * This code is distributed in the hope that it will be useful, but WITHOUT
2332N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2332N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2332N/A * version 2 for more details (a copy is included in the LICENSE file that
2332N/A * accompanied this code).
2332N/A *
2332N/A * You should have received a copy of the GNU General Public License version
2332N/A * 2 along with this work; if not, write to the Free Software Foundation,
2332N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2332N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
2332N/A */
2332N/A
2332N/A/* @test
2332N/A @bug 6945316
2332N/A @summary The Win32ShellFolderManager2.isFileSystemRoot can throw NPE
2332N/A @author Pavel Porvatov
2332N/A @run main bug6945316
2332N/A*/
2332N/A
2332N/Aimport sun.awt.OSInfo;
2332N/Aimport sun.awt.shell.ShellFolder;
2332N/A
2332N/Aimport java.awt.*;
2332N/Aimport java.io.File;
2332N/Aimport java.util.concurrent.CountDownLatch;
2332N/A
2332N/Apublic class bug6945316 {
2332N/A public static void main(String[] args) throws Exception {
2332N/A if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
2332N/A System.out.println("The test is suitable only for Windows OS. Skipped.");
2332N/A
2332N/A return;
2332N/A }
2332N/A
2332N/A // Init toolkit because it shouldn't be interrupted while initialization
2332N/A Toolkit.getDefaultToolkit();
2332N/A
2332N/A // Init the sun.awt.shell.Win32ShellFolderManager2.drives field
2332N/A ShellFolder.get("fileChooserComboBoxFolders");
2332N/A
2332N/A // To get NPE the path must obey the following rules:
2332N/A // path.length() == 3 && path.charAt(1) == ':'
2332N/A final File tempFile = new File("c:\\");
2332N/A
2332N/A for (int i = 0; i < 10000; i++) {
2332N/A final CountDownLatch countDownLatch = new CountDownLatch(1);
2332N/A
2332N/A final Thread thread = new Thread() {
2332N/A public void run() {
2332N/A countDownLatch.countDown();
2332N/A
2332N/A ShellFolder.isFileSystemRoot(tempFile);
2332N/A }
2332N/A };
2332N/A
2332N/A thread.start();
2332N/A
2332N/A countDownLatch.await();
2332N/A
2332N/A thread.interrupt();
2332N/A }
2332N/A }
2332N/A}