changeset 26011:0fa4f1bd2843

8051588: DataTransferer.getInstance throws ClassCastException in headless mode Reviewed-by: serb, alexsch
author pchelko
date Mon, 28 Jul 2014 19:11:52 +0400
parents 9a3cf8ee0776
children 36ecb579dbc8
files jdk/src/share/classes/sun/awt/ComponentFactory.java jdk/src/share/classes/sun/awt/HeadlessToolkit.java jdk/src/share/classes/sun/awt/SunToolkit.java jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java
diffstat 4 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/share/classes/sun/awt/ComponentFactory.java	Mon Jul 28 19:02:56 2014 +0400
+++ b/jdk/src/share/classes/sun/awt/ComponentFactory.java	Mon Jul 28 19:11:52 2014 +0400
@@ -25,6 +25,8 @@
 
 package sun.awt;
 
+import sun.awt.datatransfer.DataTransferer;
+
 import java.awt.*;
 import java.awt.dnd.*;
 import java.awt.dnd.peer.DragSourceContextPeer;
@@ -93,4 +95,6 @@
     RobotPeer createRobot(Robot target, GraphicsDevice screen)
         throws AWTException, HeadlessException;
 
+    DataTransferer getDataTransferer();
+
 }
--- a/jdk/src/share/classes/sun/awt/HeadlessToolkit.java	Mon Jul 28 19:02:56 2014 +0400
+++ b/jdk/src/share/classes/sun/awt/HeadlessToolkit.java	Mon Jul 28 19:11:52 2014 +0400
@@ -25,6 +25,8 @@
 
 package sun.awt;
 
+import sun.awt.datatransfer.DataTransferer;
+
 import java.awt.*;
 import java.awt.dnd.*;
 import java.awt.dnd.peer.DragSourceContextPeer;
@@ -402,6 +404,11 @@
         return null;
     }
 
+    @Override
+    public DataTransferer getDataTransferer() {
+        return null;
+    }
+
     @SuppressWarnings("deprecation")
     public FontMetrics getFontMetrics(Font font) {
         return tk.getFontMetrics(font);
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java	Mon Jul 28 19:02:56 2014 +0400
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java	Mon Jul 28 19:11:52 2014 +0400
@@ -203,8 +203,6 @@
 
     public abstract boolean isTraySupported();
 
-    public abstract DataTransferer getDataTransferer();
-
     @SuppressWarnings("deprecation")
     public abstract FontPeer getFontPeer(String name, int style);
 
--- a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Mon Jul 28 19:02:56 2014 +0400
+++ b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Mon Jul 28 19:11:52 2014 +0400
@@ -74,6 +74,7 @@
 import sun.datatransfer.DataFlavorUtil;
 
 import sun.awt.AppContext;
+import sun.awt.ComponentFactory;
 import sun.awt.SunToolkit;
 
 import java.awt.image.BufferedImage;
@@ -177,7 +178,7 @@
      * instead, null will be returned.
      */
     public static synchronized DataTransferer getInstance() {
-        return ((SunToolkit) Toolkit.getDefaultToolkit()).getDataTransferer();
+        return ((ComponentFactory) Toolkit.getDefaultToolkit()).getDataTransferer();
     }
 
     /**