Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8251211

Address reliance on default constructors in the AWT APIs

    XMLWordPrintable

    Details

    • Type: CSR
    • Status: Closed
    • Priority: P4
    • Resolution: Approved
    • Fix Version/s: 16
    • Component/s: client-libs
    • Labels:
      None
    • Subcomponent:
    • Compatibility Kind:
      source
    • Compatibility Risk:
      minimal
    • Interface Kind:
      Java API
    • Scope:
      SE

      Description

      Summary

      Add explicit constructors to some classes in Java AWT APIs which using default constructors.

      Problem

      Default constructors are not recommended for formal API classes.

      Solution

      Add the public constructors to the public/non-abstract classes, and protected constructors to the public/abstract classes.

      Specification

      src/java.desktop/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java
      
      +    /**
      +     * Constructs a {@code ContainerOrderFocusTraversalPolicy}.
      +     */
      +    public ContainerOrderFocusTraversalPolicy() {}
      
      src/java.desktop/share/classes/java/awt/DefaultFocusTraversalPolicy.java
      
      +    /**
      +     * Constructs a {@code DefaultFocusTraversalPolicy}.
      +     */
      +    public DefaultFocusTraversalPolicy() {}
      
      src/java.desktop/share/classes/java/awt/DefaultKeyboardFocusManager.java
      
      +    /**
      +     * Constructs a {@code DefaultKeyboardFocusManager}.
      +     */
      +    public DefaultKeyboardFocusManager() {}
      
      src/java.desktop/share/classes/java/awt/FocusTraversalPolicy.java
       public abstract class FocusTraversalPolicy {
      
      +    /**
      +     * Constructs a {@code FocusTraversalPolicy}.
      +     */
      +    protected FocusTraversalPolicy() {}
      
      src/java.desktop/share/classes/java/awt/Toolkit.java
       public abstract class Toolkit {
      
      +    /**
      +     * Constructs a {@code Toolkit}.
      +     */
      +    protected Toolkit() {}
      
      src/java.desktop/share/classes/java/awt/dnd/DragSourceAdapter.java
           implements DragSourceListener, DragSourceMotionListener {
      
      +    /**
      +     * Constructs a {@code DragSourceAdapter}.
      +     */
      +    protected DragSourceAdapter() {}
      
      src/java.desktop/share/classes/java/awt/dnd/DropTargetAdapter.java
       public abstract class DropTargetAdapter implements DropTargetListener {
      
      +    /**
      +     * Constructs a {@code DropTargetAdapter}.
      +     */
      +    protected DropTargetAdapter() {}
      
      src/java.desktop/share/classes/java/awt/event/ComponentAdapter.java
       public abstract class ComponentAdapter implements ComponentListener {
      +
      +    /**
      +     * Constructs a {@code ComponentAdapter}.
      +     */
      +    protected ComponentAdapter() {}
      
      src/java.desktop/share/classes/java/awt/event/ContainerAdapter.java
       public abstract class ContainerAdapter implements ContainerListener {
      +
      +    /**
      +     * Constructs a {@code ContainerAdapter}.
      +     */
      +    protected ContainerAdapter() {}
      
      src/java.desktop/share/classes/java/awt/event/FocusAdapter.java
       public abstract class FocusAdapter implements FocusListener {
      +
      +    /**
      +     * Constructs a {@code FocusAdapter}.
      +     */
      +    protected FocusAdapter() {}
      
      src/java.desktop/share/classes/java/awt/event/HierarchyBoundsAdapter.java
       public abstract class HierarchyBoundsAdapter implements HierarchyBoundsListener
       {
      +    /**
      +     * Constructs a {@code HierarchyBoundsAdapter}.
      +     */
      +    protected HierarchyBoundsAdapter() {}
      
      src/java.desktop/share/classes/java/awt/event/KeyAdapter.java
       public abstract class KeyAdapter implements KeyListener {
      +
      +    /**
      +     * Constructs a {@code KeyAdapter}.
      +     */
      +    protected KeyAdapter() {}
      
      src/java.desktop/share/classes/java/awt/event/MouseAdapter.java
       public abstract class MouseAdapter implements MouseListener, MouseWheelListener, MouseMotionListener {
      +
      +    /**
      +     * Constructs a {@code MouseAdapter}.
      +     */
      +    protected MouseAdapter() {}
      
      src/java.desktop/share/classes/java/awt/event/MouseMotionAdapter.java
       public abstract class MouseMotionAdapter implements MouseMotionListener {
      +
      +    /**
      +     * Constructs a {@code MouseMotionAdapter}.
      +     */
      +    protected MouseMotionAdapter() {}
      
      src/java.desktop/share/classes/java/awt/event/WindowAdapter.java
           public abstract class WindowAdapter implements WindowListener, WindowStateListener, WindowFocusListener
       {
      +    /**
      +     * Constructs a {@code WindowAdapter}.
      +     */
      +    protected WindowAdapter() {}

      Link for convenience: http://cr.openjdk.java.net/~serb/8250856/webrev.00

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              serb Sergey Bylokhov
              Reporter:
              prr Philip Race
              Reviewed By:
              Philip Race
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: