changeset 9939:1952706b45c0

8051588: DataTransferer.getInstance throws ClassCastException in headless mode Reviewed-by: serb, alexsch
author pchelko
date Wed, 27 Aug 2014 18:49:12 +0400
parents 02b9bba22dab
children eec42b39b081
files src/share/classes/sun/awt/ComponentFactory.java src/share/classes/sun/awt/HeadlessToolkit.java src/share/classes/sun/awt/SunToolkit.java src/share/classes/sun/awt/datatransfer/DataTransferer.java
diffstat 4 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/awt/ComponentFactory.java	Tue Aug 26 15:55:35 2014 +0400
+++ b/src/share/classes/sun/awt/ComponentFactory.java	Wed Aug 27 18:49:12 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/src/share/classes/sun/awt/HeadlessToolkit.java	Tue Aug 26 15:55:35 2014 +0400
+++ b/src/share/classes/sun/awt/HeadlessToolkit.java	Wed Aug 27 18:49:12 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;
@@ -401,6 +403,11 @@
         return null;
     }
 
+    @Override
+    public DataTransferer getDataTransferer() {
+        return null;
+    }
+
     @SuppressWarnings("deprecation")
     public FontMetrics getFontMetrics(Font font) {
         return tk.getFontMetrics(font);
--- a/src/share/classes/sun/awt/SunToolkit.java	Tue Aug 26 15:55:35 2014 +0400
+++ b/src/share/classes/sun/awt/SunToolkit.java	Wed Aug 27 18:49:12 2014 +0400
@@ -205,8 +205,6 @@
 
     public abstract boolean isTraySupported();
 
-    public abstract DataTransferer getDataTransferer();
-
     @SuppressWarnings("deprecation")
     public abstract FontPeer getFontPeer(String name, int style);
 
--- a/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Tue Aug 26 15:55:35 2014 +0400
+++ b/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Wed Aug 27 18:49:12 2014 +0400
@@ -86,6 +86,7 @@
 import java.util.TreeMap;
 import java.util.TreeSet;
 
+import sun.awt.ComponentFactory;
 import sun.util.logging.PlatformLogger;
 
 import sun.awt.AppContext;
@@ -272,7 +273,7 @@
      * instead, null will be returned.
      */
     public static synchronized DataTransferer getInstance() {
-        return ((SunToolkit) Toolkit.getDefaultToolkit()).getDataTransferer();
+        return ((ComponentFactory) Toolkit.getDefaultToolkit()).getDataTransferer();
     }
 
     /**