changeset 11804:414010b5ab83

8074757: Remove java.awt.Toolkit methods which return peer types Reviewed-by: alanb, prr, ant
author serb
date Fri, 17 Apr 2015 17:01:24 +0300
parents e1888730a57e
children a5c091b8bee9
files src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java src/java.desktop/share/classes/java/awt/Button.java src/java.desktop/share/classes/java/awt/Canvas.java src/java.desktop/share/classes/java/awt/Checkbox.java src/java.desktop/share/classes/java/awt/CheckboxMenuItem.java src/java.desktop/share/classes/java/awt/Choice.java src/java.desktop/share/classes/java/awt/Component.java src/java.desktop/share/classes/java/awt/Desktop.java src/java.desktop/share/classes/java/awt/Dialog.java src/java.desktop/share/classes/java/awt/FileDialog.java src/java.desktop/share/classes/java/awt/Font.java src/java.desktop/share/classes/java/awt/Frame.java src/java.desktop/share/classes/java/awt/Label.java src/java.desktop/share/classes/java/awt/List.java src/java.desktop/share/classes/java/awt/Menu.java src/java.desktop/share/classes/java/awt/MenuBar.java src/java.desktop/share/classes/java/awt/MenuComponent.java src/java.desktop/share/classes/java/awt/MenuItem.java src/java.desktop/share/classes/java/awt/MouseInfo.java src/java.desktop/share/classes/java/awt/Panel.java src/java.desktop/share/classes/java/awt/PopupMenu.java src/java.desktop/share/classes/java/awt/ScrollPane.java src/java.desktop/share/classes/java/awt/Scrollbar.java src/java.desktop/share/classes/java/awt/TextArea.java src/java.desktop/share/classes/java/awt/TextField.java src/java.desktop/share/classes/java/awt/Toolkit.java src/java.desktop/share/classes/java/awt/Window.java src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java src/java.desktop/share/classes/sun/awt/ComponentFactory.java src/java.desktop/share/classes/sun/awt/HToolkit.java src/java.desktop/share/classes/sun/awt/HeadlessToolkit.java src/java.desktop/share/classes/sun/awt/SunToolkit.java src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java test/java/awt/Toolkit/DynamicLayout/bug7172833.java test/java/awt/Toolkit/Headless/ExceptionContract/ExceptionContract.java
diffstat 36 files changed, 766 insertions(+), 1100 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -293,7 +293,7 @@
     }
 
     @Override
