<Swing Dev> JDK 9 RFR of JDK-8033221: Fix serial lint warnings in sun.swing.*

Joe Darcy joe.darcy at oracle.com
Thu Jan 30 16:19:41 UTC 2014


On 01/30/2014 05:05 AM, Sergey Bylokhov wrote:
> Hi, Joe.
> It seems to me that in this fix we actually suppress a bugs. These 
> classes can be extended from the public classes, and can be assigned 
> to the parent.
> If serialization of these classes are not supported, we should block 
> it via readObject+writeObject with assertion error, if it is supported 
> it should be implemented.

Many of the public javax.* swing classes contain a disclaimer "this 
class is marked serializable, but instead of the usual guarantees that 
provides about cross-version migration, we only promise you can 
serialize and deserialize on the same version of the platform." Those 
classes don't define serialVersionUIDs and a recently pushed a changeset 
to suppress serial warnings on those classes.

     8032627: Add @SuppressWarnings("serial") to appropriate javax.swing 
classes

The classes in question here are sun.* classes and therefore *not* part 
of the public API of the JDK. Therefore, there should be no implied 
expectation about serial compatibility across versions; therefore, to 
address the lint warning, I choose to suppress the warning rather than 
add a serialVersionUID.

Thanks,

-Joe

>
> On 30.01.2014 9:17, Joe Darcy wrote:
>> Hello,
>>
>> As the another installment of addressing the serial warnings in the 
>> client libraries, please review my changes for:
>>
>>     JDK-8033221: Fix serial lint warnings in sun.swing.*
>>     http://cr.openjdk.java.net/~darcy/8033221.0/
>>
>> Patch below.
>>
>> Thanks,
>>
>> -Joe
>>
>> --- old/src/share/classes/sun/swing/AbstractFilterComboBoxModel.java 
>> 2014-01-29 21:14:19.000000000 -0800
>> +++ new/src/share/classes/sun/swing/AbstractFilterComboBoxModel.java 
>> 2014-01-29 21:14:19.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2013, Oracle and/or its affiliates. All rights 
>> reserved.
>> + * Copyright (c) 2013, 2014, 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
>> @@ -34,6 +34,7 @@
>>  /**
>>   * Data model for a type-face selection combo-box.
>>   */
>> + at SuppressWarnings("serial") // JDK-implementation class
>>  public abstract class AbstractFilterComboBoxModel
>>          extends AbstractListModel<FileFilter>
>>          implements ComboBoxModel<FileFilter>, PropertyChangeListener {
>> --- old/src/share/classes/sun/swing/BakedArrayList.java 2014-01-29 
>> 21:14:20.000000000 -0800
>> +++ new/src/share/classes/sun/swing/BakedArrayList.java 2014-01-29 
>> 21:14:20.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2003, Oracle and/or its affiliates. All rights 
>> reserved.
>> + * Copyright (c) 2003, 2014, 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
>> @@ -43,6 +43,7 @@
>>   *
>>   * @author Scott Violet
>>   */
>> + at SuppressWarnings("serial") // JDK-implementation class
>>  public class BakedArrayList extends ArrayList {
>>      /**
>>       * The cached hashCode.
>> --- old/src/share/classes/sun/swing/FilePane.java    2014-01-29 
>> 21:14:20.000000000 -0800
>> +++ new/src/share/classes/sun/swing/FilePane.java    2014-01-29 
>> 21:14:20.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All 
>> rights reserved.
>> + * Copyright (c) 2003, 2014, 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
>> @@ -58,6 +58,7 @@
>>   *
>>   * @author Leif Samuelsson
>>   */
>> + at SuppressWarnings("serial") // JDK-implementation class
>>  public class FilePane extends JPanel implements 
>> PropertyChangeListener {
>>      // Constants for actions. These are used for the actions' 
>> ACTION_COMMAND_KEY
>>      // and as keys in the action maps for FilePane and the 
>> corresponding UI classes
>> @@ -391,6 +392,7 @@
>>          firePropertyChange("viewType", oldValue, viewType);
>>      }
>>
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      class ViewTypeAction extends AbstractAction {
>>          private int viewType;
>>
>> @@ -470,6 +472,7 @@
>>       */
>>      public Action[] getActions() {
>>          if (actions == null) {
>> +            @SuppressWarnings("serial") // JDK-implementation class
>>              class FilePaneAction extends AbstractAction {
>>                  FilePaneAction(String name) {
>>                      this(name, name);
>> @@ -577,6 +580,8 @@
>>      public JPanel createList() {
>>          JPanel p = new JPanel(new BorderLayout());
>>          final JFileChooser fileChooser = getFileChooser();
>> +
>> +        @SuppressWarnings("serial") // anonymous class
>>          final JList<Object> list = new JList<Object>() {
>>              public int getNextMatch(String prefix, int startIndex, 
>> Position.Bias bias) {
>>                  ListModel model = getModel();
>> @@ -651,6 +656,7 @@
>>      /**
>>       * This model allows for sorting JList
>>       */
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      private class SortableListModel extends AbstractListModel<Object>
>>              implements TableModelListener, RowSorterListener {
>>
>> @@ -684,6 +690,7 @@
>>          return detailsTableModel;
>>      }
>>
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      class DetailsTableModel extends AbstractTableModel implements 
>> ListDataListener {
>>          JFileChooser chooser;
>>          BasicDirectoryModel directoryModel;
>> @@ -1003,6 +1010,7 @@
>>          return tableCellEditor;
>>      }
>>
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      private class DetailsTableCellEditor extends DefaultCellEditor {
>>          private final JTextField tf;
>>
>> @@ -1025,7 +1033,7 @@
>>          }
>>      }
>>
>> -
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      class DetailsTableCellRenderer extends DefaultTableCellRenderer {
>>          JFileChooser chooser;
>>          DateFormat df;
>> @@ -1129,6 +1137,7 @@
>>
>>          JPanel p = new JPanel(new BorderLayout());
>>
>> +        @SuppressWarnings("serial") // anonymous class
>>          final JTable detailsTable = new 
>> JTable(getDetailsTableModel()) {
>>              // Handle Escape key events here
>>              protected boolean processKeyBinding(KeyStroke ks, 
>> KeyEvent e, int condition, boolean pressed) {
>> @@ -1447,6 +1456,7 @@
>>
>>      protected Action newFolderAction;
>>
>> +    @SuppressWarnings("serial") // anonymous class inside
>>      public Action getNewFolderAction() {
>>          if (!readOnly && newFolderAction == null) {
>>              newFolderAction = new 
>> AbstractAction(newFolderActionLabelText) {
>> @@ -1479,8 +1489,9 @@
>>          return newFolderAction;
>>      }
>>
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      protected class FileRenderer extends DefaultListCellRenderer {
>> -
>> +
>>          public Component getListCellRendererComponent(JList list, 
>> Object value,
>>                                                        int index, 
>> boolean isSelected,
>>                                                        boolean 
>> cellHasFocus) {
>> --- old/src/share/classes/sun/swing/ImageIconUIResource.java 
>> 2014-01-29 21:14:21.000000000 -0800
>> +++ new/src/share/classes/sun/swing/ImageIconUIResource.java 
>> 2014-01-29 21:14:21.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2004, Oracle and/or its affiliates. All rights 
>> reserved.
>> + * Copyright (c) 2004, 2014, 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
>> @@ -35,6 +35,7 @@
>>   * @author Shannon Hickey
>>   *
>>   */
>> + at SuppressWarnings("serial") // JDK-implementation class
>>  public class ImageIconUIResource extends ImageIcon implements 
>> UIResource {
>>
>>      /**
>> --- old/src/share/classes/sun/swing/JLightweightFrame.java 2014-01-29 
>> 21:14:21.000000000 -0800
>> +++ new/src/share/classes/sun/swing/JLightweightFrame.java 2014-01-29 
>> 21:14:21.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2013, Oracle and/or its affiliates. All rights 
>> reserved.
>> + * Copyright (c) 2013, 2014, 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
>> @@ -64,6 +64,7 @@
>>   * @author Artem Ananiev
>>   * @author Anton Tarasov
>>   */
>> + at SuppressWarnings("serial") // JDK-implementation class
>>  public final class JLightweightFrame extends LightweightFrame 
>> implements RootPaneContainer {
>>
>>      private final JRootPane rootPane = new JRootPane();
>> @@ -209,6 +210,7 @@
>>          }
>>      }
>>
>> +    @SuppressWarnings("serial") // anonymous class inside
>>      private void initInterior() {
>>          contentPane = new JPanel() {
>>              @Override
>> --- old/src/share/classes/sun/swing/PrintColorUIResource.java 
>> 2014-01-29 21:14:22.000000000 -0800
>> +++ new/src/share/classes/sun/swing/PrintColorUIResource.java 
>> 2014-01-29 21:14:22.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All 
>> rights reserved.
>> + * Copyright (c) 2004, 2014, 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
>> @@ -36,6 +36,7 @@
>>   * @author Shannon Hickey
>>   *
>>   */
>> + at SuppressWarnings("serial") // JDK-implementation class
>>  public class PrintColorUIResource extends ColorUIResource {
>>
>>      /** The color to use during printing */
>> --- old/src/share/classes/sun/swing/PrintingStatus.java 2014-01-29 
>> 21:14:22.000000000 -0800
>> +++ new/src/share/classes/sun/swing/PrintingStatus.java 2014-01-29 
>> 21:14:22.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All 
>> rights reserved.
>> + * Copyright (c) 2005, 2014, 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
>> @@ -62,6 +62,7 @@
>>      private final AtomicBoolean isAborted = new AtomicBoolean(false);
>>
>>      // the action that will abort printing
>> +    @SuppressWarnings("serial") // anonymous class
>>      private final Action abortAction = new AbstractAction() {
>>          public void actionPerformed(ActionEvent ae) {
>>              if (!isAborted.get()) {
>> --- old/src/share/classes/sun/swing/WindowsPlacesBar.java 2014-01-29 
>> 21:14:23.000000000 -0800
>> +++ new/src/share/classes/sun/swing/WindowsPlacesBar.java 2014-01-29 
>> 21:14:23.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All 
>> rights reserved.
>> + * Copyright (c) 2003, 2014, 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
>> @@ -47,6 +47,7 @@
>>   *
>>   * @author Leif Samuelsson
>>   */
>> + at SuppressWarnings("serial") // JDK-implementation class
>>  public class WindowsPlacesBar extends JToolBar
>>                                implements ActionListener, 
>> PropertyChangeListener {
>>      JFileChooser fc;
>> --- old/src/share/classes/sun/swing/icon/SortArrowIcon.java 
>> 2014-01-29 21:14:23.000000000 -0800
>> +++ new/src/share/classes/sun/swing/icon/SortArrowIcon.java 
>> 2014-01-29 21:14:23.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2005, Oracle and/or its affiliates. All rights 
>> reserved.
>> + * Copyright (c) 2005, 2014, 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
>> @@ -36,6 +36,7 @@
>>   * Sorting icon.
>>   *
>>   */
>> + at SuppressWarnings("serial") // JDK-implementation class
>>  public class SortArrowIcon implements Icon, UIResource, Serializable {
>>      // Height of the arrow, the width is ARROW_HEIGHT
>>      private static final int ARROW_HEIGHT = 5;
>> --- 
>> old/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUI.java 
>> 2014-01-29 21:14:24.000000000 -0800
>> +++ 
>> new/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUI.java 
>> 2014-01-29 21:14:24.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All 
>> rights reserved.
>> + * Copyright (c) 2002, 2014, 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
>> @@ -303,6 +303,7 @@
>>      /**
>>       * Responds to a File Name completion request (e.g. Tab)
>>       */
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      private class FileNameCompletionAction extends AbstractAction {
>>          protected FileNameCompletionAction() {
>>              super("fileNameCompletion");
>> @@ -538,6 +539,7 @@
>>      public void clearIconCache() { }
>>
>>      // Copied as SynthBorder is package private in synth
>> +    @SuppressWarnings("serial") // JDK-implementation clas
>>      private class UIBorder extends AbstractBorder implements 
>> UIResource {
>>          private Insets _insets;
>>          UIBorder(Insets insets) {
>> --- 
>> old/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java 2014-01-29 
>> 21:14:25.000000000 -0800
>> +++ 
>> new/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java 2014-01-29 
>> 21:14:24.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All 
>> rights reserved.
>> + * Copyright (c) 2003, 2014, 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
>> @@ -190,6 +190,7 @@
>>          readOnly = UIManager.getBoolean("FileChooser.readOnly");
>>      }
>>
>> +    @SuppressWarnings("serial") // anonymous classes inside
>>      public void installComponents(JFileChooser fc) {
>>          super.installComponents(fc);
>>
>> @@ -734,6 +735,7 @@
>>      /**
>>       * Data model for a type-face selection combo-box.
>>       */
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      protected class DirectoryComboBoxModel extends 
>> AbstractListModel<File> implements ComboBoxModel<File> {
>>          Vector<File> directories = new Vector<File>();
>>          int[] depths = null;
>> @@ -863,6 +865,7 @@
>>      /**
>>       * Acts when DirectoryComboBox has changed the selected item.
>>       */
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      protected class DirectoryComboBoxAction extends AbstractAction {
>>          protected DirectoryComboBoxAction() {
>>              super("DirectoryComboBoxAction");
>> @@ -923,6 +926,7 @@
>>      /**
>>       * Data model for a type-face selection combo-box.
>>       */
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      protected class FilterComboBoxModel extends 
>> AbstractFilterComboBoxModel {
>>          protected JFileChooser getFileChooser() {
>>              return SynthFileChooserUIImpl.this.getFileChooser();
>> @@ -1012,6 +1016,7 @@
>>          }
>>      }
>>
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      private class AlignedLabel extends JLabel {
>>          private AlignedLabel[] group;
>>          private int maxWidth = 0;
>> --- 
>> old/src/share/classes/sun/swing/plaf/windows/ClassicSortArrowIcon.java 2014-01-29 
>> 21:14:25.000000000 -0800
>> +++ 
>> new/src/share/classes/sun/swing/plaf/windows/ClassicSortArrowIcon.java 2014-01-29 
>> 21:14:25.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2005, Oracle and/or its affiliates. All rights 
>> reserved.
>> + * Copyright (c) 2005, 2014, 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
>> @@ -36,6 +36,7 @@
>>   * Classic sort icons.
>>   *
>>   */
>> + at SuppressWarnings("serial") // JDK-implementation class
>>  public class ClassicSortArrowIcon implements Icon, UIResource, 
>> Serializable{
>>      private static final int X_OFFSET = 9;
>>      private boolean ascending;
>> --- 
>> old/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java 
>> 2014-01-29 21:14:26.000000000 -0800
>> +++ 
>> new/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java 
>> 2014-01-29 21:14:26.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All 
>> rights reserved.
>> + * Copyright (c) 2005, 2014, 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
>> @@ -39,6 +39,7 @@
>>  import javax.swing.border.Border;
>>  import javax.swing.table.*;
>>
>> + at SuppressWarnings("serial") // JDK-implementation class
>>  public class DefaultTableCellHeaderRenderer extends 
>> DefaultTableCellRenderer
>>          implements UIResource {
>>      private boolean horizontalTextPositionSet;
>> @@ -187,6 +188,7 @@
>>          return new Point(x, y);
>>      }
>>
>> +    @SuppressWarnings("serial") // JDK-implementation class
>>      private class EmptyIcon implements Icon, Serializable {
>>          int width = 0;
>>          int height = 0;
>> --- old/src/share/classes/sun/swing/text/TextComponentPrintable.java 
>> 2014-01-29 21:14:26.000000000 -0800
>> +++ new/src/share/classes/sun/swing/text/TextComponentPrintable.java 
>> 2014-01-29 21:14:26.000000000 -0800
>> @@ -1,5 +1,5 @@
>>  /*
>> - * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All 
>> rights reserved.
>> + * Copyright (c) 2005, 2014, 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
>> @@ -324,6 +324,7 @@
>>              }
>>          }
>>      }
>> +    @SuppressWarnings("serial") // anonymous class inside
>>      private JTextComponent createPrintShellOnEDT(final 
>> JTextComponent textComponent) {
>>          assert SwingUtilities.isEventDispatchThread();
>>
>>
>
>




More information about the swing-dev mailing list