提交 34ec043a 编写于 作者: R rupashka

6461173: One JCK test([NewFolderAction0001]) failed on Windows due to lack of PropertyPermission(s)

Reviewed-by: peterz, malenkov
上级 a766d790
......@@ -37,6 +37,8 @@ import java.util.Vector;
import java.lang.ref.WeakReference;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.awt.shell.*;
......@@ -718,8 +720,13 @@ class WindowsFileSystemView extends FileSystemView {
return isFileSystemRoot(dir);
}
public boolean isFloppyDrive(File dir) {
String path = dir.getAbsolutePath();
public boolean isFloppyDrive(final File dir) {
String path = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return dir.getAbsolutePath();
}
});
return (path != null && (path.equals("A:\\") || path.equals("B:\\")));
}
......
......@@ -73,12 +73,7 @@ final class Win32ShellFolder2 extends ShellFolder {
private static native void initIDs();
private static final boolean is98;
static {
String osName = System.getProperty("os.name");
is98 = (osName != null && osName.startsWith("Windows 98"));
initIDs();
}
......@@ -305,7 +300,6 @@ final class Win32ShellFolder2 extends ShellFolder {
}, RuntimeException.class)
);
this.disposer.relativePIDL = relativePIDL;
getAbsolutePath();
sun.java2d.Disposer.addRecord(this, disposer);
}
......@@ -616,11 +610,8 @@ final class Win32ShellFolder2 extends ShellFolder {
public boolean isDirectory() {
if (isDir == null) {
// Folders with SFGAO_BROWSABLE have "shell extension" handlers and are
// not traversable in JFileChooser. An exception is "My Documents" on
// Windows 98.
if (hasAttribute(ATTRIB_FOLDER)
&& (!hasAttribute(ATTRIB_BROWSABLE) ||
(is98 && equals(Win32ShellFolderManager2.getPersonal())))) {
// not traversable in JFileChooser.
if (hasAttribute(ATTRIB_FOLDER) && !hasAttribute(ATTRIB_BROWSABLE)) {
isDir = Boolean.TRUE;
} else if (isLink()) {
ShellFolder linkLocation = getLinkLocation(false);
......
......@@ -105,9 +105,11 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
private static Win32ShellFolder2 network;
private static Win32ShellFolder2 personal;
private static String osVersion = System.getProperty("os.version");
private static final boolean useShell32Icons =
(osVersion != null && osVersion.compareTo("5.1") >= 0);
private static final boolean USE_SHELL32_ICONS = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
public Boolean run() {
return OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) >= 0;
}
});
static Win32ShellFolder2 getDesktop() {
if (desktop == null) {
......@@ -307,15 +309,15 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
i = Integer.parseInt(name);
} catch (NumberFormatException ex) {
if (name.equals("ListView")) {
i = (useShell32Icons) ? 21 : 2;
i = (USE_SHELL32_ICONS) ? 21 : 2;
} else if (name.equals("DetailsView")) {
i = (useShell32Icons) ? 23 : 3;
i = (USE_SHELL32_ICONS) ? 23 : 3;
} else if (name.equals("UpFolder")) {
i = (useShell32Icons) ? 28 : 8;
i = (USE_SHELL32_ICONS) ? 28 : 8;
} else if (name.equals("NewFolder")) {
i = (useShell32Icons) ? 31 : 11;
i = (USE_SHELL32_ICONS) ? 31 : 11;
} else if (name.equals("ViewMenu")) {
i = (useShell32Icons) ? 21 : 2;
i = (USE_SHELL32_ICONS) ? 21 : 2;
}
}
if (i >= 0) {
......@@ -352,11 +354,16 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
* Does <code>dir</code> represent a "computer" such as a node on the network, or
* "My Computer" on the desktop.
*/
public boolean isComputerNode(File dir) {
public boolean isComputerNode(final File dir) {
if (dir != null && dir == getDrives()) {
return true;
} else {
String path = dir.getAbsolutePath();
String path = AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return dir.getAbsolutePath();
}
});
return (path.startsWith("\\\\") && path.indexOf("\\", 2) < 0); //Network path
}
}
......@@ -501,7 +508,7 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
// thread, we don't need to delegate the task
return task.call();
} else {
Future<T> future;
final Future<T> future;
try {
future = submit(task);
......@@ -512,7 +519,13 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
try {
return future.get();
} catch (InterruptedException e) {
future.cancel(true);
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
future.cancel(true);
return null;
}
});
throw e;
} catch (ExecutionException e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册