-    protected DesktopPeer createDesktopPeer(Desktop target) {
+    public DesktopPeer createDesktopPeer(Desktop target) {
         return new CDesktopPeer();
     }
 
@@ -575,7 +575,8 @@
 
         final boolean[] ret = new boolean[1];
 
-        try {  invokeAndWait(new Runnable() { public void run() { synchronized(ret) {
+        try {  invokeAndWait(new Runnable() { @Override
+                                              public void run() { synchronized(ret) {
             ret[0] = a.equals(b);
         }}}, c); } catch (Exception e) { e.printStackTrace(); }
 
--- a/src/java.desktop/share/classes/java/awt/Button.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Button.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -168,13 +168,12 @@
      * application to change the look of the button without changing
      * its functionality.
      *
-     * @see     java.awt.Toolkit#createButton(java.awt.Button)
      * @see     java.awt.Component#getToolkit()
      */
     public void addNotify() {
         synchronized(getTreeLock()) {
             if (peer == null)
-                peer = getToolkit().createButton(this);
+                peer = getComponentFactory().createButton(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/Canvas.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Canvas.java	Fri Apr 17 17:01:24 2015 +0300
@@ -93,13 +93,12 @@
     /**
      * Creates the peer of the canvas.  This peer allows you to change the
      * user interface of the canvas without changing its functionality.
-     * @see     java.awt.Toolkit#createCanvas(java.awt.Canvas)
      * @see     java.awt.Component#getToolkit()
      */
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = getToolkit().createCanvas(this);
+                peer = getComponentFactory().createCanvas(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/Checkbox.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Checkbox.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -239,13 +239,12 @@
      * Creates the peer of the Checkbox. The peer allows you to change the
      * look of the Checkbox without changing its functionality.
      *
-     * @see     java.awt.Toolkit#createCheckbox(java.awt.Checkbox)
      * @see     java.awt.Component#getToolkit()
      */
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = getToolkit().createCheckbox(this);
+                peer = getComponentFactory().createCheckbox(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/CheckboxMenuItem.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/CheckboxMenuItem.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -155,13 +155,12 @@
      * change the look of the checkbox item without changing its
      * functionality.
      * Most applications do not call this method directly.
-     * @see     java.awt.Toolkit#createCheckboxMenuItem(java.awt.CheckboxMenuItem)
      * @see     java.awt.Component#getToolkit()
      */
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = Toolkit.getDefaultToolkit().createCheckboxMenuItem(this);
+                peer = getComponentFactory().createCheckboxMenuItem(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/Choice.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Choice.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -143,13 +143,12 @@
      * Creates the <code>Choice</code>'s peer.  This peer allows us
      * to change the look
      * of the <code>Choice</code> without changing its functionality.
-     * @see     java.awt.Toolkit#createChoice(java.awt.Choice)
      * @see     java.awt.Component#getToolkit()
      */
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = getToolkit().createChoice(this);
+                peer = getComponentFactory().createChoice(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/Component.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Component.java	Fri Apr 17 17:01:24 2015 +0300
@@ -61,6 +61,7 @@
 import javax.accessibility.*;
 import java.applet.Applet;
 
+import sun.awt.ComponentFactory;
 import sun.security.action.GetPropertyAction;
 import sun.awt.AppContext;
 import sun.awt.AWTAccessor;
@@ -1229,6 +1230,14 @@
         return Toolkit.getDefaultToolkit();
     }
 
+    final ComponentFactory getComponentFactory() {
+        final Toolkit toolkit = getToolkit();
+        if (toolkit instanceof ComponentFactory) {
+            return (ComponentFactory) toolkit;
+        }
+        throw new AWTError("UI components are unsupported by: " + toolkit);
+    }
+
     /**
      * Determines whether this component is valid. A component is valid
      * when it is correctly sized and positioned within its parent
@@ -1326,7 +1335,11 @@
             return null;
         }
         Window win = getContainingWindow();
-        if (!Toolkit.getDefaultToolkit().getMouseInfoPeer().isWindowUnderMouse(win)) {
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        if (!(toolkit instanceof ComponentFactory)) {
+            return null;
+        }
+        if (!((ComponentFactory) toolkit).getMouseInfoPeer().isWindowUnderMouse(win)) {
             return null;
         }
         final boolean INCLUDE_DISABLED = true;
@@ -6961,7 +6974,7 @@
                 if (peer == null) {
                     // Update both the Component's peer variable and the local
                     // variable we use for thread safety.
-                    this.peer = peer = getToolkit().createComponent(this);
+                    this.peer = peer = getComponentFactory().createComponent(this);
                 }
 
                 // This is a lightweight component which means it won't be
--- a/src/java.desktop/share/classes/java/awt/Desktop.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Desktop.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -25,19 +25,16 @@
 
 package java.awt;
 
+import java.awt.peer.DesktopPeer;
 import java.io.File;
+import java.io.FilePermission;
 import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URISyntaxException;
-import java.net.URI;
 import java.net.URL;
-import java.net.MalformedURLException;
-import java.awt.AWTPermission;
-import java.awt.GraphicsEnvironment;
-import java.awt.HeadlessException;
-import java.awt.peer.DesktopPeer;
+
 import sun.awt.SunToolkit;
-import sun.awt.HeadlessToolkit;
-import java.io.FilePermission;
 import sun.security.util.SecurityConstants;
 
 /**
@@ -122,7 +119,11 @@
      * Suppresses default constructor for noninstantiability.
      */
     private Desktop() {
-        peer = Toolkit.getDefaultToolkit().createDesktopPeer(this);
+        Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
+        // same cast as in isDesktopSupported()
+        if (defaultToolkit instanceof SunToolkit) {
+            peer = ((SunToolkit) defaultToolkit).createDesktopPeer(this);
+        }
     }
 
     /**
--- a/src/java.desktop/share/classes/java/awt/Dialog.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Dialog.java	Fri Apr 17 17:01:24 2015 +0300
@@ -754,7 +754,7 @@
             }
 
             if (peer == null) {
-                peer = getToolkit().createDialog(this);
+                peer = getComponentFactory().createDialog(this);
             }
             super.addNotify();
         }
--- a/src/java.desktop/share/classes/java/awt/FileDialog.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/FileDialog.java	Fri Apr 17 17:01:24 2015 +0300
@@ -320,7 +320,7 @@
                 parent.addNotify();
             }
             if (peer == null)
-                peer = getToolkit().createFileDialog(this);
+                peer = getComponentFactory().createFileDialog(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/Font.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Font.java	Fri Apr 17 17:01:24 2015 +0300
@@ -44,6 +44,8 @@
 import java.util.Hashtable;
 import java.util.Locale;
 import java.util.Map;
+
+import sun.awt.ComponentFactory;
 import sun.font.StandardGlyphVector;
 
 import sun.font.AttributeMap;
@@ -442,11 +444,12 @@
      *
      * @return the peer of the {@code Font}.
      */
-    @SuppressWarnings("deprecation")
     private FontPeer getFontPeer() {
         if(peer == null) {
             Toolkit tk = Toolkit.getDefaultToolkit();
-            peer = tk.getFontPeer(name, style);
+            if (tk instanceof ComponentFactory) {
+                peer = ((ComponentFactory) tk).getFontPeer(name, style);
+            }
         }
         return peer;
     }
--- a/src/java.desktop/share/classes/java/awt/Frame.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Frame.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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,21 +24,23 @@
  */
 package java.awt;
 
+import java.awt.event.KeyEvent;
+import java.awt.event.WindowEvent;
 import java.awt.peer.FramePeer;
-import java.awt.event.*;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
 import java.util.Vector;
-import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
-import java.io.IOException;
-import sun.awt.AppContext;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+
+import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
-import sun.awt.AWTAccessor;
-import java.lang.ref.WeakReference;
-import javax.accessibility.*;
 
 /**
  * A <code>Frame</code> is a top-level window with a title and a border.
@@ -474,7 +476,7 @@
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null) {
-                peer = getToolkit().createFrame(this);
+                peer = getComponentFactory().createFrame(this);
             }
             FramePeer p = (FramePeer)peer;
             MenuBar menuBar = this.menuBar;
--- a/src/java.desktop/share/classes/java/awt/Label.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Label.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -184,7 +184,7 @@
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = getToolkit().createLabel(this);
+                peer = getComponentFactory().createLabel(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/List.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/List.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -252,7 +252,7 @@
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = getToolkit().createList(this);
+                peer = getComponentFactory().createList(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/Menu.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Menu.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -174,7 +174,7 @@
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = Toolkit.getDefaultToolkit().createMenu(this);
+                peer = getComponentFactory().createMenu(this);
             int nitems = getItemCount();
             for (int i = 0 ; i < nitems ; i++) {
                 MenuItem mi = getItem(i);
--- a/src/java.desktop/share/classes/java/awt/MenuBar.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/MenuBar.java	Fri Apr 17 17:01:24 2015 +0300
@@ -143,7 +143,7 @@
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = Toolkit.getDefaultToolkit().createMenuBar(this);
+                peer = getComponentFactory().createMenuBar(this);
 
             int nmenus = getMenuCount();
             for (int i = 0 ; i < nmenus ; i++) {
--- a/src/java.desktop/share/classes/java/awt/MenuComponent.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/MenuComponent.java	Fri Apr 17 17:01:24 2015 +0300
@@ -30,6 +30,8 @@
 import java.io.ObjectInputStream;
 import sun.awt.AppContext;
 import sun.awt.AWTAccessor;
+import sun.awt.ComponentFactory;
+
 import javax.accessibility.*;
 
 import java.security.AccessControlContext;
@@ -184,6 +186,14 @@
                      // getName()
     }
 
+    final ComponentFactory getComponentFactory() {
+        final Toolkit toolkit = Toolkit.getDefaultToolkit();
+        if (toolkit instanceof ComponentFactory) {
+            return (ComponentFactory) toolkit;
+        }
+        throw new AWTError("UI components are unsupported by: " + toolkit);
+    }
+
     /**
      * Gets the name of the menu component.
      * @return        the name of the menu component
--- a/src/java.desktop/share/classes/java/awt/MenuItem.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/MenuItem.java	Fri Apr 17 17:01:24 2015 +0300
@@ -233,7 +233,7 @@
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = Toolkit.getDefaultToolkit().createMenuItem(this);
+                peer = getComponentFactory().createMenuItem(this);
         }
     }
 
--- a/src/java.desktop/share/classes/java/awt/MouseInfo.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/MouseInfo.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -26,6 +26,7 @@
 package java.awt;
 
 import sun.awt.AWTPermissions;
+import sun.awt.ComponentFactory;
 
 /**
  * <code>MouseInfo</code>  provides methods for getting information about the mouse,
@@ -80,8 +81,13 @@
             security.checkPermission(AWTPermissions.WATCH_MOUSE_PERMISSION);
         }
 
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
         Point point = new Point(0, 0);
-        int deviceNum = Toolkit.getDefaultToolkit().getMouseInfoPeer().fillPointWithCoords(point);
+        int deviceNum = 0;
+        if (toolkit instanceof ComponentFactory) {
+            deviceNum = ((ComponentFactory) toolkit).getMouseInfoPeer().fillPointWithCoords(point);
+        }
+
         GraphicsDevice[] gds = GraphicsEnvironment.getLocalGraphicsEnvironment().
                                    getScreenDevices();
         PointerInfo retval = null;
--- a/src/java.desktop/share/classes/java/awt/Panel.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Panel.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -83,7 +83,7 @@
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = getToolkit().createPanel(this);
+                peer = getComponentFactory().createPanel(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/PopupMenu.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/PopupMenu.java	Fri Apr 17 17:01:24 2015 +0300
@@ -121,7 +121,7 @@
             }
             else {
                 if (peer == null)
-                    peer = Toolkit.getDefaultToolkit().createPopupMenu(this);
+                    peer = getComponentFactory().createPopupMenu(this);
                 int nitems = getItemCount();
                 for (int i = 0 ; i < nitems ; i++) {
                     MenuItem mi = getItem(i);
--- a/src/java.desktop/share/classes/java/awt/ScrollPane.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/ScrollPane.java	Fri Apr 17 17:01:24 2015 +0300
@@ -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,7 +24,6 @@
  */
 package java.awt;
 
-import java.awt.peer.LightweightPeer;
 import java.awt.peer.ScrollPanePeer;
 import java.awt.event.*;
 import javax.accessibility.*;
@@ -562,7 +561,7 @@
             }
 
             if (peer == null)
-                peer = getToolkit().createScrollPane(this);
+                peer = getComponentFactory().createScrollPane(this);
             super.addNotify();
 
             // Bug 4124460. Restore the adjustable values.
--- a/src/java.desktop/share/classes/java/awt/Scrollbar.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Scrollbar.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -433,7 +433,7 @@
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = getToolkit().createScrollbar(this);
+                peer = getComponentFactory().createScrollbar(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/TextArea.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/TextArea.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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,15 +24,15 @@
  */
 package java.awt;
 
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
 import java.awt.peer.TextAreaPeer;
-import java.io.ObjectOutputStream;
+import java.io.IOException;
 import java.io.ObjectInputStream;
-import java.io.IOException;
 import java.util.HashSet;
 import java.util.Set;
-import javax.accessibility.*;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
 
 /**
  * A <code>TextArea</code> object is a multi-line region
@@ -290,7 +290,7 @@
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = getToolkit().createTextArea(this);
+                peer = getComponentFactory().createTextArea(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/TextField.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/TextField.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -219,7 +219,7 @@
     public void addNotify() {
         synchronized (getTreeLock()) {
             if (peer == null)
-                peer = getToolkit().createTextField(this);
+                peer = getComponentFactory().createTextField(this);
             super.addNotify();
         }
     }
--- a/src/java.desktop/share/classes/java/awt/Toolkit.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Toolkit.java	Fri Apr 17 17:01:24 2015 +0300
@@ -25,36 +25,37 @@
 
 package java.awt;
 
-import java.beans.PropertyChangeEvent;
+import java.awt.datatransfer.Clipboard;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
 import java.awt.event.*;
-import java.awt.peer.*;
 import java.awt.im.InputMethodHighlight;
+import java.awt.image.ColorModel;
 import java.awt.image.ImageObserver;
 import java.awt.image.ImageProducer;
-import java.awt.image.ColorModel;
-import java.awt.datatransfer.Clipboard;
-import java.awt.dnd.DragSource;
-import java.awt.dnd.DragGestureRecognizer;
-import java.awt.dnd.DragGestureEvent;
-import java.awt.dnd.DragGestureListener;
-import java.awt.dnd.InvalidDnDOperationException;
-import java.awt.dnd.peer.DragSourceContextPeer;
-import java.net.URL;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
 import java.io.File;
 import java.io.FileInputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.EventListener;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.StringTokenizer;
+import java.util.WeakHashMap;
 
-import java.util.*;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
+import sun.awt.AWTAccessor;
+import sun.awt.AWTPermissions;
 import sun.awt.AppContext;
-
 import sun.awt.HeadlessToolkit;
-import sun.awt.NullComponentPeer;
 import sun.awt.PeerEvent;
 import sun.awt.SunToolkit;
-import sun.awt.AWTAccessor;
-import sun.awt.AWTPermissions;
-
 import sun.util.CoreResourceBundleControl;
 
 /**
@@ -112,341 +113,6 @@
  */
 public abstract class Toolkit {
 
-    /**
-     * Creates this toolkit's implementation of the <code>Desktop</code>
-     * using the specified peer interface.
-     * @param     target the desktop to be implemented
-     * @return    this toolkit's implementation of the <code>Desktop</code>
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.Desktop
-     * @see       java.awt.peer.DesktopPeer
-     * @since 1.6
-     */
-    protected abstract DesktopPeer createDesktopPeer(Desktop target)
-      throws HeadlessException;
-
-
-    /**
-     * Creates this toolkit's implementation of <code>Button</code> using
-     * the specified peer interface.
-     * @param     target the button to be implemented.
-     * @return    this toolkit's implementation of <code>Button</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.Button
-     * @see       java.awt.peer.ButtonPeer
-     */
-    protected abstract ButtonPeer createButton(Button target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>TextField</code> using
-     * the specified peer interface.
-     * @param     target the text field to be implemented.
-     * @return    this toolkit's implementation of <code>TextField</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.TextField
-     * @see       java.awt.peer.TextFieldPeer
-     */
-    protected abstract TextFieldPeer createTextField(TextField target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>Label</code> using
-     * the specified peer interface.
-     * @param     target the label to be implemented.
-     * @return    this toolkit's implementation of <code>Label</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.Label
-     * @see       java.awt.peer.LabelPeer
-     */
-    protected abstract LabelPeer createLabel(Label target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>List</code> using
-     * the specified peer interface.
-     * @param     target the list to be implemented.
-     * @return    this toolkit's implementation of <code>List</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.List
-     * @see       java.awt.peer.ListPeer
-     */
-    protected abstract ListPeer createList(java.awt.List target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>Checkbox</code> using
-     * the specified peer interface.
-     * @param     target the check box to be implemented.
-     * @return    this toolkit's implementation of <code>Checkbox</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.Checkbox
-     * @see       java.awt.peer.CheckboxPeer
-     */
-    protected abstract CheckboxPeer createCheckbox(Checkbox target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>Scrollbar</code> using
-     * the specified peer interface.
-     * @param     target the scroll bar to be implemented.
-     * @return    this toolkit's implementation of <code>Scrollbar</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.Scrollbar
-     * @see       java.awt.peer.ScrollbarPeer
-     */
-    protected abstract ScrollbarPeer createScrollbar(Scrollbar target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>ScrollPane</code> using
-     * the specified peer interface.
-     * @param     target the scroll pane to be implemented.
-     * @return    this toolkit's implementation of <code>ScrollPane</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.ScrollPane
-     * @see       java.awt.peer.ScrollPanePeer
-     * @since     1.1
-     */
-    protected abstract ScrollPanePeer createScrollPane(ScrollPane target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>TextArea</code> using
-     * the specified peer interface.
-     * @param     target the text area to be implemented.
-     * @return    this toolkit's implementation of <code>TextArea</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.TextArea
-     * @see       java.awt.peer.TextAreaPeer
-     */
-    protected abstract TextAreaPeer createTextArea(TextArea target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>Choice</code> using
-     * the specified peer interface.
-     * @param     target the choice to be implemented.
-     * @return    this toolkit's implementation of <code>Choice</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.Choice
-     * @see       java.awt.peer.ChoicePeer
-     */
-    protected abstract ChoicePeer createChoice(Choice target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>Frame</code> using
-     * the specified peer interface.
-     * @param     target the frame to be implemented.
-     * @return    this toolkit's implementation of <code>Frame</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.Frame
-     * @see       java.awt.peer.FramePeer
-     */
-    protected abstract FramePeer createFrame(Frame target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>Canvas</code> using
-     * the specified peer interface.
-     * @param     target the canvas to be implemented.
-     * @return    this toolkit's implementation of <code>Canvas</code>.
-     * @see       java.awt.Canvas
-     * @see       java.awt.peer.CanvasPeer
-     */
-    protected abstract CanvasPeer       createCanvas(Canvas target);
-
-    /**
-     * Creates this toolkit's implementation of <code>Panel</code> using
-     * the specified peer interface.
-     * @param     target the panel to be implemented.
-     * @return    this toolkit's implementation of <code>Panel</code>.
-     * @see       java.awt.Panel
-     * @see       java.awt.peer.PanelPeer
-     */
-    protected abstract PanelPeer        createPanel(Panel target);
-
-    /**
-     * Creates this toolkit's implementation of <code>Window</code> using
-     * the specified peer interface.
-     * @param     target the window to be implemented.
-     * @return    this toolkit's implementation of <code>Window</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.Window
-     * @see       java.awt.peer.WindowPeer
-     */
-    protected abstract WindowPeer createWindow(Window target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>Dialog</code> using
-     * the specified peer interface.
-     * @param     target the dialog to be implemented.
-     * @return    this toolkit's implementation of <code>Dialog</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.Dialog
-     * @see       java.awt.peer.DialogPeer
-     */
-    protected abstract DialogPeer createDialog(Dialog target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>MenuBar</code> using
-     * the specified peer interface.
-     * @param     target the menu bar to be implemented.
-     * @return    this toolkit's implementation of <code>MenuBar</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.MenuBar
-     * @see       java.awt.peer.MenuBarPeer
-     */
-    protected abstract MenuBarPeer createMenuBar(MenuBar target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>Menu</code> using
-     * the specified peer interface.
-     * @param     target the menu to be implemented.
-     * @return    this toolkit's implementation of <code>Menu</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.Menu
-     * @see       java.awt.peer.MenuPeer
-     */
-    protected abstract MenuPeer createMenu(Menu target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>PopupMenu</code> using
-     * the specified peer interface.
-     * @param     target the popup menu to be implemented.
-     * @return    this toolkit's implementation of <code>PopupMenu</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.PopupMenu
-     * @see       java.awt.peer.PopupMenuPeer
-     * @since     1.1
-     */
-    protected abstract PopupMenuPeer createPopupMenu(PopupMenu target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>MenuItem</code> using
-     * the specified peer interface.
-     * @param     target the menu item to be implemented.
-     * @return    this toolkit's implementation of <code>MenuItem</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.MenuItem
-     * @see       java.awt.peer.MenuItemPeer
-     */
-    protected abstract MenuItemPeer createMenuItem(MenuItem target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>FileDialog</code> using
-     * the specified peer interface.
-     * @param     target the file dialog to be implemented.
-     * @return    this toolkit's implementation of <code>FileDialog</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.FileDialog
-     * @see       java.awt.peer.FileDialogPeer
-     */
-    protected abstract FileDialogPeer createFileDialog(FileDialog target)
-        throws HeadlessException;
-
-    /**
-     * Creates this toolkit's implementation of <code>CheckboxMenuItem</code> using
-     * the specified peer interface.
-     * @param     target the checkbox menu item to be implemented.
-     * @return    this toolkit's implementation of <code>CheckboxMenuItem</code>.
-     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
-     * returns true
-     * @see       java.awt.GraphicsEnvironment#isHeadless
-     * @see       java.awt.CheckboxMenuItem
-     * @see       java.awt.peer.CheckboxMenuItemPeer
-     */
-    protected abstract CheckboxMenuItemPeer createCheckboxMenuItem(
-        CheckboxMenuItem target) throws HeadlessException;
-
-    /**
-     * Obtains this toolkit's implementation of helper class for
-     * <code>MouseInfo</code> operations.
-     * @return    this toolkit's implementation of  helper for <code>MouseInfo</code>
-     * @throws    UnsupportedOperationException if this operation is not implemented
-     * @see       java.awt.peer.MouseInfoPeer
-     * @see       java.awt.MouseInfo
-     * @since 1.5
-     */
-    protected MouseInfoPeer getMouseInfoPeer() {
-        throw new UnsupportedOperationException("Not implemented");
-    }
-
-    private static LightweightPeer lightweightMarker;
-
-    /**
-     * Creates a peer for a component or container.  This peer is windowless
-     * and allows the Component and Container classes to be extended directly
-     * to create windowless components that are defined entirely in java.
-     *
-     * @param  target The Component to be created.
-     * @return the peer for the specified component
-     */
-    protected LightweightPeer createComponent(Component target) {
-        if (lightweightMarker == null) {
-            lightweightMarker = new NullComponentPeer();
-        }
-        return lightweightMarker;
-    }
-
-    /**
-     * Creates this toolkit's implementation of <code>Font</code> using
-     * the specified peer interface.
-     * @param     name the font to be implemented
-     * @param     style the style of the font, such as <code>PLAIN</code>,
-     *            <code>BOLD</code>, <code>ITALIC</code>, or a combination
-     * @return    this toolkit's implementation of <code>Font</code>
-     * @see       java.awt.Font
-     * @see       java.awt.peer.FontPeer
-     * @see       java.awt.GraphicsEnvironment#getAllFonts
-     * @deprecated  see java.awt.GraphicsEnvironment#getAllFonts
-     */
-    @Deprecated
-    protected abstract FontPeer getFontPeer(String name, int style);
-
     // The following method is called by the private method
     // <code>updateSystemColors</code> in <code>SystemColor</code>.
 
@@ -1749,17 +1415,6 @@
     }
 
     /**
-     * Creates the peer for a DragSourceContext.
-     * Always throws InvalidDndOperationException if
-     * GraphicsEnvironment.isHeadless() returns true.
-     *
-     * @param  dge the {@code DragGestureEvent}
-     * @return the peer created
-     * @see java.awt.GraphicsEnvironment#isHeadless
-     */
-    public abstract DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException;
-
-    /**
      * Creates a concrete, platform dependent, subclass of the abstract
      * DragGestureRecognizer class requested, and associates it with the
      * DragSource, Component and DragGestureListener specified.
--- a/src/java.desktop/share/classes/java/awt/Window.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/Window.java	Fri Apr 17 17:01:24 2015 +0300
@@ -760,7 +760,7 @@
                 parent.addNotify();
             }
             if (peer == null) {
-                peer = getToolkit().createWindow(this);
+                peer = getComponentFactory().createWindow(this);
             }
             synchronized (allWindows) {
                 allWindows.add(this);
--- a/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -25,6 +25,7 @@
 
 package java.awt.dnd;
 
+import java.awt.AWTError;
 import java.awt.Component;
 import java.awt.Cursor;
 import java.awt.Image;
@@ -42,6 +43,7 @@
 import java.util.TooManyListenersException;
 
 import sun.awt.AWTAccessor;
+import sun.awt.ComponentFactory;
 
 /**
  * The <code>DragSourceContext</code> class is responsible for managing the
@@ -184,8 +186,12 @@
     public DragSourceContext(DragGestureEvent trigger, Cursor dragCursor,
                              Image dragImage, Point offset, Transferable t,
                              DragSourceListener dsl) {
-        DragSourceContextPeer dscp = Toolkit.getDefaultToolkit()
-                .createDragSourceContextPeer(trigger);
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        if (!(toolkit instanceof ComponentFactory)) {
+            throw new AWTError("Unsupported toolkit: " + toolkit);
+        }
+        DragSourceContextPeer dscp = ((ComponentFactory) toolkit).
+                createDragSourceContextPeer(trigger);
 
         if (dscp == null) {
             throw new NullPointerException("DragSourceContextPeer");
--- a/src/java.desktop/share/classes/sun/awt/ComponentFactory.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/sun/awt/ComponentFactory.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -25,76 +25,421 @@
 
 package sun.awt;
 
-import sun.awt.datatransfer.DataTransferer;
-
 import java.awt.*;
-import java.awt.dnd.*;
+import java.awt.dnd.DragGestureEvent;
+import java.awt.dnd.InvalidDnDOperationException;
 import java.awt.dnd.peer.DragSourceContextPeer;
 import java.awt.peer.*;
 
+import sun.awt.datatransfer.DataTransferer;
+
+final class LightweightPeerHolder {
+    static final LightweightPeer lightweightMarker = new NullComponentPeer();
+
+    private LightweightPeerHolder() {
+    }
+}
+
 /**
- * Interface for component creation support in toolkits
+ * Interface for component creation support in toolkits.
  */
 public interface ComponentFactory {
 
-    CanvasPeer createCanvas(Canvas target) throws HeadlessException;
+    /**
+     * Creates a peer for a component or container. This peer is windowless and
+     * allows the Component and Container classes to be extended directly to
+     * create windowless components that are defined entirely in java.
+     *
+     * @param  target The Component to be created
+     * @return the peer for the specified component
+     */
+    default LightweightPeer createComponent(Component target) {
+        return LightweightPeerHolder.lightweightMarker;
+    }
 
-    PanelPeer createPanel(Panel target) throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of the {@code Desktop} using the
+     * specified peer interface.
+     *
+     * @param  target the desktop to be implemented
+     * @return this toolkit's implementation of the {@code Desktop}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.Desktop
+     * @see java.awt.peer.DesktopPeer
+     * @since 1.6
+     */
+    default DesktopPeer createDesktopPeer(Desktop target) {
+        throw new HeadlessException();
+    }
 
-    WindowPeer createWindow(Window target) throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code Button} using the
+     * specified peer interface.
+     *
+     * @param  target the button to be implemented
+     * @return this toolkit's implementation of {@code Button}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.Button
+     * @see java.awt.peer.ButtonPeer
+     */
+    default ButtonPeer createButton(Button target) {
+        throw new HeadlessException();
+    }
 
-    FramePeer createFrame(Frame target) throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code TextField} using the
+     * specified peer interface.
+     *
+     * @param  target the text field to be implemented
+     * @return this toolkit's implementation of {@code TextField}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.TextField
+     * @see java.awt.peer.TextFieldPeer
+     */
+    default TextFieldPeer createTextField(TextField target) {
+        throw new HeadlessException();
+    }
 
-    DialogPeer createDialog(Dialog target) throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code Label} using the
+     * specified peer interface.
+     *
+     * @param  target the label to be implemented
+     * @return this toolkit's implementation of {@code Label}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.Label
+     * @see java.awt.peer.LabelPeer
+     */
+    default LabelPeer createLabel(Label target) {
+        throw new HeadlessException();
+    }
 
-    ButtonPeer createButton(Button target) throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code List} using the specified
+     * peer interface.
+     *
+     * @param  target the list to be implemented
+     * @return this toolkit's implementation of {@code List}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.List
+     * @see java.awt.peer.ListPeer
+     */
+    default ListPeer createList(java.awt.List target) {
+        throw new HeadlessException();
+    }
 
-    TextFieldPeer createTextField(TextField target)
-        throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code Checkbox} using the
+     * specified peer interface.
+     *
+     * @param  target the check box to be implemented
+     * @return this toolkit's implementation of {@code Checkbox}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.Checkbox
+     * @see java.awt.peer.CheckboxPeer
+     */
+    default CheckboxPeer createCheckbox(Checkbox target) {
+        throw new HeadlessException();
+    }
 
-    ChoicePeer createChoice(Choice target) throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code Scrollbar} using the
+     * specified peer interface.
+     *
+     * @param  target the scroll bar to be implemented
+     * @return this toolkit's implementation of {@code Scrollbar}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.Scrollbar
+     * @see java.awt.peer.ScrollbarPeer
+     */
+    default ScrollbarPeer createScrollbar(Scrollbar target) {
+        throw new HeadlessException();
+    }
 
-    LabelPeer createLabel(Label target) throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code ScrollPane} using the
+     * specified peer interface.
+     *
+     * @param  target the scroll pane to be implemented
+     * @return this toolkit's implementation of {@code ScrollPane}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.ScrollPane
+     * @see java.awt.peer.ScrollPanePeer
+     * @since 1.1
+     */
+    default ScrollPanePeer createScrollPane(ScrollPane target) {
+        throw new HeadlessException();
+    }
 
-    ListPeer createList(List target) throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code TextArea} using the
+     * specified peer interface.
+     *
+     * @param  target the text area to be implemented
+     * @return this toolkit's implementation of {@code TextArea}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.TextArea
+     * @see java.awt.peer.TextAreaPeer
+     */
+    default TextAreaPeer createTextArea(TextArea target) {
+        throw new HeadlessException();
+    }
 
-    CheckboxPeer createCheckbox(Checkbox target)
-        throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code Choice} using the
+     * specified peer interface.
+     *
+     * @param  target the choice to be implemented
+     * @return this toolkit's implementation of {@code Choice}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.Choice
+     * @see java.awt.peer.ChoicePeer
+     */
+    default ChoicePeer createChoice(Choice target) {
+        throw new HeadlessException();
+    }
 
-    ScrollbarPeer createScrollbar(Scrollbar target)
-        throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code Frame} using the
+     * specified peer interface.
+     *
+     * @param  target the frame to be implemented
+     * @return this toolkit's implementation of {@code Frame}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.Frame
+     * @see java.awt.peer.FramePeer
+     */
+    default FramePeer createFrame(Frame target) {
+        throw new HeadlessException();
+    }
 
-    ScrollPanePeer createScrollPane(ScrollPane target)
-        throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code Canvas} using the
+     * specified peer interface.
+     *
+     * @param  target the canvas to be implemented
+     * @return this toolkit's implementation of {@code Canvas}
+     * @see java.awt.Canvas
+     * @see java.awt.peer.CanvasPeer
+     */
+    default CanvasPeer createCanvas(Canvas target) {
+        return (CanvasPeer) createComponent(target);
+    }
 
-    TextAreaPeer createTextArea(TextArea target)
-        throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code Panel} using the
+     * specified peer interface.
+     *
+     * @param  target the panel to be implemented
+     * @return this toolkit's implementation of {@code Panel}
+     * @see java.awt.Panel
+     * @see java.awt.peer.PanelPeer
+     */
+    default PanelPeer createPanel(Panel target) {
+        return (PanelPeer) createComponent(target);
+    }
 
-    FileDialogPeer createFileDialog(FileDialog target)
-        throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code Window} using the
+     * specified peer interface.
+     *
+     * @param  target the window to be implemented
+     * @return this toolkit's implementation of {@code Window}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.Window
+     * @see java.awt.peer.WindowPeer
+     */
+    default WindowPeer createWindow(Window target) {
+        throw new HeadlessException();
+    }
 
-    MenuBarPeer createMenuBar(MenuBar target) throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code Dialog} using the
+     * specified peer interface.
+     *
+     * @param  target the dialog to be implemented
+     * @return this toolkit's implementation of {@code Dialog}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.Dialog
+     * @see java.awt.peer.DialogPeer
+     */
+    default DialogPeer createDialog(Dialog target) {
+        throw new HeadlessException();
+    }
 
-    MenuPeer createMenu(Menu target) throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code MenuBar} using the
+     * specified peer interface.
+     *
+     * @param  target the menu bar to be implemented
+     * @return this toolkit's implementation of {@code MenuBar}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.MenuBar
+     * @see java.awt.peer.MenuBarPeer
+     */
+    default MenuBarPeer createMenuBar(MenuBar target) {
+        throw new HeadlessException();
+    }
 
-    PopupMenuPeer createPopupMenu(PopupMenu target)
-        throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code Menu} using the specified
+     * peer interface.
+     *
+     * @param  target the menu to be implemented
+     * @return this toolkit's implementation of {@code Menu}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.Menu
+     * @see java.awt.peer.MenuPeer
+     */
+    default MenuPeer createMenu(Menu target) {
+        throw new HeadlessException();
+    }
 
-    MenuItemPeer createMenuItem(MenuItem target)
-        throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code PopupMenu} using the
+     * specified peer interface.
+     *
+     * @param  target the popup menu to be implemented
+     * @return this toolkit's implementation of {@code PopupMenu}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.PopupMenu
+     * @see java.awt.peer.PopupMenuPeer
+     * @since 1.1
+     */
+    default PopupMenuPeer createPopupMenu(PopupMenu target) {
+        throw new HeadlessException();
+    }
 
-    CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
-        throws HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code MenuItem} using the
+     * specified peer interface.
+     *
+     * @param  target the menu item to be implemented
+     * @return this toolkit's implementation of {@code MenuItem}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.MenuItem
+     * @see java.awt.peer.MenuItemPeer
+     */
+    default MenuItemPeer createMenuItem(MenuItem target) {
+        throw new HeadlessException();
+    }
 
-    DragSourceContextPeer createDragSourceContextPeer(
-        DragGestureEvent dge)
-        throws InvalidDnDOperationException, HeadlessException;
+    /**
+     * Creates this toolkit's implementation of {@code FileDialog} using the
+     * specified peer interface.
+     *
+     * @param  target the file dialog to be implemented
+     * @return this toolkit's implementation of {@code FileDialog}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.FileDialog
+     * @see java.awt.peer.FileDialogPeer
+     */
+    default FileDialogPeer createFileDialog(FileDialog target) {
+        throw new HeadlessException();
+    }
 
-    FontPeer getFontPeer(String name, int style);
+    /**
+     * Creates this toolkit's implementation of {@code CheckboxMenuItem} using
+     * the specified peer interface.
+     *
+     * @param  target the checkbox menu item to be implemented
+     * @return this toolkit's implementation of {@code CheckboxMenuItem}
+     * @throws HeadlessException if GraphicsEnvironment.isHeadless() returns
+     *         true
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     * @see java.awt.CheckboxMenuItem
+     * @see java.awt.peer.CheckboxMenuItemPeer
+     */
+    default CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) {
+        throw new HeadlessException();
+    }
 
-    RobotPeer createRobot(Robot target, GraphicsDevice screen)
-        throws AWTException, HeadlessException;
+    /**
+     * Creates the peer for a DragSourceContext. Always throws
+     * InvalidDndOperationException if GraphicsEnvironment.isHeadless() returns
+     * true.
+     *
+     * @param  dge the {@code DragGestureEvent}
+     * @return the peer created
+     * @see java.awt.GraphicsEnvironment#isHeadless
+     */
+    default DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) {
+        throw new InvalidDnDOperationException("Headless environment");
+    }
 
-    DataTransferer getDataTransferer();
+    /**
+     * Creates this toolkit's implementation of {@code Font} using the specified
+     * peer interface.
+     *
+     * @param name the font to be implemented
+     * @param style the style of the font, such as {@code PLAIN}, {@code BOLD},
+     *        {@code ITALIC}, or a combination
+     * @return this toolkit's implementation of {@code Font}
+     * @see java.awt.Font
+     * @see java.awt.peer.FontPeer
+     * @see java.awt.GraphicsEnvironment#getAllFonts
+     */
+    default FontPeer getFontPeer(String name, int style) {
+        return null;
+    }
 
+    default RobotPeer createRobot(Robot target, GraphicsDevice screen)
+            throws AWTException {
+        throw new HeadlessException();
+    }
+
+    default DataTransferer getDataTransferer() {
+        return null;
+    }
+
+    /**
+     * Obtains this toolkit's implementation of helper class for {@code
+     * MouseInfo} operations.
+     *
+     * @return this toolkit's implementation of helper for {@code MouseInfo}
+     * @throws UnsupportedOperationException if this operation is not
+     *         implemented
+     * @see java.awt.peer.MouseInfoPeer
+     * @see java.awt.MouseInfo
+     * @since 1.5
+     */
+    default MouseInfoPeer getMouseInfoPeer() {
+        throw new UnsupportedOperationException("Not implemented");
+    }
 }
--- a/src/java.desktop/share/classes/sun/awt/HToolkit.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/sun/awt/HToolkit.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
@@ -25,16 +25,18 @@
 
 package sun.awt;
 
-import sun.awt.datatransfer.DataTransferer;
-
 import java.awt.*;
-import java.awt.dnd.*;
-import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.datatransfer.Clipboard;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
 import java.awt.im.InputMethodHighlight;
 import java.awt.im.spi.InputMethodDescriptor;
-import java.awt.image.*;
-import java.awt.datatransfer.Clipboard;
-import java.awt.peer.*;
+import java.awt.image.ColorModel;
+import java.awt.peer.FramePeer;
+import java.awt.peer.KeyboardFocusManagerPeer;
+import java.awt.peer.SystemTrayPeer;
+import java.awt.peer.TrayIconPeer;
 import java.util.Map;
 import java.util.Properties;
 
@@ -47,10 +49,15 @@
     implements ComponentFactory {
 
     private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() {
+        @Override
         public void setCurrentFocusedWindow(Window win) {}
+        @Override
         public Window getCurrentFocusedWindow() { return null; }
+        @Override
         public void setCurrentFocusOwner(Component comp) {}
+        @Override
         public Component getCurrentFocusOwner() { return null; }
+        @Override
         public void clearGlobalFocusOwner(Window activeWindow) {}
     };
 
@@ -61,136 +68,35 @@
      * Component peer objects - unsupported.
      */
 
-    public WindowPeer createWindow(Window target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
+    @Override
     public FramePeer createLightweightFrame(LightweightFrame target)
         throws HeadlessException {
         throw new HeadlessException();
     }
 
-    public FramePeer createFrame(Frame target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public DialogPeer createDialog(Dialog target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public ButtonPeer createButton(Button target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public TextFieldPeer createTextField(TextField target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public ChoicePeer createChoice(Choice target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public LabelPeer createLabel(Label target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public ListPeer createList(List target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public CheckboxPeer createCheckbox(Checkbox target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public ScrollbarPeer createScrollbar(Scrollbar target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public ScrollPanePeer createScrollPane(ScrollPane target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public TextAreaPeer createTextArea(TextArea target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public FileDialogPeer createFileDialog(FileDialog target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public MenuBarPeer createMenuBar(MenuBar target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public MenuPeer createMenu(Menu target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public PopupMenuPeer createPopupMenu(PopupMenu target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public MenuItemPeer createMenuItem(MenuItem target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public DragSourceContextPeer createDragSourceContextPeer(
-        DragGestureEvent dge)
-        throws InvalidDnDOperationException {
-        throw new InvalidDnDOperationException("Headless environment");
-    }
-
-    public RobotPeer createRobot(Robot target, GraphicsDevice screen)
-        throws AWTException, HeadlessException {
-        throw new HeadlessException();
-    }
-
+    @Override
     public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
         // See 6833019.
         return kfmPeer;
     }
 
+    @Override
     public TrayIconPeer createTrayIcon(TrayIcon target)
       throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public SystemTrayPeer createSystemTray(SystemTray target)
       throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public boolean isTraySupported() {
         return false;
     }
 
-    @Override
-    public DataTransferer getDataTransferer() {
-        return null;
-    }
-
     public GlobalCursorManager getGlobalCursorManager()
         throws HeadlessException {
         throw new HeadlessException();
@@ -199,57 +105,68 @@
     /*
      * Headless toolkit - unsupported.
      */
+    @Override
     protected void loadSystemColors(int[] systemColors)
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public ColorModel getColorModel()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public int getScreenResolution()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public Map<java.awt.font.TextAttribute, ?> mapInputMethodHighlight(
             InputMethodHighlight highlight)
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public int getMenuShortcutKeyMask()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public boolean getLockingKeyState(int keyCode)
         throws UnsupportedOperationException {
         throw new HeadlessException();
     }
 
+    @Override
     public void setLockingKeyState(int keyCode, boolean on)
         throws UnsupportedOperationException {
         throw new HeadlessException();
     }
 
+    @Override
     public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
         throws IndexOutOfBoundsException, HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public int getMaximumCursorColors()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public <T extends DragGestureRecognizer> T
         createDragGestureRecognizer(Class<T> abstractRecognizerClass,
                                     DragSource ds, Component c,
@@ -258,41 +175,49 @@
         return null;
     }
 
+    @Override
     public int getScreenHeight()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public int getScreenWidth()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public Dimension getScreenSize()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public Insets getScreenInsets(GraphicsConfiguration gc)
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public void setDynamicLayout(boolean dynamic)
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     protected boolean isDynamicLayoutSet()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public boolean isDynamicLayoutActive()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public Clipboard getSystemClipboard()
         throws HeadlessException {
         throw new HeadlessException();
@@ -301,6 +226,7 @@
     /*
      * Printing
      */
+    @Override
     public PrintJob getPrintJob(Frame frame, String jobtitle,
         JobAttributes jobAttributes,
         PageAttributes pageAttributes) {
@@ -312,6 +238,7 @@
                 "PrintJob not supported in a headless environment");
     }
 
+    @Override
     public PrintJob getPrintJob(Frame frame, String doctitle, Properties props)
     {
         if (frame != null) {
@@ -326,65 +253,63 @@
      * Headless toolkit - supported.
      */
 
+    @Override
     public void sync() {
         // Do nothing
     }
 
+    @Override
     protected boolean syncNativeQueue(final long timeout) {
         return false;
     }
 
+    @Override
     public void beep() {
         // Send alert character
         System.out.write(0x07);
     }
 
-
-    /*
-     * Fonts
-     */
-    public FontPeer getFontPeer(String name, int style) {
-        return (FontPeer)null;
-    }
-
     /*
      * Modality
      */
+    @Override
     public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
         return false;
     }
 
+    @Override
     public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
         return false;
     }
 
+    @Override
     public boolean isDesktopSupported() {
         return false;
     }
 
-    public DesktopPeer createDesktopPeer(Desktop target)
-    throws HeadlessException{
-        throw new HeadlessException();
-    }
-
     public boolean isWindowOpacityControlSupported() {
         return false;
     }
 
+    @Override
     public boolean isWindowShapingSupported() {
         return false;
     }
 
+    @Override
     public boolean isWindowTranslucencySupported() {
         return false;
     }
 
+    @Override
     public  void grab(Window w) { }
 
+    @Override
     public void ungrab(Window w) { }
 
     protected boolean syncNativeQueue() { return false; }
 
+    @Override
     public InputMethodDescriptor getInputMethodAdapterDescriptor()
         throws AWTException
     {
--- a/src/java.desktop/share/classes/sun/awt/HeadlessToolkit.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/sun/awt/HeadlessToolkit.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -25,34 +25,43 @@
 
 package sun.awt;
 
-import sun.awt.datatransfer.DataTransferer;
-
 import java.awt.*;
-import java.awt.dnd.*;
-import java.awt.dnd.peer.DragSourceContextPeer;
-import java.awt.event.*;
+import java.awt.datatransfer.Clipboard;
+import java.awt.dnd.DragGestureListener;
+import java.awt.dnd.DragGestureRecognizer;
+import java.awt.dnd.DragSource;
+import java.awt.event.AWTEventListener;
 import java.awt.font.TextAttribute;
 import java.awt.im.InputMethodHighlight;
-import java.awt.image.*;
-import java.awt.datatransfer.Clipboard;
-import java.awt.peer.*;
+import java.awt.image.ColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.peer.FontPeer;
+import java.awt.peer.KeyboardFocusManagerPeer;
+import java.awt.peer.SystemTrayPeer;
+import java.awt.peer.TrayIconPeer;
 import java.beans.PropertyChangeListener;
 import java.net.URL;
 import java.util.Map;
 import java.util.Properties;
 
-public class HeadlessToolkit extends Toolkit
+public final class HeadlessToolkit extends Toolkit
     implements ComponentFactory, KeyboardFocusManagerPeerProvider {
 
     private static final KeyboardFocusManagerPeer kfmPeer = new KeyboardFocusManagerPeer() {
+        @Override
         public void setCurrentFocusedWindow(Window win) {}
+        @Override
         public Window getCurrentFocusedWindow() { return null; }
+        @Override
         public void setCurrentFocusOwner(Component comp) {}
+        @Override
         public Component getCurrentFocusOwner() { return null; }
+        @Override
         public void clearGlobalFocusOwner(Window activeWindow) {}
     };
 
-    private Toolkit tk;
+    private final Toolkit tk;
     private ComponentFactory componentFactory;
 
     public HeadlessToolkit(Toolkit tk) {
@@ -66,125 +75,7 @@
         return tk;
     }
 
-    /*
-     * Component peer objects.
-     */
-
-    /* Lightweight implementation of Canvas and Panel */
-
-    public CanvasPeer createCanvas(Canvas target) {
-        return (CanvasPeer)createComponent(target);
-    }
-
-    public PanelPeer createPanel(Panel target) {
-        return (PanelPeer)createComponent(target);
-    }
-
-    /*
-     * Component peer objects - unsupported.
-     */
-
-    public WindowPeer createWindow(Window target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public FramePeer createFrame(Frame target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public DialogPeer createDialog(Dialog target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public ButtonPeer createButton(Button target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public TextFieldPeer createTextField(TextField target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public ChoicePeer createChoice(Choice target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public LabelPeer createLabel(Label target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public ListPeer createList(List target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public CheckboxPeer createCheckbox(Checkbox target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public ScrollbarPeer createScrollbar(Scrollbar target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public ScrollPanePeer createScrollPane(ScrollPane target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public TextAreaPeer createTextArea(TextArea target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public FileDialogPeer createFileDialog(FileDialog target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public MenuBarPeer createMenuBar(MenuBar target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public MenuPeer createMenu(Menu target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public PopupMenuPeer createPopupMenu(PopupMenu target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public MenuItemPeer createMenuItem(MenuItem target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
-        throws HeadlessException {
-        throw new HeadlessException();
-    }
-
-    public DragSourceContextPeer createDragSourceContextPeer(
-        DragGestureEvent dge)
-        throws InvalidDnDOperationException {
-        throw new InvalidDnDOperationException("Headless environment");
-    }
-
-    public RobotPeer createRobot(Robot target, GraphicsDevice screen)
-        throws AWTException, HeadlessException {
-        throw new HeadlessException();
-    }
-
+    @Override
     public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() {
         // See 6833019.
         return kfmPeer;
@@ -212,56 +103,67 @@
     /*
      * Headless toolkit - unsupported.
      */
+    @Override
     protected void loadSystemColors(int[] systemColors)
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public ColorModel getColorModel()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public int getScreenResolution()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight)
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public int getMenuShortcutKeyMask()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public boolean getLockingKeyState(int keyCode)
         throws UnsupportedOperationException {
         throw new HeadlessException();
     }
 
+    @Override
     public void setLockingKeyState(int keyCode, boolean on)
         throws UnsupportedOperationException {
         throw new HeadlessException();
     }
 
+    @Override
     public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
         throws IndexOutOfBoundsException, HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public int getMaximumCursorColors()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public <T extends DragGestureRecognizer> T
         createDragGestureRecognizer(Class<T> abstractRecognizerClass,
                                     DragSource ds, Component c,
@@ -280,31 +182,37 @@
         throw new HeadlessException();
     }
 
+    @Override
     public Dimension getScreenSize()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public Insets getScreenInsets(GraphicsConfiguration gc)
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public void setDynamicLayout(boolean dynamic)
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     protected boolean isDynamicLayoutSet()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public boolean isDynamicLayoutActive()
         throws HeadlessException {
         throw new HeadlessException();
     }
 
+    @Override
     public Clipboard getSystemClipboard()
         throws HeadlessException {
         throw new HeadlessException();
@@ -313,6 +221,7 @@
     /*
      * Printing
      */
+    @Override
     public PrintJob getPrintJob(Frame frame, String jobtitle,
         JobAttributes jobAttributes,
         PageAttributes pageAttributes) {
@@ -323,6 +232,7 @@
         throw new NullPointerException("frame must not be null");
     }
 
+    @Override
     public PrintJob getPrintJob(Frame frame, String doctitle, Properties props)
     {
         if (frame != null) {
@@ -336,10 +246,12 @@
      * Headless toolkit - supported.
      */
 
+    @Override
     public void sync() {
         // Do nothing
     }
 
+    @Override
     public void beep() {
         // Send alert character
         System.out.write(0x07);
@@ -348,6 +260,7 @@
     /*
      * Event Queue
      */
+    @Override
     public EventQueue getSystemEventQueueImpl() {
         return SunToolkit.getSystemEventQueueImplPP();
     }
@@ -355,39 +268,48 @@
     /*
      * Images.
      */
+    @Override
     public int checkImage(Image img, int w, int h, ImageObserver o) {
         return tk.checkImage(img, w, h, o);
     }
 
+    @Override
     public boolean prepareImage(
         Image img, int w, int h, ImageObserver o) {
         return tk.prepareImage(img, w, h, o);
     }
 
+    @Override
     public Image getImage(String filename) {
         return tk.getImage(filename);
     }
 
+    @Override
     public Image getImage(URL url) {
         return tk.getImage(url);
     }
 
+    @Override
     public Image createImage(String filename) {
         return tk.createImage(filename);
     }
 
+    @Override
     public Image createImage(URL url) {
         return tk.createImage(url);
     }
 
+    @Override
     public Image createImage(byte[] data, int offset, int length) {
         return tk.createImage(data, offset, length);
     }
 
+    @Override
     public Image createImage(ImageProducer producer) {
         return tk.createImage(producer);
     }
 
+    @Override
     public Image createImage(byte[] imagedata) {
         return tk.createImage(imagedata);
     }
@@ -396,7 +318,7 @@
     /*
      * Fonts
      */
-    @SuppressWarnings("deprecation")
+    @Override
     public FontPeer getFontPeer(String name, int style) {
         if (componentFactory != null) {
             return componentFactory.getFontPeer(name, style);
@@ -405,15 +327,12 @@
     }
 
     @Override
-    public DataTransferer getDataTransferer() {
-        return null;
-    }
-
     @SuppressWarnings("deprecation")
     public FontMetrics getFontMetrics(Font font) {
         return tk.getFontMetrics(font);
     }
 
+    @Override
     @SuppressWarnings("deprecation")
     public String[] getFontList() {
         return tk.getFontList();
@@ -423,11 +342,13 @@
      * Desktop properties
      */
 
+    @Override
     public void addPropertyChangeListener(String name,
         PropertyChangeListener pcl) {
         tk.addPropertyChangeListener(name, pcl);
     }
 
+    @Override
     public void removePropertyChangeListener(String name,
         PropertyChangeListener pcl) {
         tk.removePropertyChangeListener(name, pcl);
@@ -436,10 +357,12 @@
     /*
      * Modality
      */
+    @Override
     public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
         return false;
     }
 
+    @Override
     public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
         return false;
     }
@@ -447,6 +370,7 @@
     /*
      * Always on top
      */
+    @Override
     public boolean isAlwaysOnTopSupported() {
         return false;
     }
@@ -455,19 +379,23 @@
      * AWT Event listeners
      */
 
+    @Override
     public void addAWTEventListener(AWTEventListener listener,
         long eventMask) {
         tk.addAWTEventListener(listener, eventMask);
     }
 
+    @Override
     public void removeAWTEventListener(AWTEventListener listener) {
         tk.removeAWTEventListener(listener);
     }
 
+    @Override
     public AWTEventListener[] getAWTEventListeners() {
         return tk.getAWTEventListeners();
     }
 
+    @Override
     public AWTEventListener[] getAWTEventListeners(long eventMask) {
         return tk.getAWTEventListeners(eventMask);
     }
@@ -476,11 +404,7 @@
         return false;
     }
 
-    public DesktopPeer createDesktopPeer(Desktop target)
-    throws HeadlessException{
-        throw new HeadlessException();
-    }
-
+    @Override
     public boolean areExtraMouseButtonsEnabled() throws HeadlessException{
         throw new HeadlessException();
     }
--- a/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/share/classes/sun/awt/SunToolkit.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -26,37 +26,51 @@
 package sun.awt;
 
 import java.awt.*;
-import static java.awt.RenderingHints.*;
-import java.awt.dnd.*;
-import java.awt.dnd.peer.DragSourceContextPeer;
-import java.awt.peer.*;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
 import java.awt.event.WindowEvent;
-import java.awt.event.KeyEvent;
-import java.awt.image.*;
-import java.awt.TrayIcon;
-import java.awt.SystemTray;
-import java.awt.event.InputEvent;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferInt;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.Raster;
+import java.awt.peer.FramePeer;
+import java.awt.peer.KeyboardFocusManagerPeer;
+import java.awt.peer.MouseInfoPeer;
+import java.awt.peer.SystemTrayPeer;
+import java.awt.peer.TrayIconPeer;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
-import java.security.PrivilegedAction;
-import java.util.*;
+import java.security.AccessController;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Vector;
+import java.util.WeakHashMap;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import sun.awt.datatransfer.DataTransferer;
+import sun.awt.im.InputContext;
+import sun.awt.image.ByteArrayImageSource;
+import sun.awt.image.FileImageSource;
+import sun.awt.image.ImageRepresentation;
+import sun.awt.image.MultiResolutionImage;
+import sun.awt.image.MultiResolutionToolkitImage;
+import sun.awt.image.ToolkitImage;
+import sun.awt.image.URLImageSource;
+import sun.font.FontDesignMetrics;
+import sun.misc.SoftCache;
+import sun.security.action.GetBooleanAction;
+import sun.security.action.GetPropertyAction;
 import sun.util.logging.PlatformLogger;
-import sun.misc.SoftCache;
-import sun.font.FontDesignMetrics;
-import sun.awt.im.InputContext;
-import sun.awt.image.*;
-import sun.security.action.GetPropertyAction;
-import sun.security.action.GetBooleanAction;
-import java.lang.reflect.InvocationTargetException;
-import java.security.AccessController;
+
+import static java.awt.RenderingHints.*;
 
 public abstract class SunToolkit extends Toolkit
     implements ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider {
@@ -134,68 +148,9 @@
         return false;
     }
 
-    public abstract WindowPeer createWindow(Window target)
-        throws HeadlessException;
-
-    public abstract FramePeer createFrame(Frame target)
-        throws HeadlessException;
-
     public abstract FramePeer createLightweightFrame(LightweightFrame target)
         throws HeadlessException;
 
-    public abstract DialogPeer createDialog(Dialog target)
-        throws HeadlessException;
-
-    public abstract ButtonPeer createButton(Button target)
-        throws HeadlessException;
-
-    public abstract TextFieldPeer createTextField(TextField target)
-        throws HeadlessException;
-
-    public abstract ChoicePeer createChoice(Choice target)
-        throws HeadlessException;
-
-    public abstract LabelPeer createLabel(Label target)
-        throws HeadlessException;
-
-    public abstract ListPeer createList(java.awt.List target)
-        throws HeadlessException;
-
-    public abstract CheckboxPeer createCheckbox(Checkbox target)
-        throws HeadlessException;
-
-    public abstract ScrollbarPeer createScrollbar(Scrollbar target)
-        throws HeadlessException;
-
-    public abstract ScrollPanePeer createScrollPane(ScrollPane target)
-        throws HeadlessException;
-
-    public abstract TextAreaPeer createTextArea(TextArea target)
-        throws HeadlessException;
-
-    public abstract FileDialogPeer createFileDialog(FileDialog target)
-        throws HeadlessException;
-
-    public abstract MenuBarPeer createMenuBar(MenuBar target)
-        throws HeadlessException;
-
-    public abstract MenuPeer createMenu(Menu target)
-        throws HeadlessException;
-
-    public abstract PopupMenuPeer createPopupMenu(PopupMenu target)
-        throws HeadlessException;
-
-    public abstract MenuItemPeer createMenuItem(MenuItem target)
-        throws HeadlessException;
-
-    public abstract CheckboxMenuItemPeer createCheckboxMenuItem(
-        CheckboxMenuItem target)
-        throws HeadlessException;
-
-    public abstract DragSourceContextPeer createDragSourceContextPeer(
-        DragGestureEvent dge)
-        throws InvalidDnDOperationException;
-
     public abstract TrayIconPeer createTrayIcon(TrayIcon target)
         throws HeadlessException, AWTException;
 
@@ -203,12 +158,7 @@
 
     public abstract boolean isTraySupported();
 
-    @SuppressWarnings("deprecation")
-    public abstract FontPeer getFontPeer(String name, int style);
-
-    public abstract RobotPeer createRobot(Robot target, GraphicsDevice screen)
-        throws AWTException;
-
+    @Override
     public abstract KeyboardFocusManagerPeer getKeyboardFocusManagerPeer()
         throws HeadlessException;
 
@@ -511,6 +461,7 @@
      */
     public static void postPriorityEvent(final AWTEvent e) {
         PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() {
+                @Override
                 public void run() {
                     AWTAccessor.getAWTEventAccessor().setPosted(e);
                     ((Component)e.getSource()).dispatchEvent(e);
@@ -561,6 +512,7 @@
                                                    final long when) {
         executeOnEventHandlerThread(
             new PeerEvent(target, runnable, PeerEvent.PRIORITY_EVENT) {
+                @Override
                 public long getWhen() {
                     return when;
                 }
@@ -636,17 +588,20 @@
         return accessor.isDispatchThreadImpl(eq);
     }
 
+    @Override
     public Dimension getScreenSize() {
         return new Dimension(getScreenWidth(), getScreenHeight());
     }
     protected abstract int getScreenWidth();
     protected abstract int getScreenHeight();
 
+    @Override
     @SuppressWarnings("deprecation")
     public FontMetrics getFontMetrics(Font font) {
         return FontDesignMetrics.getMetrics(font);
     }
 
+    @Override
     @SuppressWarnings("deprecation")
     public String[] getFontList() {
         String[] hardwiredFontList = {
@@ -660,14 +615,6 @@
         return hardwiredFontList;
     }
 
-    public PanelPeer createPanel(Panel target) {
-        return (PanelPeer)createComponent(target);
-    }
-
-    public CanvasPeer createCanvas(Canvas target) {
-        return (CanvasPeer)createComponent(target);
-    }
-
     /**
      * Disables erasing of background on the canvas before painting if
      * this is supported by the current toolkit. It is recommended to
@@ -747,10 +694,12 @@
         }
     }
 
+    @Override
     public Image getImage(String filename) {
         return getImageFromHash(this, filename);
     }
 
+    @Override
     public Image getImage(URL url) {
         return getImageFromHash(this, url);
     }
@@ -784,20 +733,24 @@
     }
 
 
+    @Override
     public Image createImage(String filename) {
         checkPermissions(filename);
         return createImage(new FileImageSource(filename));
     }
 
+    @Override
     public Image createImage(URL url) {
         checkPermissions(url);
         return createImage(new URLImageSource(url));
     }
 
+    @Override
     public Image createImage(byte[] data, int offset, int length) {
         return createImage(new ByteArrayImageSource(data, offset, length));
     }
 
+    @Override
     public Image createImage(ImageProducer producer) {
         return new ToolkitImage(producer);
     }
@@ -807,6 +760,7 @@
         return new MultiResolutionToolkitImage(image, resolutionVariant);
     }
 
+    @Override
     public int checkImage(Image img, int w, int h, ImageObserver o) {
         if (!(img instanceof ToolkitImage)) {
             return ImageObserver.ALLBITS;
@@ -822,6 +776,7 @@
         return (tkimg.check(o) | repbits) & checkResolutionVariant(img, w, h, o);
     }
 
+    @Override
     public boolean prepareImage(Image img, int w, int h, ImageObserver o) {
         if (w == 0 || h == 0) {
             return true;
@@ -1063,6 +1018,7 @@
         return (DataBufferInt)buffer;
     }
 
+    @Override
     protected EventQueue getSystemEventQueueImpl() {
         return getSystemEventQueueImplPP();
     }
@@ -1144,6 +1100,7 @@
      * SunToolkit subclasses can override this method to return better input
      * method windows.
      */
+    @Override
     public Window createInputMethodWindow(String title, InputContext context) {
         return new sun.awt.im.SimpleInputMethodWindow(title, context);
     }
@@ -1152,6 +1109,7 @@
      * Returns whether enableInputMethods should be set to true for peered
      * TextComponent instances on this platform. False by default.
      */
+    @Override
     public boolean enableInputMethodsForTextComponent() {
         return false;
     }
@@ -1193,13 +1151,15 @@
     /**
      * Returns the default keyboard locale of the underlying operating system
      */
+    @Override
     public Locale getDefaultKeyboardLocale() {
         return getStartupLocale();
     }
 
     private static DefaultMouseInfoPeer mPeer = null;
 
-    protected synchronized MouseInfoPeer getMouseInfoPeer() {
+    @Override
+    public synchronized MouseInfoPeer getMouseInfoPeer() {
         if (mPeer == null) {
             mPeer = new DefaultMouseInfoPeer();
         }
@@ -1331,6 +1291,7 @@
     /**
      * Overridden in XToolkit and WToolkit
      */
+    @Override
     public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
         return (modalityType == Dialog.ModalityType.MODELESS) ||
                (modalityType == Dialog.ModalityType.APPLICATION_MODAL);
@@ -1339,6 +1300,7 @@
     /**
      * Overridden in XToolkit and WToolkit
      */
+    @Override
     public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
         return (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE);
     }
@@ -1386,6 +1348,7 @@
             listeners.removeElement(listener);
         }
 
+        @Override
         public void modalityPushed(ModalityEvent ev) {
             Iterator<ModalityListener> it = listeners.iterator();
             while (it.hasNext()) {
@@ -1393,6 +1356,7 @@
             }
         }
 
+        @Override
         public void modalityPopped(ModalityEvent ev) {
             Iterator<ModalityListener> it = listeners.iterator();
             while (it.hasNext()) {
@@ -1592,6 +1556,7 @@
         synchronized(waitLock) {
             postEvent(AppContext.getAppContext(),
                       new PeerEvent(getSystemEventQueueImpl(), null, PeerEvent.LOW_PRIORITY_EVENT) {
+                          @Override
                           public void dispatch() {
                               // Here we block EDT.  It could have some
                               // events, it should have dispatched them by
--- a/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java	Fri Apr 17 17:01:24 2015 +0300
@@ -106,6 +106,7 @@
     /**
      * Overridden to handle GTK icon loading
      */
+    @Override
     protected Object lazilyLoadDesktopProperty(String name) {
         if (name.startsWith("gtk.icon.")) {
             return lazilyLoadGTKIcon(name);
--- a/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	Fri Apr 17 17:01:24 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -175,6 +175,7 @@
         return uidefaults;
     }
 
+    @Override
     public void loadSystemColors(int[] systemColors) {
         nativeLoadSystemColors(systemColors);
         MotifColorUtilities.loadSystemColors(systemColors);
@@ -347,18 +348,21 @@
         }
     }
 
+    @Override
     public ButtonPeer createButton(Button target) {
         ButtonPeer peer = new XButtonPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public FramePeer createLightweightFrame(LightweightFrame target) {
         FramePeer peer = new XLightweightFramePeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public FramePeer createFrame(Frame target) {
         FramePeer peer = new XFramePeer(target);
         targetCreatedPeer(target, peer);
@@ -540,6 +544,7 @@
 
     static native void awt_toolkit_init();
 
+    @Override
     public void run() {
         awt_toolkit_init();
         run(PRIMARY_LOOP);
@@ -680,10 +685,12 @@
         return screenHeight;
     }
 
+    @Override
     protected int getScreenWidth() {
         return getDefaultScreenWidth();
     }
 
+    @Override
     protected int getScreenHeight() {
         return getDefaultScreenHeight();
     }
@@ -724,6 +731,7 @@
      * not set, we try to calculate the insets ourselves using
      * getScreenInsetsManually method.
      */
+    @Override
     public Insets getScreenInsets(GraphicsConfiguration gc)
     {
         XNETProtocol netProto = XWM.getWM().getNETProtocol();
@@ -911,6 +919,7 @@
         SunToolkit.targetDisposedPeer(target, peer);
     }
 
+    @Override
     public RobotPeer createRobot(Robot target, GraphicsDevice screen) {
         return new XRobotPeer(screen.getDefaultConfiguration());
     }
@@ -922,10 +931,12 @@
      * automatically.  The setter method for this property is
      * irrelevant on X.
      */
+    @Override
     public void setDynamicLayout(boolean b) {
         dynamicLayoutSetting = b;
     }
 
+    @Override
     protected boolean isDynamicLayoutSet() {
         return dynamicLayoutSetting;
     }
@@ -937,15 +948,17 @@
         return XWM.getWM().supportsDynamicLayout();
     }
 
+    @Override
     public boolean isDynamicLayoutActive() {
         return isDynamicLayoutSupported();
     }
 
-
+    @Override
     public FontPeer getFontPeer(String name, int style){
         return new XFontPeer(name, style);
     }
 
+    @Override
     public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
         final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
         if (f != null) {
@@ -955,6 +968,7 @@
         return XDragSourceContextPeer.createDragSourceContextPeer(dge);
     }
 
+    @Override
     @SuppressWarnings("unchecked")
     public <T extends DragGestureRecognizer> T
     createDragGestureRecognizer(Class<T> recognizerClass,
@@ -974,6 +988,7 @@
             return null;
     }
 
+    @Override
     public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) {
         XCheckboxMenuItemPeer peer = new XCheckboxMenuItemPeer(target);
         //vb157120: looks like we don't need to map menu items
@@ -982,6 +997,7 @@
         return peer;
     }
 
+    @Override
     public MenuItemPeer createMenuItem(MenuItem target) {
         XMenuItemPeer peer = new XMenuItemPeer(target);
         //vb157120: looks like we don't need to map menu items
@@ -990,72 +1006,84 @@
         return peer;
     }
 
+    @Override
     public TextFieldPeer createTextField(TextField target) {
         TextFieldPeer  peer = new XTextFieldPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public LabelPeer createLabel(Label target) {
         LabelPeer  peer = new XLabelPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public ListPeer createList(java.awt.List target) {
         ListPeer peer = new XListPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public CheckboxPeer createCheckbox(Checkbox target) {
         CheckboxPeer peer = new XCheckboxPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public ScrollbarPeer createScrollbar(Scrollbar target) {
         XScrollbarPeer peer = new XScrollbarPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public ScrollPanePeer createScrollPane(ScrollPane target) {
         XScrollPanePeer peer = new XScrollPanePeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public TextAreaPeer createTextArea(TextArea target) {
         TextAreaPeer peer = new XTextAreaPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public ChoicePeer createChoice(Choice target) {
         XChoicePeer peer = new XChoicePeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public CanvasPeer createCanvas(Canvas target) {
         XCanvasPeer peer = (isXEmbedServerRequested() ? new XEmbedCanvasPeer(target) : new XCanvasPeer(target));
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public PanelPeer createPanel(Panel target) {
         PanelPeer peer = new XPanelPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public WindowPeer createWindow(Window target) {
         WindowPeer peer = new XWindowPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public DialogPeer createDialog(Dialog target) {
         DialogPeer peer = new XDialogPeer(target);
         targetCreatedPeer(target, peer);
@@ -1076,6 +1104,7 @@
         return sunAwtDisableGtkFileDialogs.booleanValue();
     }
 
+    @Override
     public FileDialogPeer createFileDialog(FileDialog target) {
         FileDialogPeer peer = null;
         // The current GtkFileChooser is available from GTK+ 2.4
@@ -1088,12 +1117,14 @@
         return peer;
     }
 
+    @Override
     public MenuBarPeer createMenuBar(MenuBar target) {
         XMenuBarPeer peer = new XMenuBarPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public MenuPeer createMenu(Menu target) {
         XMenuPeer peer = new XMenuPeer(target);
         //vb157120: looks like we don't need to map menu items
@@ -1102,12 +1133,14 @@
         return peer;
     }
 
+    @Override
     public PopupMenuPeer createPopupMenu(PopupMenu target) {
         XPopupMenuPeer peer = new XPopupMenuPeer(target);
         targetCreatedPeer(target, peer);
         return peer;
     }
 
+    @Override
     public synchronized MouseInfoPeer getMouseInfoPeer() {
         if (xPeer == null) {
             xPeer = new XMouseInfoPeer();
@@ -1128,6 +1161,7 @@
         return peer;
     }
 
+    @Override
     public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() throws HeadlessException {
         return XKeyboardFocusManagerPeer.getInstance();
     }
@@ -1135,11 +1169,13 @@
     /**
      * Returns a new custom cursor.
      */
+    @Override
     public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
       throws IndexOutOfBoundsException {
         return new XCustomCursor(cursor, hotSpot, name);
     }
 
+    @Override
     public TrayIconPeer createTrayIcon(TrayIcon target)
       throws HeadlessException, AWTException
     {
@@ -1148,11 +1184,13 @@
         return peer;
     }
 
+    @Override
     public SystemTrayPeer createSystemTray(SystemTray target) throws HeadlessException {
         SystemTrayPeer peer = new XSystemTrayPeer(target);
         return peer;
     }
 
+    @Override
     public boolean isTraySupported() {
         XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
         if (peer != null) {
@@ -1169,16 +1207,19 @@
     /**
      * Returns the supported cursor size
      */
+    @Override
     public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
         return XCustomCursor.getBestCursorSize(
                                                java.lang.Math.max(1,preferredWidth), java.lang.Math.max(1,preferredHeight));
     }
 
 
+    @Override
     public int getMaximumCursorColors() {
         return 2;  // Black and white.
     }
 
+    @Override
     public Map<TextAttribute, ?> mapInputMethodHighlight( InputMethodHighlight highlight) {
         return XInputMethod.mapInputMethodHighlight(highlight);
     }
@@ -1196,6 +1237,7 @@
         }
     }
 
+    @Override
     public  Clipboard getSystemClipboard() {
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
@@ -1209,6 +1251,7 @@
         return clipboard;
     }
 
+    @Override
     public Clipboard getSystemSelection() {
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
@@ -1222,6 +1265,7 @@
         return selection;
     }
 
+    @Override
     public void beep() {
         awtLock();
         try {
@@ -1232,6 +1276,7 @@
         }
     }
 
+    @Override
     public PrintJob getPrintJob(final Frame frame, final String doctitle,
                                 final Properties props) {
 
@@ -1247,6 +1292,7 @@
         return printJob;
     }
 
+    @Override
     public PrintJob getPrintJob(final Frame frame, final String doctitle,
                 final JobAttributes jobAttributes,
                 final PageAttributes pageAttributes)
@@ -1274,6 +1320,7 @@
         }
     }
 
+    @Override
     public int getScreenResolution() {
         long display = getDisplay();
         awtLock();
@@ -1299,6 +1346,7 @@
         return screenmodel;
     }
 
+    @Override
     public ColorModel getColorModel() {
         return getStaticColorModel();
     }
@@ -1306,6 +1354,7 @@
     /**
      * Returns a new input method adapter descriptor for native input methods.
      */
+    @Override
     public InputMethodDescriptor getInputMethodAdapterDescriptor() throws AWTException {
         return new XInputMethodDescriptor();
     }
@@ -1357,6 +1406,7 @@
         }
     }
 
+    @Override
     public boolean isFrameStateSupported(int state)
       throws HeadlessException
     {
@@ -1399,6 +1449,7 @@
 
     private static final XEventDispatcher timeFetcher =
     new XEventDispatcher() {
+            @Override
             public void dispatchEvent(XEvent ev) {
                 switch (ev.get_type()) {
                   case XConstants.PropertyNotify:
@@ -1467,6 +1518,7 @@
         }
         return timeStamp;
     }
+    @Override
     protected void initializeDesktopProperties() {
         desktopProperties.put("DnD.Autoscroll.initialDelay",
                               Integer.valueOf(50));
@@ -1525,6 +1577,7 @@
     private final static String postfix = ".32x32";
     private static final String dndPrefix  = "DnD.";
 
+    @Override
     protected Object lazilyLoadDesktopProperty(String name) {
         if (name.startsWith(prefix)) {
             String cursorName = name.substring(prefix.length(), name.length()) + postfix;
@@ -1547,6 +1600,7 @@
         return super.lazilyLoadDesktopProperty(name);
     }
 
+    @Override
     public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
         if (name == null) {
             // See JavaDoc for the Toolkit.addPropertyChangeListener() method
@@ -2045,12 +2099,14 @@
     /**
      * @see sun.awt.SunToolkit#needsXEmbedImpl
      */
+    @Override
     protected boolean needsXEmbedImpl() {
         // XToolkit implements supports for XEmbed-client protocol and
         // requires the supports from the embedding host for it to work.
         return true;
     }
 
+    @Override
     public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
         return (modalityType == null) ||
                (modalityType == Dialog.ModalityType.MODELESS) ||
@@ -2059,6 +2115,7 @@
                (modalityType == Dialog.ModalityType.TOOLKIT_MODAL);
     }
 
+    @Override
     public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
         return (exclusionType == null) ||
                (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE) ||
@@ -2081,6 +2138,7 @@
             .removeSourceEvents(queue, source, removeAllEvents);
     }
 
+    @Override
     public boolean isAlwaysOnTopSupported() {
         for (XLayerProtocol proto : XWM.getWM().getProtocols(XLayerProtocol.class)) {
             if (proto.supportsLayer(XLayerProtocol.LAYER_ALWAYS_ON_TOP)) {
@@ -2090,6 +2148,7 @@
         return false;
     }
 
+    @Override
     public boolean useBufferPerWindow() {
         return XToolkit.getBackingStoreType() == XConstants.NotUseful;
     }
@@ -2398,11 +2457,13 @@
     /**
      * @inheritDoc
      */
+    @Override
     protected boolean syncNativeQueue(final long timeout) {
         XBaseWindow win = XBaseWindow.getXAWTRootWindow();
 
         if (oops_waiter == null) {
             oops_waiter = new XEventDispatcher() {
+                    @Override
                     public void dispatchEvent(XEvent e) {
                         if (e.get_type() == XConstants.ConfigureNotify) {
                             // OOPS ConfigureNotify event catched
@@ -2449,6 +2510,7 @@
             awtUnlock();
         }
     }
+    @Override
     public void grab(Window w) {
         final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
         if (peer != null) {
@@ -2456,6 +2518,7 @@
         }
     }
 
+    @Override
     public void ungrab(Window w) {
         final Object peer = AWTAccessor.getComponentAccessor().getPeer(w);
         if (peer != null) {
@@ -2469,14 +2532,17 @@
      * The methods of java.awt.Desktop class are supported on the Gnome desktop.
      * Check if the running desktop is Gnome by checking the window manager.
      */
+    @Override
     public boolean isDesktopSupported(){
         return XDesktopPeer.isDesktopSupported();
     }
 
+    @Override
     public DesktopPeer createDesktopPeer(Desktop target){
         return new XDesktopPeer();
     }
 
+    @Override
     public boolean areExtraMouseButtonsEnabled() throws HeadlessException {
         return areExtraMouseButtonsEnabled;
     }
--- a/test/java/awt/Toolkit/DynamicLayout/bug7172833.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/test/java/awt/Toolkit/DynamicLayout/bug7172833.java	Fri Apr 17 17:01:24 2015 +0300
@@ -23,16 +23,13 @@
 
 
 import java.awt.*;
+import java.awt.Frame;
 import java.awt.datatransfer.Clipboard;
-import java.awt.dnd.DragGestureEvent;
-import java.awt.dnd.InvalidDnDOperationException;
-import java.awt.dnd.peer.DragSourceContextPeer;
 import java.awt.font.TextAttribute;
 import java.awt.im.InputMethodHighlight;
 import java.awt.image.ColorModel;
 import java.awt.image.ImageObserver;
 import java.awt.image.ImageProducer;
-import java.awt.peer.*;
 import java.net.URL;
 import java.util.Map;
 import java.util.Properties;
@@ -67,130 +64,6 @@
             return super.isDynamicLayoutSet();
         }
 
-        @Override
-        protected DesktopPeer createDesktopPeer(final Desktop target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected ButtonPeer createButton(final Button target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected TextFieldPeer createTextField(final TextField target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected LabelPeer createLabel(final Label target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected ListPeer createList(final List target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected CheckboxPeer createCheckbox(final Checkbox target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected ScrollbarPeer createScrollbar(final Scrollbar target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected ScrollPanePeer createScrollPane(final ScrollPane target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected TextAreaPeer createTextArea(final TextArea target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected ChoicePeer createChoice(final Choice target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected FramePeer createFrame(final Frame target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected CanvasPeer createCanvas(final Canvas target) {
-            return null;
-        }
-
-        @Override
-        protected PanelPeer createPanel(final Panel target) {
-            return null;
-        }
-
-        @Override
-        protected WindowPeer createWindow(final Window target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected DialogPeer createDialog(final Dialog target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected MenuBarPeer createMenuBar(final MenuBar target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected MenuPeer createMenu(final Menu target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected PopupMenuPeer createPopupMenu(final PopupMenu target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected MenuItemPeer createMenuItem(final MenuItem target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected FileDialogPeer createFileDialog(final FileDialog target)
-                throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected CheckboxMenuItemPeer createCheckboxMenuItem(
-                final CheckboxMenuItem target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected FontPeer getFontPeer(final String name, final int style) {
-            return null;
-        }
 
         @Override
         public Dimension getScreenSize() throws HeadlessException {
@@ -288,12 +161,6 @@
         }
 
         @Override
-        public DragSourceContextPeer createDragSourceContextPeer(
-                final DragGestureEvent dge) throws InvalidDnDOperationException {
-            return null;
-        }
-
-        @Override
         public boolean isModalityTypeSupported(
                 final Dialog.ModalityType modalityType) {
             return false;
--- a/test/java/awt/Toolkit/Headless/ExceptionContract/ExceptionContract.java	Fri Apr 17 16:57:30 2015 +0300
+++ b/test/java/awt/Toolkit/Headless/ExceptionContract/ExceptionContract.java	Fri Apr 17 17:01:24 2015 +0300
@@ -36,12 +36,9 @@
 import test.java.awt.regtesthelpers.Sysout;
 
 import java.awt.datatransfer.Clipboard;
-import java.awt.dnd.*;
-import java.awt.dnd.peer.DragSourceContextPeer;
 import java.awt.font.TextAttribute;
 import java.awt.im.InputMethodHighlight;
 import java.awt.image.*;
-import java.awt.peer.*;
 import java.net.URL;
 import java.util.Map;
 import java.util.Properties;
@@ -112,116 +109,6 @@
         }
 
         @Override
-        protected DesktopPeer createDesktopPeer(Desktop target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected ButtonPeer createButton(Button target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected TextFieldPeer createTextField(TextField target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected LabelPeer createLabel(Label target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected ListPeer createList(List target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected CheckboxPeer createCheckbox(Checkbox target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected ScrollbarPeer createScrollbar(Scrollbar target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected ScrollPanePeer createScrollPane(ScrollPane target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected TextAreaPeer createTextArea(TextArea target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected ChoicePeer createChoice(Choice target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected FramePeer createFrame(Frame target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected CanvasPeer createCanvas(Canvas target) {
-            return null;
-        }
-
-        @Override
-        protected PanelPeer createPanel(Panel target) {
-            return null;
-        }
-
-        @Override
-        protected WindowPeer createWindow(Window target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected DialogPeer createDialog(Dialog target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected MenuBarPeer createMenuBar(MenuBar target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected MenuPeer createMenu(Menu target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected PopupMenuPeer createPopupMenu(PopupMenu target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected MenuItemPeer createMenuItem(MenuItem target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected FileDialogPeer createFileDialog(FileDialog target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) throws HeadlessException {
-            return null;
-        }
-
-        @Override
-        protected FontPeer getFontPeer(String name, int style) {
-            return null;
-        }
-
-        @Override
         public Dimension getScreenSize() throws HeadlessException {
             return null;
         }
@@ -312,11 +199,6 @@
         }
 
         @Override
-        public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
-            return null;
-        }
-
-        @Override
         public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
             return false;
         }