8195624: Desktop API cannot be used without permission to read "os.version"
Reviewed-by: prr
--- a/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java Wed May 30 21:30:05 2018 -0700
+++ b/src/java.desktop/windows/classes/sun/awt/windows/WDesktopPeer.java Wed May 30 22:03:12 2018 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2018, 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
@@ -25,7 +25,6 @@
package sun.awt.windows;
-
import java.awt.Desktop.Action;
import java.awt.EventQueue;
import java.awt.desktop.SystemEventListener;
@@ -38,9 +37,8 @@
import java.io.File;
import java.io.IOException;
import java.net.URI;
+
import javax.swing.event.EventListenerList;
-import sun.awt.OSInfo;
-
/**
* Concrete implementation of the interface {@code DesktopPeer} for
@@ -49,19 +47,15 @@
* @see DesktopPeer
*/
final class WDesktopPeer implements DesktopPeer {
- /* Contants for the operation verbs */
+ /* Constants for the operation verbs */
private static String ACTION_OPEN_VERB = "open";
private static String ACTION_EDIT_VERB = "edit";
private static String ACTION_PRINT_VERB = "print";
- private static boolean isEventUserSessionSupported = false;
-
private static native void init();
WDesktopPeer() {
init();
- isEventUserSessionSupported = OSInfo.getWindowsVersion()
- .compareTo(OSInfo.WINDOWS_VISTA) >= 0;
}
@Override
@@ -75,9 +69,8 @@
case MOVE_TO_TRASH:
case APP_SUDDEN_TERMINATION:
case APP_EVENT_SYSTEM_SLEEP:
+ case APP_EVENT_USER_SESSION:
return true;
- case APP_EVENT_USER_SESSION:
- return isEventUserSessionSupported;
default:
return false;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/Desktop/DefaultPermissions/DefaultPermissions.java Wed May 30 22:03:12 2018 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2018, 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.
+ */
+
+import java.awt.Desktop;
+
+/**
+ * @test
+ * @bug 8195624
+ * @summary Desktop.getDesktop() should work without permissions
+ * @run main/othervm/policy=java.policy -Djava.security.manager DefaultPermissions
+ */
+public final class DefaultPermissions {
+
+ public static void main(final String[] args) {
+ if (Desktop.isDesktopSupported()) {
+ Desktop.getDesktop();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/Desktop/DefaultPermissions/java.policy Wed May 30 22:03:12 2018 -0700
@@ -0,0 +1,1 @@
+;
\ No newline at end of file