Skip to content

Commit

Permalink
8250853: Address reliance on default constructors in the javax.swing …
Browse files Browse the repository at this point in the history
…APIs

Reviewed-by: serb
  • Loading branch information
prsadhuk committed Aug 26, 2020
1 parent fa31c0d commit 4b8ea58
Show file tree
Hide file tree
Showing 44 changed files with 294 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ public abstract class AbstractButton extends JComponent implements ItemSelectabl

private boolean hideActionText = false;

/**
* Constructor for subclasses to call.
*/
protected AbstractButton() {}

/**
* Sets the <code>hideActionText</code> property, which determines
* whether the button displays text from the <code>Action</code>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public abstract class AbstractCellEditor implements CellEditor, Serializable {
*/
protected transient ChangeEvent changeEvent = null;

/**
* Constructor for subclasses to call.
*/
protected AbstractCellEditor() {}

// Force this to be implemented.
// public Object getCellEditorValue()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public abstract class AbstractListModel<E> implements ListModel<E>, Serializable
*/
protected EventListenerList listenerList = new EventListenerList();

/**
* Constructor for subclasses to call.
*/
protected AbstractListModel() {}

/**
* Adds a listener to the list that's notified each time a change
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public abstract class AbstractSpinnerModel implements SpinnerModel, Serializable
*/
protected EventListenerList listenerList = new EventListenerList();

/**
* Constructor for subclasses to call.
*/
protected AbstractSpinnerModel() {}

/**
* Adds a ChangeListener to the model's listener list. The
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public class DefaultDesktopManager implements DesktopManager, java.io.Serializab
*/
private transient boolean didDrag;

/**
* Constructs a {@code DefaultDesktopManager}.
*/
public DefaultDesktopManager() {}

