--- old/src/java.desktop/share/classes/java/awt/Cursor.java 2015-05-27 15:41:13.000000000 +0300
+++ new/src/java.desktop/share/classes/java/awt/Cursor.java 2015-05-27 15:41:12.000000000 +0300
@@ -25,9 +25,10 @@
package java.awt;
import java.beans.ConstructorProperties;
+import java.io.ByteArrayOutputStream;
import java.io.InputStream;
-import java.net.URL;
import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import java.util.Hashtable;
import java.util.Properties;
@@ -261,7 +262,7 @@
* @throws IllegalArgumentException if the specified cursor type is
* invalid
*/
- static public Cursor getPredefinedCursor(int type) {
+ public static Cursor getPredefinedCursor(int type) {
if (type < Cursor.DEFAULT_CURSOR || type > Cursor.MOVE_CURSOR) {
throw new IllegalArgumentException("illegal cursor type");
}
@@ -286,7 +287,7 @@
* GraphicsEnvironment.isHeadless
returns true
* @exception AWTException in case of erroneous retrieving of the cursor
*/
- static public Cursor getSystemCustomCursor(final String name)
+ public static Cursor getSystemCustomCursor(final String name)
throws AWTException, HeadlessException {
GraphicsEnvironment.checkHeadless();
Cursor cursor = systemCustomCursors.get(name);
@@ -330,18 +331,17 @@
} catch (NumberFormatException nfe) {
throw new AWTException("failed to parse hotspot property for cursor: " + name);
}
-
- try {
- final Toolkit toolkit = Toolkit.getDefaultToolkit();
- final String file = RESOURCE_PREFIX + fileName;
-
- cursor = AccessController.doPrivileged(
- (PrivilegedExceptionAction) () -> {
- URL url = Cursor.class.getResource(file);
- Image image = toolkit.getImage(url);
- return toolkit.createCustomCursor(image, hotPoint,
- localized);
- });
+ final Toolkit toolkit = Toolkit.getDefaultToolkit();
+ final String file = RESOURCE_PREFIX + fileName;
+ final InputStream in = AccessController.doPrivileged(
+ (PrivilegedAction) () -> {
+ return Cursor.class.getResourceAsStream(file);
+ });
+ try (in) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ in.transferTo(baos);
+ Image image = toolkit.createImage(baos.toByteArray());
+ cursor = toolkit.createCustomCursor(image, hotPoint, localized);
} catch (Exception e) {
throw new AWTException(
"Exception: " + e.getClass() + " " + e.getMessage() +
@@ -365,7 +365,7 @@
*
* @return the default cursor
*/
- static public Cursor getDefaultCursor() {
+ public static Cursor getDefaultCursor() {
return getPredefinedCursor(Cursor.DEFAULT_CURSOR);
}