--- old/make/copy/Copy-java.desktop.gmk 2015-02-12 20:06:05.561133700 +0400 +++ new/make/copy/Copy-java.desktop.gmk 2015-02-12 20:06:05.401133500 +0400 @@ -100,34 +100,3 @@ TARGETS += $(PSFONTPROPFILE_TARGET_FILES) ################################################################################ -# -# Copy cursor.properties and cursors gif files to LIB_DST_DIR -# -ifneq ($(OPENJDK_TARGET_OS), macosx) - OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/conf -else - OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/macosx/conf -endif - -CURSORS_DEST_DIR := $(LIB_DST_DIR)/images/cursors -CURSORS_OPENJDK_TARGET_OS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/conf/images/cursors - -$(CURSORS_DEST_DIR)/cursors.properties: $(CURSORS_OPENJDK_TARGET_OS_LIB_SRC)/cursors.properties - $(call install-file) - -TARGETS += $(CURSORS_DEST_DIR)/cursors.properties - -CURSORS_LIB_SRC := $(JDK_TOPDIR)/src/java.desktop/share/conf/images/cursors -ifeq ($(OPENJDK_TARGET_OS), windows) - CURSORS_SRC_FILES := $(CURSORS_LIB_SRC)/invalid32x32.gif $(wildcard $(CURSORS_LIB_SRC)/win32_*.gif) -else # OPENJDK_TARGET_OS - CURSORS_SRC_FILES := $(CURSORS_LIB_SRC)/invalid32x32.gif $(wildcard $(CURSORS_LIB_SRC)/motif_*.gif) -endif # OPENJDK_TARGET_OS -CURSORS_TARGET_FILES := $(subst $(CURSORS_LIB_SRC),$(CURSORS_DEST_DIR),$(CURSORS_SRC_FILES)) - -$(CURSORS_DEST_DIR)/%: $(CURSORS_LIB_SRC)/% - $(call install-file) - -TARGETS += $(CURSORS_TARGET_FILES) - -################################################################################ --- old/make/gensrc/Gensrc-java.desktop.gmk 2015-02-12 20:06:07.061135800 +0400 +++ new/make/gensrc/Gensrc-java.desktop.gmk 2015-02-12 20:06:06.901135600 +0400 @@ -66,8 +66,11 @@ PROP_SRC_DIRS += $(JDK_TOPDIR)/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/resources endif +PROP_SRC_FILES := $(filter-out %cursors.properties, \ + $(filter %.properties, $(call CacheFind, $(PROP_SRC_DIRS)))) + $(eval $(call SetupCompileProperties,COMPILE_PROPERTIES, \ - $(filter %.properties, $(call CacheFind, $(PROP_SRC_DIRS))), ListResourceBundle)) + $(PROP_SRC_FILES), ListResourceBundle)) GENSRC_JAVA_DESKTOP += $(COMPILE_PROPERTIES) --- old/src/java.desktop/share/classes/java/awt/Cursor.java 2015-02-12 20:06:08.591138000 +0400 +++ new/src/java.desktop/share/classes/java/awt/Cursor.java 2015-02-12 20:06:08.421137700 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -24,18 +24,17 @@ */ package java.awt; -import java.io.File; -import java.io.FileInputStream; - import java.beans.ConstructorProperties; +import java.io.InputStream; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; import java.util.Hashtable; import java.util.Properties; import java.util.StringTokenizer; -import java.security.AccessController; - -import sun.util.logging.PlatformLogger; import sun.awt.AWTAccessor; +import sun.util.logging.PlatformLogger; /** * A class to encapsulate the bitmap representation of the mouse cursor. @@ -160,21 +159,12 @@ public static final int CUSTOM_CURSOR = -1; /* - * hashtable, filesystem dir prefix, filename, and properties for custom cursors support + * hashtable, resource prefix, filename, and properties for custom cursors + * support */ - private static final Hashtable systemCustomCursors = new Hashtable<>(1); - private static final String systemCustomCursorDirPrefix = initCursorDir(); - - private static String initCursorDir() { - String jhome = java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("java.home")); - return jhome + - File.separator + "lib" + File.separator + "images" + - File.separator + "cursors" + File.separator; - } - - private static final String systemCustomCursorPropertiesFile = systemCustomCursorDirPrefix + "cursors.properties"; + private static final String resourcePrefix = "/sun/awt/resources/cursors/"; + private static final String propertiesFile = resourcePrefix + "cursors.properties"; private static Properties systemCustomCursorProperties = null; @@ -320,9 +310,8 @@ final String fileName = systemCustomCursorProperties.getProperty(key); - String localized = systemCustomCursorProperties.getProperty(prefix + DotNameSuffix); - - if (localized == null) localized = name; + final String localized = systemCustomCursorProperties.getProperty( + prefix + DotNameSuffix, name); String hotspot = systemCustomCursorProperties.getProperty(prefix + DotHotspotSuffix); @@ -334,31 +323,25 @@ if (st.countTokens() != 2) throw new AWTException("failed to parse hotspot property for cursor: " + name); - int x = 0; - int y = 0; - + final Point hotPoint; try { - x = Integer.parseInt(st.nextToken()); - y = Integer.parseInt(st.nextToken()); + hotPoint = new Point(Integer.parseInt(st.nextToken()), + Integer.parseInt(st.nextToken())); } catch (NumberFormatException nfe) { throw new AWTException("failed to parse hotspot property for cursor: " + name); } try { - final int fx = x; - final int fy = y; - final String flocalized = localized; - - cursor = java.security.AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Cursor run() throws Exception { - Toolkit toolkit = Toolkit.getDefaultToolkit(); - Image image = toolkit.getImage( - systemCustomCursorDirPrefix + fileName); - return toolkit.createCustomCursor( - image, new Point(fx,fy), flocalized); - } - }); + final Toolkit toolkit = Toolkit.getDefaultToolkit(); + final String file = resourcePrefix + fileName; + + cursor = AccessController.doPrivileged( + (PrivilegedExceptionAction) () -> { + URL url = Cursor.class.getResource(file); + Image image = toolkit.getImage(url); + return toolkit.createCustomCursor(image, hotPoint, + localized); + }); } catch (Exception e) { throw new AWTException( "Exception: " + e.getClass() + " " + e.getMessage() + @@ -452,26 +435,24 @@ systemCustomCursorProperties = new Properties(); try { - AccessController.doPrivileged( - new java.security.PrivilegedExceptionAction() { - public Object run() throws Exception { - FileInputStream fis = null; - try { - fis = new FileInputStream( - systemCustomCursorPropertiesFile); - systemCustomCursorProperties.load(fis); - } finally { - if (fis != null) - fis.close(); - } - return null; - } - }); + AccessController.doPrivileged( + (PrivilegedExceptionAction) () -> { + InputStream fis = null; + try { + fis = Cursor.class.getResourceAsStream( + propertiesFile); + systemCustomCursorProperties.load(fis); + } finally { + if (fis != null) + fis.close(); + } + return null; + }); } catch (Exception e) { systemCustomCursorProperties = null; throw new AWTException("Exception: " + e.getClass() + " " + e.getMessage() + " occurred while loading: " + - systemCustomCursorPropertiesFile); + propertiesFile); } } } Binary files old/src/java.desktop/share/conf/images/cursors/invalid32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/motif_CopyDrop32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/motif_CopyNoDrop32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/motif_LinkDrop32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/motif_LinkNoDrop32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/motif_MoveDrop32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/motif_MoveNoDrop32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/win32_CopyDrop32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/win32_CopyNoDrop32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/win32_LinkDrop32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/win32_LinkNoDrop32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/win32_MoveDrop32x32.gif and /dev/null differ Binary files old/src/java.desktop/share/conf/images/cursors/win32_MoveNoDrop32x32.gif and /dev/null differ --- old/src/java.desktop/unix/conf/images/cursors/cursors.properties 2015-02-12 20:06:20.421154500 +0400 +++ /dev/null 2015-02-12 20:06:20.000000000 +0400 @@ -1,40 +0,0 @@ -# -# -# Cursors Properties file -# -# Names GIF89 sources for Custom Cursors and their associated HotSpots -# -# Note: the syntax of the property name is significant and is parsed -# by java.awt.Cursor -# -# The syntax is: Cursor...File= -# Cursor...HotSpot=, -# Cursor...Name= -# -Cursor.CopyDrop.32x32.File=motif_CopyDrop32x32.gif -Cursor.CopyDrop.32x32.HotSpot=0,0 -Cursor.CopyDrop.32x32.Name=CopyDrop32x32 -# -Cursor.MoveDrop.32x32.File=motif_MoveDrop32x32.gif -Cursor.MoveDrop.32x32.HotSpot=0,0 -Cursor.MoveDrop.32x32.Name=MoveDrop32x32 -# -Cursor.LinkDrop.32x32.File=motif_LinkDrop32x32.gif -Cursor.LinkDrop.32x32.HotSpot=0,0 -Cursor.LinkDrop.32x32.Name=LinkDrop32x32 -# -Cursor.CopyNoDrop.32x32.File=motif_CopyNoDrop32x32.gif -Cursor.CopyNoDrop.32x32.HotSpot=6,2 -Cursor.CopyNoDrop.32x32.Name=CopyNoDrop32x32 -# -Cursor.MoveNoDrop.32x32.File=motif_MoveNoDrop32x32.gif -Cursor.MoveNoDrop.32x32.HotSpot=6,2 -Cursor.MoveNoDrop.32x32.Name=MoveNoDrop32x32 -# -Cursor.LinkNoDrop.32x32.File=motif_LinkNoDrop32x32.gif -Cursor.LinkNoDrop.32x32.HotSpot=6,2 -Cursor.LinkNoDrop.32x32.Name=LinkNoDrop32x32 -# -Cursor.Invalid.32x32.File=invalid32x32.gif -Cursor.Invalid.32x32.HotSpot=6,2 -Cursor.Invalid.32x32.Name=Invalid32x32 --- old/src/java.desktop/windows/conf/images/cursors/cursors.properties 2015-02-12 20:06:21.241155700 +0400 +++ /dev/null 2015-02-12 20:06:21.000000000 +0400 @@ -1,40 +0,0 @@ -# -# -# Cursors Properties file -# -# Names GIF89 sources for Custom Cursors and their associated HotSpots -# -# Note: the syntax of the property name is significant and is parsed -# by java.awt.Cursor -# -# The syntax is: Cursor...File=win32_ -# Cursor...HotSpot=, -# Cursor...Name= -# -Cursor.CopyDrop.32x32.File=win32_CopyDrop32x32.gif -Cursor.CopyDrop.32x32.HotSpot=0,0 -Cursor.CopyDrop.32x32.Name=CopyDrop32x32 -# -Cursor.MoveDrop.32x32.File=win32_MoveDrop32x32.gif -Cursor.MoveDrop.32x32.HotSpot=0,0 -Cursor.MoveDrop.32x32.Name=MoveDrop32x32 -# -Cursor.LinkDrop.32x32.File=win32_LinkDrop32x32.gif -Cursor.LinkDrop.32x32.HotSpot=0,0 -Cursor.LinkDrop.32x32.Name=LinkDrop32x32 -# -Cursor.CopyNoDrop.32x32.File=win32_CopyNoDrop32x32.gif -Cursor.CopyNoDrop.32x32.HotSpot=6,2 -Cursor.CopyNoDrop.32x32.Name=CopyNoDrop32x32 -# -Cursor.MoveNoDrop.32x32.File=win32_MoveNoDrop32x32.gif -Cursor.MoveNoDrop.32x32.HotSpot=6,2 -Cursor.MoveNoDrop.32x32.Name=MoveNoDrop32x32 -# -Cursor.LinkNoDrop.32x32.File=win32_LinkNoDrop32x32.gif -Cursor.LinkNoDrop.32x32.HotSpot=6,2 -Cursor.LinkNoDrop.32x32.Name=LinkNoDrop32x32 -# -Cursor.Invalid.32x32.File=invalid32x32.gif -Cursor.Invalid.32x32.HotSpot=6,2 -Cursor.Invalid.32x32.Name=Invalid32x32 Binary files old/src/java.desktop/share/conf/images/cursors/motif_CopyDrop32x32.gif and /dev/null differ Binary files /dev/null and new/src/java.desktop/share/classes/sun/awt/resources/cursors/CopyDrop32x32.gif differ Binary files old/src/java.desktop/share/conf/images/cursors/motif_LinkDrop32x32.gif and /dev/null differ Binary files /dev/null and new/src/java.desktop/share/classes/sun/awt/resources/cursors/LinkDrop32x32.gif differ Binary files old/src/java.desktop/share/conf/images/cursors/motif_MoveDrop32x32.gif and /dev/null differ Binary files /dev/null and new/src/java.desktop/share/classes/sun/awt/resources/cursors/MoveDrop32x32.gif differ --- old/src/java.desktop/unix/conf/images/cursors/cursors.properties 2015-02-12 20:06:24.691160500 +0400 +++ /dev/null 2015-02-12 20:06:24.000000000 +0400 @@ -1,40 +0,0 @@ -# -# -# Cursors Properties file -# -# Names GIF89 sources for Custom Cursors and their associated HotSpots -# -# Note: the syntax of the property name is significant and is parsed -# by java.awt.Cursor -# -# The syntax is: Cursor...File= -# Cursor...HotSpot=, -# Cursor...Name= -# -Cursor.CopyDrop.32x32.File=motif_CopyDrop32x32.gif -Cursor.CopyDrop.32x32.HotSpot=0,0 -Cursor.CopyDrop.32x32.Name=CopyDrop32x32 -# -Cursor.MoveDrop.32x32.File=motif_MoveDrop32x32.gif -Cursor.MoveDrop.32x32.HotSpot=0,0 -Cursor.MoveDrop.32x32.Name=MoveDrop32x32 -# -Cursor.LinkDrop.32x32.File=motif_LinkDrop32x32.gif -Cursor.LinkDrop.32x32.HotSpot=0,0 -Cursor.LinkDrop.32x32.Name=LinkDrop32x32 -# -Cursor.CopyNoDrop.32x32.File=motif_CopyNoDrop32x32.gif -Cursor.CopyNoDrop.32x32.HotSpot=6,2 -Cursor.CopyNoDrop.32x32.Name=CopyNoDrop32x32 -# -Cursor.MoveNoDrop.32x32.File=motif_MoveNoDrop32x32.gif -Cursor.MoveNoDrop.32x32.HotSpot=6,2 -Cursor.MoveNoDrop.32x32.Name=MoveNoDrop32x32 -# -Cursor.LinkNoDrop.32x32.File=motif_LinkNoDrop32x32.gif -Cursor.LinkNoDrop.32x32.HotSpot=6,2 -Cursor.LinkNoDrop.32x32.Name=LinkNoDrop32x32 -# -Cursor.Invalid.32x32.File=invalid32x32.gif -Cursor.Invalid.32x32.HotSpot=6,2 -Cursor.Invalid.32x32.Name=Invalid32x32 --- /dev/null 2015-02-12 20:06:24.000000000 +0400 +++ new/src/java.desktop/share/classes/sun/awt/resources/cursors/cursors.properties 2015-02-12 20:06:24.511160300 +0400 @@ -0,0 +1,40 @@ +# +# +# Cursors Properties file +# +# Names GIF89 sources for Custom Cursors and their associated HotSpots +# +# Note: the syntax of the property name is significant and is parsed +# by java.awt.Cursor +# +# The syntax is: Cursor...File= +# Cursor...HotSpot=, +# Cursor...Name= +# +Cursor.CopyDrop.32x32.File=CopyDrop32x32.gif +Cursor.CopyDrop.32x32.HotSpot=0,0 +Cursor.CopyDrop.32x32.Name=CopyDrop32x32 +# +Cursor.MoveDrop.32x32.File=MoveDrop32x32.gif +Cursor.MoveDrop.32x32.HotSpot=0,0 +Cursor.MoveDrop.32x32.Name=MoveDrop32x32 +# +Cursor.LinkDrop.32x32.File=LinkDrop32x32.gif +Cursor.LinkDrop.32x32.HotSpot=0,0 +Cursor.LinkDrop.32x32.Name=LinkDrop32x32 +# +Cursor.CopyNoDrop.32x32.File=invalid32x32.gif +Cursor.CopyNoDrop.32x32.HotSpot=6,2 +Cursor.CopyNoDrop.32x32.Name=CopyNoDrop32x32 +# +Cursor.MoveNoDrop.32x32.File=invalid32x32.gif +Cursor.MoveNoDrop.32x32.HotSpot=6,2 +Cursor.MoveNoDrop.32x32.Name=MoveNoDrop32x32 +# +Cursor.LinkNoDrop.32x32.File=invalid32x32.gif +Cursor.LinkNoDrop.32x32.HotSpot=6,2 +Cursor.LinkNoDrop.32x32.Name=LinkNoDrop32x32 +# +Cursor.Invalid.32x32.File=invalid32x32.gif +Cursor.Invalid.32x32.HotSpot=6,2 +Cursor.Invalid.32x32.Name=Invalid32x32 Binary files old/src/java.desktop/share/conf/images/cursors/win32_CopyNoDrop32x32.gif and /dev/null differ Binary files /dev/null and new/src/java.desktop/share/classes/sun/awt/resources/cursors/invalid32x32.gif differ Binary files old/src/java.desktop/share/conf/images/cursors/win32_CopyDrop32x32.gif and /dev/null differ Binary files /dev/null and new/src/java.desktop/windows/classes/sun/awt/resources/cursors/CopyDrop32x32.gif differ Binary files old/src/java.desktop/share/conf/images/cursors/win32_LinkDrop32x32.gif and /dev/null differ Binary files /dev/null and new/src/java.desktop/windows/classes/sun/awt/resources/cursors/LinkDrop32x32.gif differ Binary files old/src/java.desktop/share/conf/images/cursors/win32_MoveDrop32x32.gif and /dev/null differ Binary files /dev/null and new/src/java.desktop/windows/classes/sun/awt/resources/cursors/MoveDrop32x32.gif differ --- /dev/null 2015-02-12 20:06:29.000000000 +0400 +++ new/test/java/awt/Cursor/GetSystemCustomCursor/GetSystemCustomCursor.java 2015-02-12 20:06:29.571167300 +0400 @@ -0,0 +1,46 @@ +/* + * 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. + */ + +import java.awt.AWTException; +import java.awt.Cursor; + +/** + * @test + * @bug 8039269 + * @author Sergey Bylokhov + */ +public final class GetSystemCustomCursor { + + public static void main(final String[] args) throws AWTException { + // This list is copied from cursors.properties + String[] names = {"CopyDrop.32x32", "MoveDrop.32x32", "LinkDrop.32x32", + "CopyNoDrop.32x32", "MoveNoDrop.32x32", + "LinkNoDrop.32x32", "Invalid.32x32"}; + for (final String name : names) { + if (Cursor.getSystemCustomCursor(name) == null) { + throw new RuntimeException("Cursor is null: " + name); + } + } + System.out.println("Test passed"); + } +}