/** Normally this method will not be called. If it is, it
* tries to determine the appropriate parent from the desktopIcon of the frame.
* Will remove the desktopIcon from its parent if it successfully adds the frame.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,5 +351,9 @@ public void firePropertyChange(String propertyName, boolean oldValue, boolean ne
public static class UIResource extends DefaultListCellRenderer
implements javax.swing.plaf.UIResource
{
/**
* Constructs a {@code UIResource}.
*/
public UIResource() {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public class DefaultListModel<E> extends AbstractListModel<E>
{
private Vector<E> delegate = new Vector<E>();

/**
* Constructs a {@code DefaultListModel}.
*/
public DefaultListModel() {}

/**
* Returns the number of components in this list.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable,
*/
protected boolean leadAnchorNotificationEnabled = true;

/**
* Constructs a {@code DefaultListSelectionModel}.
*/
public DefaultListSelectionModel() {}

/** {@inheritDoc} */
public int getMinSelectionIndex() { return isSelectionEmpty() ? -1 : minIndex; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public class DefaultSingleSelectionModel implements SingleSelectionModel,

private int index = -1;

/**
* Constructs a {@code DefaultSingleSelectionModel}.
*/
public DefaultSingleSelectionModel() {}

/**
* {@inheritDoc}
*/
Expand Down
5 changes: 5 additions & 0 deletions src/java.desktop/share/classes/javax/swing/FocusManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public abstract class FocusManager extends DefaultKeyboardFocusManager {

private static boolean enabled = true;

/**
* Constructor for subclasses to call.
*/
protected FocusManager() {}

/**
* Returns the current <code>KeyboardFocusManager</code> instance
* for the calling thread's context.
Expand Down
5 changes: 5 additions & 0 deletions src/java.desktop/share/classes/javax/swing/InputVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@
*/
public abstract class InputVerifier {

/**
* Constructor for subclasses to call.
*/
protected InputVerifier() {}

/**
* Checks whether the JComponent's input is valid. This method should
* have no side effects. It returns a boolean indicating the status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
public abstract class InternalFrameFocusTraversalPolicy
extends FocusTraversalPolicy
{
/**
* Constructor for subclasses to call.
*/
protected InternalFrameFocusTraversalPolicy() {}

/**
* Returns the Component that should receive the focus when a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,11 @@ private AbstractFormatterFactory getDefaultFormatterFactory(Object type) {
* @since 1.4
*/
public abstract static class AbstractFormatterFactory {
/**
* Constructor for subclasses to call.
*/
protected AbstractFormatterFactory() {}

/**
* Returns an <code>AbstractFormatter</code> that can handle formatting
* of the passed in <code>JFormattedTextField</code>.
Expand Down Expand Up @@ -914,6 +919,11 @@ public abstract static class AbstractFormatterFactory {
public abstract static class AbstractFormatter implements Serializable {
private JFormattedTextField ftf;

/**
* Constructor for subclasses to call.
*/
protected AbstractFormatter() {}

/**
* Installs the <code>AbstractFormatter</code> onto a particular
* <code>JFormattedTextField</code>.
Expand Down
4 changes: 4 additions & 0 deletions src/java.desktop/share/classes/javax/swing/LookAndFeel.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
*/
public abstract class LookAndFeel
{
/**
* Constructor for subclasses to call.
*/
protected LookAndFeel() {}

/**
* Convenience method for setting a component's foreground
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public class MenuSelectionManager {
private static final StringBuilder MENU_SELECTION_MANAGER_KEY =
new StringBuilder("javax.swing.MenuSelectionManager");

/**
* Constructs a {@code MenuSelectionManager}.
*/
public MenuSelectionManager() {}

/**
* Returns the default menu selection manager.
*
Expand Down
4 changes: 4 additions & 0 deletions src/java.desktop/share/classes/javax/swing/PopupFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ public Popup getHeavyWeightPopup(PopupFactory factory, Component owner,
*/
private int popupType = LIGHT_WEIGHT_POPUP;

/**
* Constructs a {@code PopupFactory}.
*/
public PopupFactory() {}

/**
* Sets the <code>PopupFactory</code> that will be used to obtain
Expand Down
5 changes: 5 additions & 0 deletions src/java.desktop/share/classes/javax/swing/RowFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ public enum ComparisonType {
NOT_EQUAL
}

/**
* Constructor for subclasses to call.
*/
protected RowFilter() {}

/**
* Throws an IllegalArgumentException if any of the values in
* columns are {@literal <} 0.
Expand Down
11 changes: 10 additions & 1 deletion src/java.desktop/share/classes/javax/swing/ScrollPaneLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ public class ScrollPaneLayout
*/
protected int hsbPolicy = HORIZONTAL_SCROLLBAR_AS_NEEDED;

/**
* Constructs a {@code ScrollPaneLayout}.
*/
public ScrollPaneLayout() {}

/**
* This method is invoked after the ScrollPaneLayout is set as the
Expand Down Expand Up @@ -1116,5 +1120,10 @@ public Rectangle getViewportBorderBounds(JScrollPane scrollpane) {
/**
* The UI resource version of <code>ScrollPaneLayout</code>.
*/
public static class UIResource extends ScrollPaneLayout implements javax.swing.plaf.UIResource {}
public static class UIResource extends ScrollPaneLayout implements javax.swing.plaf.UIResource {
/**
* Constructs a {@code UIResource}.
*/
public UIResource() {}
}
}
5 changes: 5 additions & 0 deletions src/java.desktop/share/classes/javax/swing/UIManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ private static class LAFState
*/
private static final Object classLock = new Object();

/**
* Constructs a {@code UIManager}.
*/
public UIManager() {}

/**
* Return the <code>LAFState</code> object, lazily create one if necessary.
* All access to the <code>LAFState</code> fields is done via this method,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public class ViewportLayout implements LayoutManager, Serializable
// Single instance used by JViewport.
static ViewportLayout SHARED_INSTANCE = new ViewportLayout();

/**
* Constructs a {@code ViewportLayout}.
*/
public ViewportLayout() {}

/**
* Adds the specified component to the layout. Not used by this class.
* @param name the name of the component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
@SuppressWarnings("serial")
public abstract class AbstractBorder implements Border, Serializable
{
/**
* Constructor for subclasses to call.
*/
protected AbstractBorder() {}

/**
* This default implementation does no painting.
* @param c the component for which this border is being painted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public void propertyChange(PropertyChangeEvent event) {
*/
private JColorChooser chooser;

/**
* Constructor for subclasses to call.
*/
protected AbstractColorChooserPanel() {}

/**
* Invoked automatically when the model's state changes.
* It is also called by <code>installChooserPanel</code> to allow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public class EventListenerList implements Serializable {
/** The list of ListenerType - Listener pairs */
protected transient volatile Object[] listenerList = NULL_ARRAY;

/**
* Constructs a {@code EventListenerList}.
*/
public EventListenerList() {}

/**
* Passes back the event listener list as an array
* of ListenerType-listener pairs. Note that for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
* @author Thomas Ball
*/
public abstract class InternalFrameAdapter implements InternalFrameListener {
/**
* Constructor for subclasses to call.
*/
protected InternalFrameAdapter() {}

/**
* Invoked when an internal frame has been opened.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@
*/
public abstract class MouseInputAdapter extends MouseAdapter
implements MouseInputListener {
/**
* Constructor for subclasses to call.
*/
protected MouseInputAdapter() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
* @author Jeff Dinkins
*/
public abstract class FileFilter {
/**
* Constructor for subclasses to call.
*/
protected FileFilter() {}

/**
* Whether the given file is accepted by this filter.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
*
*/
public abstract class FileView {
/**
* Constructor for subclasses to call.
*/
protected FileView() {}

/**
* The name of the file. Normally this would be simply
* <code>f.getName()</code>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public abstract class AbstractTableModel implements TableModel, Serializable
/** List of listeners */
protected EventListenerList listenerList = new EventListenerList();

/**
* Constructor for subclasses to call.
*/
protected AbstractTableModel() {}

//
// Default Implementation of the Interface
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ protected void setValue(Object value) {
public static class UIResource extends DefaultTableCellRenderer
implements javax.swing.plaf.UIResource
{
/**
* Constructs a {@code UIResource}.
*/
public UIResource() {}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
* @since 1.6
*/
public abstract class TableStringConverter {
/**
* Constructor for subclasses to call.
*/
protected TableStringConverter() {}

/**
* Returns the string representation of the value at the specified
* location.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
*/
@Deprecated
public abstract class DefaultTextUI extends BasicTextUI {

/**
* Constructor for subclasses to call.
*/
protected DefaultTextUI() {}

}
Loading

0 comments on commit 4b8ea58

Please sign in to comment.