changeset 60657:2c7b5ae39c19

8250852: Address reliance on default constructors in the javax.swing.plaf.basic APIs Reviewed-by: serb, aivanov
author psadhukhan
date Wed, 19 Aug 2020 11:49:54 +0530
parents 770c5fe491b1
children ea4c71fe7b8f
files src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuBarUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPanelUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPasswordFieldUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRootPaneUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSeparatorUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java
diffstat 20 files changed, 199 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -71,6 +71,11 @@
     private Rectangle paintIconR = new Rectangle();
     private Rectangle paintTextR = new Rectangle();
 
+    /**
+     * Constructs a {@code BasicLabelUI}.
+     */
+    public BasicLabelUI() {}
+
     static void loadActionMap(LazyActionMap map) {
         map.put(new Actions(Actions.PRESS));
         map.put(new Actions(Actions.RELEASE));
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -199,6 +199,11 @@
 
     private static final int DROP_LINE_THICKNESS = 2;
 
+    /**
+     * Constructs a {@code BasicListUI}.
+     */
+    public BasicListUI() {}
+
     static void loadActionMap(LazyActionMap map) {
         map.put(new Actions(Actions.SELECT_PREVIOUS_COLUMN));
         map.put(new Actions(Actions.SELECT_PREVIOUS_COLUMN_EXTEND));
@@ -1577,6 +1582,11 @@
     @SuppressWarnings("serial") // Same-version serialization only
     public class MouseInputHandler implements MouseInputListener
     {
+        /**
+         * Constructs a {@code MouseInputHandler}.
+         */
+        public MouseInputHandler() {}
+
         public void mouseClicked(MouseEvent e) {
             getHandler().mouseClicked(e);
         }
@@ -1641,6 +1651,11 @@
     public class FocusHandler implements FocusListener
     {
         /**
+         * Constructs a {@code FocusHandler}.
+         */
+        public FocusHandler() {}
+
+        /**
          * Repaints focused cells.
          */
         protected void repaintCellFocus()
@@ -1691,6 +1706,11 @@
     @SuppressWarnings("serial") // Same-version serialization only
     public class ListSelectionHandler implements ListSelectionListener
     {
+        /**
+         * Constructs a {@code ListSelectionHandler}.
+         */
+        public ListSelectionHandler() {}
+
         public void valueChanged(ListSelectionEvent e)
         {
             getHandler().valueChanged(e);
@@ -1752,6 +1772,11 @@
     @SuppressWarnings("serial") // Same-version serialization only
     public class ListDataHandler implements ListDataListener
     {
+        /**
+         * Constructs a {@code ListDataHandler}.
+         */
+        public ListDataHandler() {}
+
         public void intervalAdded(ListDataEvent e) {
             getHandler().intervalAdded(e);
         }
@@ -1820,6 +1845,11 @@
     @SuppressWarnings("serial") // Same-version serialization only
     public class PropertyChangeHandler implements PropertyChangeListener
     {
+        /**
+         * Constructs a {@code PropertyChangeHandler}.
+         */
+        public PropertyChangeHandler() {}
+
         public void propertyChange(PropertyChangeEvent e)
         {
             getHandler().propertyChange(e);
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java	Wed Aug 19 11:49:54 2020 +0530
@@ -128,6 +128,11 @@
     private PropertyChangeListener disposer = null;
 
     /**
+     * Constructor for subclasses to call.
+     */
+    protected BasicLookAndFeel() {}
+
+    /**
      * Returns the look and feel defaults. The returned {@code UIDefaults}
      * is populated by invoking, in order, {@code initClassDefaults},
      * {@code initSystemColorDefaults} and {@code initComponentDefaults}.
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuBarUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuBarUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -72,6 +72,11 @@
     private Handler handler;
 
     /**
+     * Constructs a {@code BasicMenuBarUI}.
+     */
+    public BasicMenuBarUI() {}
+
+    /**
      * Returns a new instance of {@code BasicMenuBarUI}.
      *
      * @param x a component
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -131,6 +131,11 @@
     private static final boolean VERBOSE = false; // show reuse hits/misses
     private static final boolean DEBUG =   false;  // show bad params, misc.
 
+    /**
+     * Constructs a {@code BasicMenuItemUI}.
+     */
+    public BasicMenuItemUI() {}
+
     static void loadActionMap(LazyActionMap map) {
         // NOTE: BasicMenuUI also calls into this method.
         map.put(new Actions(Actions.CLICK));
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -71,6 +71,11 @@
     private static boolean crossMenuMnemonic = true;
 
     /**
+     * Constructs a {@code BasicMenuUI}.
+     */
+    public BasicMenuUI() {}
+
+    /**
      * Constructs a new instance of {@code BasicMenuUI}.
      *
      * @param x a component
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -127,6 +127,11 @@
         }
     }
 
+    /**
+     * Constructs a {@code BasicOptionPaneUI}.
+     */
+    public BasicOptionPaneUI() {}
+
     static void loadActionMap(LazyActionMap map) {
         map.put(new Actions(Actions.CLOSE));
         BasicLookAndFeel.installAudioActionMap(map);
@@ -1258,6 +1263,11 @@
      */
     public class PropertyChangeHandler implements PropertyChangeListener {
         /**
+         * Constructs a {@code PropertyChangeHandler}.
+         */
+        public PropertyChangeHandler() {}
+
+        /**
          * If the source of the PropertyChangeEvent <code>e</code> equals the
          * optionPane and is one of the ICON_PROPERTY, MESSAGE_PROPERTY,
          * OPTIONS_PROPERTY or INITIAL_VALUE_PROPERTY,
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPanelUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPanelUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -44,6 +44,11 @@
     private static PanelUI panelUI;
 
     /**
+     * Constructs a {@code BasicPanelUI}.
+     */
+    public BasicPanelUI() {}
+
+    /**
      * Returns an instance of {@code BasicPanelUI}.
      *
      * @param c a component
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPasswordFieldUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPasswordFieldUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -43,6 +43,11 @@
 public class BasicPasswordFieldUI extends BasicTextFieldUI {
 
     /**
+     * Constructs a {@code BasicPasswordFieldUI}.
+     */
+    public BasicPasswordFieldUI() {}
+
+    /**
      * Creates a UI for a JPasswordField.
      *
      * @param c the JPasswordField
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuSeparatorUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -43,6 +43,11 @@
 public class BasicPopupMenuSeparatorUI extends BasicSeparatorUI
 {
     /**
+     * Constructs a {@code BasicPopupMenuSeparatorUI}.
+     */
+    public BasicPopupMenuSeparatorUI() {}
+
+    /**
      * Returns a new instance of {@code BasicPopupMenuSeparatorUI}.
      *
      * @param c a component
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -134,6 +134,11 @@
     private int maxPosition = 0; //maximum X (horiz) or Y box location
 
     /**
+     * Constructs a {@code BasicProgressBarUI}.
+     */
+    public BasicProgressBarUI() {}
+
+    /**
      * Returns a new instance of {@code BasicProgressBarUI}.
      *
      * @param x a component
@@ -1288,6 +1293,11 @@
      * Instantiate it only within subclasses of {@code BasicProgressBarUI}.
      */
     public class ChangeHandler implements ChangeListener {
+        /**
+         * Constructs a {@code ChangeHandler}.
+         */
+        public ChangeHandler() {}
+
         // NOTE: This class exists only for backward compatibility. All
         // its functionality has been moved into Handler. If you need to add
         // new functionality add it to the Handler, but make sure this
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRadioButtonMenuItemUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -40,6 +40,11 @@
 public class BasicRadioButtonMenuItemUI extends BasicMenuItemUI
 {
     /**
+     * Constructs a {@code BasicRadioButtonMenuItemUI}.
+     */
+    public BasicRadioButtonMenuItemUI() {}
+
+    /**
      * Returns a new instance of {@code BasicRadioButtonMenuItemUI}.
      *
      * @param b a component
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -62,6 +62,11 @@
     // ********************************
 
     /**
+     * Constructs a {@code BasicRadioButtonUI}.
+     */
+    public BasicRadioButtonUI() {}
+
+    /**
      * Returns an instance of {@code BasicRadioButtonUI}.
      *
      * @param b a component
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRootPaneUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicRootPaneUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -49,6 +49,11 @@
     private static RootPaneUI rootPaneUI = new BasicRootPaneUI();
 
     /**
+     * Constructs a {@code BasicRootPaneUI}.
+     */
+    public BasicRootPaneUI() {}
+
+    /**
      * Returns a new instance of {@code BasicRootPaneUI}.
      *
      * @param c a component
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -163,6 +163,11 @@
      */
     protected int decrGap;
 
+    /**
+     * Constructs a {@code BasicScrollBarUI}.
+     */
+    public BasicScrollBarUI() {}
+
     static void loadActionMap(LazyActionMap map) {
         map.put(new Actions(Actions.POSITIVE_UNIT_INCREMENT));
         map.put(new Actions(Actions.POSITIVE_BLOCK_INCREMENT));
@@ -1645,6 +1650,11 @@
     /** Property change handler */
     public class PropertyChangeHandler implements PropertyChangeListener
     {
+        /**
+         * Constructs a {@code PropertyChangeHandler}.
+         */
+        public PropertyChangeHandler() {}
+
         // NOTE: This class exists only for backward compatibility. All
         // its functionality has been moved into Handler. If you need to add
         // new functionality add it to the Handler, but make sure this
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicScrollPaneUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -99,6 +99,11 @@
     private boolean setValueCalled = false;
 
     /**
+     * Constructs a {@code BasicScrollPaneUI}.
+     */
+    public BasicScrollPaneUI() {}
+
+    /**
      * Returns a new instance of {@code BasicScrollPaneUI}.
      *
      * @param x a component.
@@ -494,6 +499,10 @@
      */
     public class ViewportChangeHandler implements ChangeListener
     {
+        /**
+         * Constructs a {@code ViewportChangeHandler}.
+         */
+        public ViewportChangeHandler() {}
 
         // NOTE: This class exists only for backward compatibility. All
         // its functionality has been moved into Handler. If you need to add
@@ -520,6 +529,10 @@
      */
     public class HSBChangeListener implements ChangeListener
     {
+        /**
+         * Constructs a {@code HSBChangeListener}.
+         */
+        public HSBChangeListener() {}
 
         // NOTE: This class exists only for backward compatibility. All
         // its functionality has been moved into Handler. If you need to add
@@ -555,6 +568,10 @@
      */
     public class VSBChangeListener implements ChangeListener
     {
+        /**
+         * Constructs a {@code VSBChangeListener}.
+         */
+        public VSBChangeListener() {}
 
         // NOTE: This class exists only for backward compatibility. All
         // its functionality has been moved into Handler. If you need to add
@@ -751,6 +768,10 @@
      */
     public class PropertyChangeHandler implements PropertyChangeListener
     {
+        /**
+         * Constructs a {@code PropertyChangeHandler}.
+         */
+        public PropertyChangeHandler() {}
 
         // NOTE: This class exists only for backward compatibility. All
         // its functionality has been moved into Handler. If you need to add
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSeparatorUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSeparatorUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -56,6 +56,11 @@
     protected Color highlight;
 
     /**
+     * Constructs a {@code BasicSeparatorUI}.
+     */
+    public BasicSeparatorUI() {}
+
+    /**
      * Returns a new instance of {@code BasicSeparatorUI}.
      *
      * @param c a component
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -117,6 +117,11 @@
     private boolean sameLabelBaselines;
 
     /**
+     * Constructs a {@code BasicSliderUI}.
+     */
+    public BasicSliderUI() {}
+
+    /**
      * Returns the shadow color.
      * @return the shadow color
      */
@@ -918,6 +923,11 @@
      * A property change handler.
      */
     public class PropertyChangeHandler implements PropertyChangeListener {
+        /**
+         * Constructs a {@code PropertyChangeHandler}.
+         */
+        public PropertyChangeHandler() {}
+
         // NOTE: This class exists only for backward compatibility. All
         // its functionality has been moved into Handler. If you need to add
         // new functionality add it to the Handler, but make sure this
@@ -1863,6 +1873,11 @@
      * Instantiate it only within subclasses of <code>Foo</code>.
      */
     public class ChangeHandler implements ChangeListener {
+        /**
+         * Constructs a {@code ChangeHandler}.
+         */
+        public ChangeHandler() {}
+
         // NOTE: This class exists only for backward compatibility. All
         // its functionality has been moved into Handler. If you need to add
         // new functionality add it to the Handler, but make sure this
@@ -1890,6 +1905,11 @@
         protected transient int currentMouseY;
 
         /**
+         * Constructs a {@code TrackListener}.
+         */
+        public TrackListener() {}
+
+        /**
          * {@inheritDoc}
          */
         public void mouseReleased(MouseEvent e) {
@@ -2200,6 +2220,11 @@
      * Instantiate it only within subclasses of <code>Foo</code>.
      */
     public class ComponentHandler extends ComponentAdapter {
+        /**
+         * Constructs a {@code ComponentHandler}.
+         */
+        public ComponentHandler() {}
+
         // NOTE: This class exists only for backward compatibility. All
         // its functionality has been moved into Handler. If you need to add
         // new functionality add it to the Handler, but make sure this
@@ -2216,6 +2241,11 @@
      * Instantiate it only within subclasses of <code>Foo</code>.
      */
     public class FocusHandler implements FocusListener {
+        /**
+         * Constructs a {@code FocusHandler}.
+         */
+        public FocusHandler() {}
+
         // NOTE: This class exists only for backward compatibility. All
         // its functionality has been moved into Handler. If you need to add
         // new functionality add it to the Handler, but make sure this
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -80,6 +80,10 @@
      */
     private static final Dimension zeroSize = new Dimension(0, 0);
 
+    /**
+     * Constructs a {@code BasicSpinnerUI}.
+     */
+    public BasicSpinnerUI() {}
 
     /**
      * Returns a new instance of BasicSpinnerUI.  SpinnerListUI
--- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java	Wed Aug 19 11:47:48 2020 +0530
+++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java	Wed Aug 19 11:49:54 2020 +0530
@@ -286,6 +286,10 @@
     /** If true, setDividerLocation does nothing. */
     boolean             ignoreDividerLocationChange;
 
+    /**
+     * Constructs a {@code BasicSplitPaneUI}.
+     */
+    public BasicSplitPaneUI() {}
 
     /**
      * Creates a new instance of {@code BasicSplitPaneUI}.
@@ -734,6 +738,11 @@
      */
     public class FocusHandler extends FocusAdapter
     {
+        /**
+         * Constructs a {@code FocusHandler}.
+         */
+        public FocusHandler() {}
+
         // NOTE: This class exists only for backward compatibility. All
         // its functionality has been moved into Handler. If you need to add
         // new functionality add it to the Handler, but make sure this
@@ -774,6 +783,11 @@
      */
     public class KeyboardDownRightHandler implements ActionListener
     {
+        /**
+         * Constructs a {@code KeyboardDownRightHandler}.
+         */
+        public KeyboardDownRightHandler() {}
+
         public void actionPerformed(ActionEvent ev) {
             if (dividerKeyboardResize) {
                 splitPane.setDividerLocation(getDividerLocation(splitPane) +
@@ -792,6 +806,11 @@
      */
     public class KeyboardHomeHandler implements ActionListener
     {
+        /**
+         * Constructs a {@code KeyboardHomeHandler}.
+         */
+        public KeyboardHomeHandler() {}
+
         public void actionPerformed(ActionEvent ev) {
             if (dividerKeyboardResize) {
                 splitPane.setDividerLocation(0);
@@ -809,6 +828,11 @@
      */
     public class KeyboardEndHandler implements ActionListener
     {
+        /**
+         * Constructs a {@code KeyboardEndHandler}.
+         */
+        public KeyboardEndHandler() {}
+
         public void actionPerformed(ActionEvent ev) {
             if (dividerKeyboardResize) {
                 Insets   insets = splitPane.getInsets();