--- old/src/share/classes/javax/swing/AbstractButton.java 2014-07-02 23:34:58.000000000 -0700 +++ new/src/share/classes/javax/swing/AbstractButton.java 2014-07-02 23:34:58.000000000 -0700 @@ -1123,7 +1123,7 @@ } } - private boolean isListener(Class c, ActionListener a) { + private boolean isListener(Class c, ActionListener a) { boolean isListener = false; Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length-2; i>=0; i-=2) { --- old/src/share/classes/javax/swing/ArrayTable.java 2014-07-02 23:34:59.000000000 -0700 +++ new/src/share/classes/javax/swing/ArrayTable.java 2014-07-02 23:34:59.000000000 -0700 @@ -133,7 +133,9 @@ if ((size==ARRAY_BOUNDARY) && isArray()) { grow(); } - ((Hashtable)table).put(key, value); + @SuppressWarnings("unchecked") + Hashtable tmp = (Hashtable)table; + tmp.put(key, value); } } } --- old/src/share/classes/javax/swing/DebugGraphics.java 2014-07-02 23:35:00.000000000 -0700 +++ new/src/share/classes/javax/swing/DebugGraphics.java 2014-07-02 23:35:00.000000000 -0700 @@ -1463,7 +1463,5 @@ } return debugGraphicsInfo; } - private static final Class debugGraphicsInfoKey = DebugGraphicsInfo.class; - - + private static final Class debugGraphicsInfoKey = DebugGraphicsInfo.class; } --- old/src/share/classes/javax/swing/DefaultCellEditor.java 2014-07-02 23:35:00.000000000 -0700 +++ new/src/share/classes/javax/swing/DefaultCellEditor.java 2014-07-02 23:35:00.000000000 -0700 @@ -131,7 +131,7 @@ * * @param comboBox a JComboBox object */ - public DefaultCellEditor(final JComboBox comboBox) { + public DefaultCellEditor(final JComboBox comboBox) { editorComponent = comboBox; comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); delegate = new EditorDelegate() { --- old/src/share/classes/javax/swing/DefaultRowSorter.java 2014-07-02 23:35:01.000000000 -0700 +++ new/src/share/classes/javax/swing/DefaultRowSorter.java 2014-07-02 23:35:01.000000000 -0700 @@ -128,7 +128,7 @@ /** * Comparators specified by column. */ - private Comparator[] comparators; + private Comparator[] comparators; /** * Whether or not the specified column is sortable, by column. @@ -143,7 +143,7 @@ /** * Cached comparators for the current sort */ - private Comparator[] sortComparators; + private Comparator[] sortComparators; /** * Developer supplied Filter. @@ -695,7 +695,7 @@ */ private void cacheSortKeys(List keys) { int keySize = keys.size(); - sortComparators = new Comparator[keySize]; + sortComparators = new Comparator[keySize]; for (int i = 0; i < keySize; i++) { sortComparators[i] = getComparator0(keys.get(i).getColumn()); } @@ -760,7 +760,7 @@ public void setComparator(int column, Comparator comparator) { checkColumn(column); if (comparators == null) { - comparators = new Comparator[getModelWrapper().getColumnCount()]; + comparators = new Comparator[getModelWrapper().getColumnCount()]; } comparators[column] = comparator; } @@ -786,8 +786,8 @@ // Returns the Comparator to use during sorting. Where as // getComparator() may return null, this will never return null. - private Comparator getComparator0(int column) { - Comparator comparator = getComparator(column); + private Comparator getComparator0(int column) { + Comparator comparator = getComparator(column); if (comparator != null) { return comparator; } @@ -965,7 +965,9 @@ } else if (v2 == null) { result = 1; } else { - result = sortComparators[counter].compare(v1, v2); + Comparator c = + (Comparator)sortComparators[counter]; + result = c.compare(v1, v2); } if (sortOrder == SortOrder.DESCENDING) { result *= -1; @@ -1364,10 +1366,10 @@ */ // NOTE: this class is static so that it can be placed in an array private static class Row implements Comparable { - private DefaultRowSorter sorter; + private DefaultRowSorter sorter; int modelIndex; - public Row(DefaultRowSorter sorter, int index) { + public Row(DefaultRowSorter sorter, int index) { this.sorter = sorter; modelIndex = index; } --- old/src/share/classes/javax/swing/JComponent.java 2014-07-02 23:35:02.000000000 -0700 +++ new/src/share/classes/javax/swing/JComponent.java 2014-07-02 23:35:01.000000000 -0700 @@ -2111,6 +2111,7 @@ private void registerWithKeyboardManager(boolean onlyIfNew) { InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false); KeyStroke[] strokes; + @SuppressWarnings("unchecked") Hashtable registered = (Hashtable)getClientProperty (WHEN_IN_FOCUSED_WINDOW_BINDINGS); @@ -2164,6 +2165,7 @@ * WHEN_IN_FOCUSED_WINDOW KeyStroke bindings. */ private void unregisterWithKeyboardManager() { + @SuppressWarnings("unchecked") Hashtable registered = (Hashtable)getClientProperty (WHEN_IN_FOCUSED_WINDOW_BINDINGS); @@ -4126,16 +4128,20 @@ setFlag(AUTOSCROLLS_SET, false); } } else if (propertyName == "focusTraversalKeysForward") { + @SuppressWarnings("unchecked") + Set strokeSet = (Set) value; if (!getFlag(FOCUS_TRAVERSAL_KEYS_FORWARD_SET)) { super.setFocusTraversalKeys(KeyboardFocusManager. FORWARD_TRAVERSAL_KEYS, - (Set)value); + strokeSet); } } else if (propertyName == "focusTraversalKeysBackward") { + @SuppressWarnings("unchecked") + Set strokeSet = (Set) value; if (!getFlag(FOCUS_TRAVERSAL_KEYS_BACKWARD_SET)) { super.setFocusTraversalKeys(KeyboardFocusManager. BACKWARD_TRAVERSAL_KEYS, - (Set)value); + strokeSet); } } else { throw new IllegalArgumentException("property \""+ @@ -4713,6 +4719,7 @@ * @see #getVetoableChangeListeners * @see #getAncestorListeners */ + @SuppressWarnings("unchecked") // Casts to (T[]) public T[] getListeners(Class listenerType) { T[] result; if (listenerType == AncestorListener.class) { --- old/src/share/classes/javax/swing/JEditorPane.java 2014-07-02 23:35:02.000000000 -0700 +++ new/src/share/classes/javax/swing/JEditorPane.java 2014-07-02 23:35:02.000000000 -0700 @@ -1191,7 +1191,7 @@ String classname = getKitTypeRegistry().get(type); ClassLoader loader = getKitLoaderRegistry().get(type); try { - Class c; + Class c; if (loader != null) { c = loader.loadClass(classname); } else { @@ -1264,18 +1264,26 @@ private static Hashtable getKitTypeRegistry() { loadDefaultKitsIfNecessary(); - return (Hashtable)SwingUtilities.appContextGet(kitTypeRegistryKey); + @SuppressWarnings("unchecked") + Hashtable tmp = + (Hashtable)SwingUtilities.appContextGet(kitTypeRegistryKey); + return tmp; } private static Hashtable getKitLoaderRegistry() { loadDefaultKitsIfNecessary(); - return (Hashtable)SwingUtilities.appContextGet(kitLoaderRegistryKey); + @SuppressWarnings("unchecked") + Hashtable tmp = + (Hashtable)SwingUtilities.appContextGet(kitLoaderRegistryKey); + return tmp; } private static Hashtable getKitRegisty() { - Hashtable ht = (Hashtable)SwingUtilities.appContextGet(kitRegistryKey); + @SuppressWarnings("unchecked") + Hashtable ht = + (Hashtable)SwingUtilities.appContextGet(kitRegistryKey); if (ht == null) { - ht = new Hashtable(3); + ht = new Hashtable<>(3); SwingUtilities.appContextPut(kitRegistryKey, ht); } return ht; @@ -1301,9 +1309,9 @@ "javax.swing.text.rtf.RTFEditorKit"); } } - Hashtable ht = new Hashtable(); + Hashtable ht = new Hashtable<>(); SwingUtilities.appContextPut(kitTypeRegistryKey, ht); - ht = new Hashtable(); + ht = new Hashtable<>(); SwingUtilities.appContextPut(kitLoaderRegistryKey, ht); for (String key : defaultEditorKitMap.keySet()) { registerEditorKitForContentType(key,defaultEditorKitMap.get(key)); --- old/src/share/classes/javax/swing/JLayer.java 2014-07-02 23:35:03.000000000 -0700 +++ new/src/share/classes/javax/swing/JLayer.java 2014-07-02 23:35:03.000000000 -0700 @@ -721,7 +721,7 @@ AWTEvent.HIERARCHY_EVENT_MASK | AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK; - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) public void eventDispatched(AWTEvent event) { Object source = event.getSource(); if (source instanceof Component) { @@ -729,7 +729,7 @@ while (component != null) { if (component instanceof JLayer) { JLayer l = (JLayer) component; - LayerUI ui = l.getUI(); + LayerUI ui = l.getUI(); if (ui != null && isEventEnabled(l.getLayerEventMask(), event.getID()) && (!(event instanceof InputEvent) || !((InputEvent)event).isConsumed())) { --- old/src/share/classes/javax/swing/JOptionPane.java 2014-07-02 23:35:03.000000000 -0700 +++ new/src/share/classes/javax/swing/JOptionPane.java 2014-07-02 23:35:03.000000000 -0700 @@ -2387,7 +2387,7 @@ throws IOException, ClassNotFoundException { s.defaultReadObject(); - Vector values = (Vector)s.readObject(); + Vector values = (Vector)s.readObject(); int indexCounter = 0; int maxCounter = values.size(); --- old/src/share/classes/javax/swing/JSpinner.java 2014-07-02 23:35:04.000000000 -0700 +++ new/src/share/classes/javax/swing/JSpinner.java 2014-07-02 23:35:04.000000000 -0700 @@ -907,7 +907,7 @@ /** * This subclass of javax.swing.DateFormatter maps the minimum/maximum - * properties to te start/end properties of a SpinnerDateModel. + * properties to the start/end properties of a SpinnerDateModel. */ private static class DateEditorFormatter extends DateFormatter { private final SpinnerDateModel model; @@ -917,19 +917,25 @@ this.model = model; } - public void setMinimum(Comparable min) { - model.setStart(min); + @Override + @SuppressWarnings("unchecked") + public void setMinimum(Comparable min) { + model.setStart((Comparable)min); } - public Comparable getMinimum() { + @Override + public Comparable getMinimum() { return model.getStart(); } - public void setMaximum(Comparable max) { - model.setEnd(max); + @Override + @SuppressWarnings("unchecked") + public void setMaximum(Comparable max) { + model.setEnd((Comparable)max); } - public Comparable getMaximum() { + @Override + public Comparable getMaximum() { return model.getEnd(); } } @@ -1095,19 +1101,23 @@ setValueClass(model.getValue().getClass()); } - public void setMinimum(Comparable min) { + @Override + public void setMinimum(Comparable min) { model.setMinimum(min); } - public Comparable getMinimum() { + @Override + public Comparable getMinimum() { return model.getMinimum(); } - public void setMaximum(Comparable max) { + @Override + public void setMaximum(Comparable max) { model.setMaximum(max); } - public Comparable getMaximum() { + @Override + public Comparable getMaximum() { return model.getMaximum(); } } --- old/src/share/classes/javax/swing/JTable.java 2014-07-02 23:35:05.000000000 -0700 +++ new/src/share/classes/javax/swing/JTable.java 2014-07-02 23:35:05.000000000 -0700 @@ -354,19 +354,23 @@ /** Identifies the row of the cell being edited. */ transient protected int editingRow; - /** + /** * A table of objects that display the contents of a cell, * indexed by class as declared in getColumnClass * in the TableModel interface. */ - transient protected Hashtable defaultRenderersByColumnClass; + transient protected Hashtable defaultRenderersByColumnClass; + // Logicaly, the above is a Hashtable, TableCellRenderer>. + // It is declared otherwise to accomodate using UIDefaults. /** * A table of objects that display and edit the contents of a cell, * indexed by class as declared in getColumnClass * in the TableModel interface. */ - transient protected Hashtable defaultEditorsByColumnClass; + transient protected Hashtable defaultEditorsByColumnClass; + // Logicaly, the above is a Hashtable, TableCellEditor>. + // It is declared otherwise to accomodate using UIDefaults. /** The foreground color of selected cells. */ protected Color selectionForeground; @@ -665,7 +669,7 @@ * @param rowData the data for the new table * @param columnNames names of each column */ - public JTable(Vector rowData, Vector columnNames) { + public JTable(Vector> rowData, Vector columnNames) { this(new DefaultTableModel(rowData, columnNames)); } @@ -1336,7 +1340,7 @@ return (TableCellRenderer)renderer; } else { - Class c = columnClass.getSuperclass(); + Class c = columnClass.getSuperclass(); if (c == null && columnClass != Object.class) { c = Object.class; } @@ -2617,7 +2621,7 @@ * @since 1.6 */ public int convertRowIndexToView(int modelRowIndex) { - RowSorter sorter = getRowSorter(); + RowSorter sorter = getRowSorter(); if (sorter != null) { return sorter.convertRowIndexToView(modelRowIndex); } @@ -2639,7 +2643,7 @@ * @since 1.6 */ public int convertRowIndexToModel(int viewRowIndex) { - RowSorter sorter = getRowSorter(); + RowSorter sorter = getRowSorter(); if (sorter != null) { return sorter.convertRowIndexToModel(viewRowIndex); } @@ -2657,7 +2661,7 @@ * @see #getColumnCount */ public int getRowCount() { - RowSorter sorter = getRowSorter(); + RowSorter sorter = getRowSorter(); if (sorter != null) { return sorter.getViewRowCount(); } @@ -3625,13 +3629,13 @@ } // Update the UIs of all the default renderers. - Enumeration defaultRenderers = defaultRenderersByColumnClass.elements(); + Enumeration defaultRenderers = defaultRenderersByColumnClass.elements(); while (defaultRenderers.hasMoreElements()) { SwingUtilities.updateRendererOrEditorUI(defaultRenderers.nextElement()); } // Update the UIs of all the default editors. - Enumeration defaultEditors = defaultEditorsByColumnClass.elements(); + Enumeration defaultEditors = defaultEditorsByColumnClass.elements(); while (defaultEditors.hasMoreElements()) { SwingUtilities.updateRendererOrEditorUI(defaultEditors.nextElement()); } @@ -5445,8 +5449,8 @@ */ static class GenericEditor extends DefaultCellEditor { - Class[] argTypes = new Class[]{String.class}; - java.lang.reflect.Constructor constructor; + Class[] argTypes = new Class[]{String.class}; + java.lang.reflect.Constructor constructor; Object value; public GenericEditor() { --- old/src/share/classes/javax/swing/JTextField.java 2014-07-02 23:35:06.000000000 -0700 +++ new/src/share/classes/javax/swing/JTextField.java 2014-07-02 23:35:05.000000000 -0700 @@ -587,7 +587,7 @@ } } - private boolean isListener(Class c, ActionListener a) { + private boolean isListener(Class c, ActionListener a) { boolean isListener = false; Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length-2; i>=0; i-=2) { --- old/src/share/classes/javax/swing/JTree.java 2014-07-02 23:35:06.000000000 -0700 +++ new/src/share/classes/javax/swing/JTree.java 2014-07-02 23:35:06.000000000 -0700 @@ -4032,7 +4032,7 @@ /** * Subclassed to load the children, if necessary. */ - public Enumeration children() { + public Enumeration children() { if(!loadedChildren) loadChildren(); return super.children(); --- old/src/share/classes/javax/swing/KeyboardManager.java 2014-07-02 23:35:09.000000000 -0700 +++ new/src/share/classes/javax/swing/KeyboardManager.java 2014-07-02 23:35:09.000000000 -0700 @@ -68,13 +68,13 @@ /** * maps top-level containers to a sub-hashtable full of keystrokes */ - Hashtable containerMap = new Hashtable(); + Hashtable> containerMap = new Hashtable<>(); /** * Maps component/keystroke pairs to a topLevel container * This is mainly used for fast unregister operations */ - Hashtable componentKeyStrokeMap = new Hashtable(); + Hashtable componentKeyStrokeMap = new Hashtable<>(); public static KeyboardManager getCurrentManager() { return currentManager; @@ -95,7 +95,7 @@ if (topContainer == null) { return; } - Hashtable keyMap = containerMap.get(topContainer); + Hashtable keyMap = containerMap.get(topContainer); if (keyMap == null) { // lazy evaluate one keyMap = registerNewTopContainer(topContainer); @@ -105,7 +105,8 @@ if (tmp == null) { keyMap.put(k,c); } else if (tmp instanceof Vector) { // if there's a Vector there then add to it. - Vector v = (Vector)tmp; + @SuppressWarnings("unchecked") + Vector v = (Vector)tmp; if (!v.contains(c)) { // only add if this keystroke isn't registered for this component v.addElement(c); } @@ -114,7 +115,7 @@ // Then add the old compoennt and the new compoent to the vector // then insert the vector in the table if (tmp != c) { // this means this is already registered for this component, no need to dup - Vector v = new Vector(); + Vector v = new Vector<>(); v.addElement((JComponent) tmp); v.addElement(c); keyMap.put(k, v); @@ -160,7 +161,7 @@ return; } - Hashtable keyMap = containerMap.get(topContainer); + Hashtable keyMap = containerMap.get(topContainer); if (keyMap == null) { // this should never happen, but I'm being safe Thread.dumpStack(); return; @@ -176,7 +177,7 @@ keyMap.remove(ks); // remove the KeyStroke from the Map //System.out.println("removed a stroke" + ks); } else if (tmp instanceof Vector ) { // this means there is more than one component reg for this key - Vector v = (Vector)tmp; + Vector v = (Vector)tmp; v.removeElement(c); if ( v.isEmpty() ) { keyMap.remove(ks); // remove the KeyStroke from the Map @@ -227,7 +228,7 @@ ks=KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers(), !pressed); } - Hashtable keyMap = containerMap.get(topAncestor); + Hashtable keyMap = containerMap.get(topAncestor); if (keyMap != null) { // this container isn't registered, so bail Object tmp = null; @@ -250,7 +251,7 @@ fireBinding(c, ks, e, pressed); } } else if ( tmp instanceof Vector) { //more than one comp registered for this - Vector v = (Vector)tmp; + Vector v = (Vector)tmp; // There is no well defined order for WHEN_IN_FOCUSED_WINDOW // bindings, but we give precedence to those bindings just // added. This is done so that JMenus WHEN_IN_FOCUSED_WINDOW @@ -279,11 +280,12 @@ // The're handled differently. The key is to let any JMenuBars // process the event if ( keyMap != null) { - Vector v = (Vector)keyMap.get(JMenuBar.class); + @SuppressWarnings("unchecked") + Vector v = (Vector)keyMap.get(JMenuBar.class); if (v != null) { - Enumeration iter = v.elements(); + Enumeration iter = v.elements(); while (iter.hasMoreElements()) { - JMenuBar mb = (JMenuBar)iter.nextElement(); + JMenuBar mb = iter.nextElement(); if ( mb.isShowing() && mb.isEnabled() ) { // don't want to give these out boolean extended = (ksE != null) && !ksE.equals(ks); if (extended) { @@ -315,17 +317,18 @@ if (top == null) { return; } - Hashtable keyMap = containerMap.get(top); + Hashtable keyMap = containerMap.get(top); if (keyMap == null) { // lazy evaluate one keyMap = registerNewTopContainer(top); } // use the menubar class as the key - Vector menuBars = (Vector)keyMap.get(JMenuBar.class); + @SuppressWarnings("unchecked") + Vector menuBars = (Vector)keyMap.get(JMenuBar.class); if (menuBars == null) { // if we don't have a list of menubars, // then make one. - menuBars = new Vector(); + menuBars = new Vector<>(); keyMap.put(JMenuBar.class, menuBars); } @@ -340,9 +343,9 @@ if (topContainer == null) { return; } - Hashtable keyMap = containerMap.get(topContainer); + Hashtable keyMap = containerMap.get(topContainer); if (keyMap!=null) { - Vector v = (Vector)keyMap.get(JMenuBar.class); + Vector v = (Vector)keyMap.get(JMenuBar.class); if (v != null) { v.removeElement(mb); if (v.isEmpty()) { @@ -355,8 +358,8 @@ } } } - protected Hashtable registerNewTopContainer(Container topContainer) { - Hashtable keyMap = new Hashtable(); + protected Hashtable registerNewTopContainer(Container topContainer) { + Hashtable keyMap = new Hashtable<>(); containerMap.put(topContainer, keyMap); return keyMap; } --- old/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java 2014-07-02 23:35:10.000000000 -0700 +++ new/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java 2014-07-02 23:35:10.000000000 -0700 @@ -98,7 +98,7 @@ if (aContainer == null || aComponent == null) { throw new IllegalArgumentException("aContainer and aComponent cannot be null"); } - Comparator comparator = getComparator(); + Comparator comparator = getComparator(); if (comparator instanceof LayoutComparator) { ((LayoutComparator)comparator). setComponentOrientation(aContainer. @@ -134,7 +134,7 @@ if (aContainer == null || aComponent == null) { throw new IllegalArgumentException("aContainer and aComponent cannot be null"); } - Comparator comparator = getComparator(); + Comparator comparator = getComparator(); if (comparator instanceof LayoutComparator) { ((LayoutComparator)comparator). setComponentOrientation(aContainer. @@ -158,7 +158,7 @@ if (aContainer == null) { throw new IllegalArgumentException("aContainer cannot be null"); } - Comparator comparator = getComparator(); + Comparator comparator = getComparator(); if (comparator instanceof LayoutComparator) { ((LayoutComparator)comparator). setComponentOrientation(aContainer. @@ -182,7 +182,7 @@ if (aContainer == null) { throw new IllegalArgumentException("aContainer cannot be null"); } - Comparator comparator = getComparator(); + Comparator comparator = getComparator(); if (comparator instanceof LayoutComparator) { ((LayoutComparator)comparator). setComponentOrientation(aContainer. @@ -233,7 +233,7 @@ // to be focusable by returning true here. return true; } else if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JComboBox")) { - JComboBox box = (JComboBox)aComponent; + JComboBox box = (JComboBox)aComponent; return box.getUI().isFocusTraversable(box); } else if (aComponent instanceof JComponent) { JComponent jComponent = (JComponent)aComponent; @@ -256,10 +256,11 @@ out.writeObject(getComparator()); out.writeBoolean(getImplicitDownCycleTraversal()); } + @SuppressWarnings("unchecked") // Cast to (Comparator) private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - setComparator((Comparator)in.readObject()); + setComparator((Comparator)in.readObject()); setImplicitDownCycleTraversal(in.readBoolean()); } } --- old/src/share/classes/javax/swing/MenuSelectionManager.java 2014-07-02 23:35:11.000000000 -0700 +++ new/src/share/classes/javax/swing/MenuSelectionManager.java 2014-07-02 23:35:10.000000000 -0700 @@ -221,7 +221,6 @@ MenuElement menuElement; MenuElement subElements[]; MenuElement path[]; - Vector tmp; int selectionSize; p = event.getPoint(); @@ -250,7 +249,8 @@ screenX = p.x; screenY = p.y; - tmp = (Vector)selection.clone(); + @SuppressWarnings("unchecked") + Vector tmp = (Vector)selection.clone(); selectionSize = tmp.size(); boolean success = false; for (i=selectionSize - 1;i >= 0 && success == false; i--) { @@ -385,7 +385,6 @@ int cWidth,cHeight; MenuElement menuElement; MenuElement subElements[]; - Vector tmp; int selectionSize; SwingUtilities.convertPointToScreen(p,source); @@ -393,7 +392,8 @@ screenX = p.x; screenY = p.y; - tmp = (Vector)selection.clone(); + @SuppressWarnings("unchecked") + Vector tmp = (Vector)selection.clone(); selectionSize = tmp.size(); for(i=selectionSize - 1 ; i >= 0 ; i--) { menuElement = tmp.elementAt(i); --- old/src/share/classes/javax/swing/MultiUIDefaults.java 2014-07-02 23:35:11.000000000 -0700 +++ new/src/share/classes/javax/swing/MultiUIDefaults.java 2014-07-02 23:35:11.000000000 -0700 @@ -192,7 +192,7 @@ public synchronized String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); - Enumeration keys = keys(); + Enumeration keys = keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); sb.append(key + "=" + get(key) + ", "); --- old/src/share/classes/javax/swing/PopupFactory.java 2014-07-02 23:35:12.000000000 -0700 +++ new/src/share/classes/javax/swing/PopupFactory.java 2014-07-02 23:35:12.000000000 -0700 @@ -402,13 +402,14 @@ * Window to a List of * HeavyWeightPopups. */ + @SuppressWarnings("unchecked") private static Map> getHeavyWeightPopupCache() { synchronized (HeavyWeightPopup.class) { Map> cache = (Map>)SwingUtilities.appContextGet( heavyWeightPopupCacheKey); if (cache == null) { - cache = new HashMap>(2); + cache = new HashMap<>(2); SwingUtilities.appContextPut(heavyWeightPopupCacheKey, cache); } @@ -699,11 +700,12 @@ /** * Returns the cache to use for heavy weight popups. */ + @SuppressWarnings("unchecked") private static List getLightWeightPopupCache() { List cache = (List)SwingUtilities.appContextGet( lightWeightPopupCacheKey); if (cache == null) { - cache = new ArrayList(); + cache = new ArrayList<>(); SwingUtilities.appContextPut(lightWeightPopupCacheKey, cache); } return cache; @@ -855,12 +857,13 @@ /** * Returns the cache to use for medium weight popups. */ + @SuppressWarnings("unchecked") private static List getMediumWeightPopupCache() { List cache = (List)SwingUtilities.appContextGet( mediumWeightPopupCacheKey); if (cache == null) { - cache = new ArrayList(); + cache = new ArrayList<>(); SwingUtilities.appContextPut(mediumWeightPopupCacheKey, cache); } return cache; --- old/src/share/classes/javax/swing/RowFilter.java 2014-07-02 23:35:13.000000000 -0700 +++ new/src/share/classes/javax/swing/RowFilter.java 2014-07-02 23:35:12.000000000 -0700 @@ -173,8 +173,7 @@ */ public static RowFilter regexFilter(String regex, int... indices) { - return (RowFilter)new RegexFilter(Pattern.compile(regex), - indices); + return new RegexFilter(Pattern.compile(regex), indices); } /** @@ -201,7 +200,7 @@ */ public static RowFilter dateFilter(ComparisonType type, Date date, int... indices) { - return (RowFilter)new DateFilter(type, date.getTime(), indices); + return new DateFilter(type, date.getTime(), indices); } /** @@ -224,7 +223,7 @@ */ public static RowFilter numberFilter(ComparisonType type, Number number, int... indices) { - return (RowFilter)new NumberFilter(type, number, indices); + return new NumberFilter(type, number, indices); } /** @@ -397,7 +396,7 @@ } - private static abstract class GeneralFilter extends RowFilter { + private static abstract class GeneralFilter extends RowFilter { private int[] columns; GeneralFilter(int[] columns) { @@ -405,7 +404,8 @@ this.columns = columns; } - public boolean include(Entry value){ + @Override + public boolean include(Entry value){ int count = value.getValueCount(); if (columns.length > 0) { for (int i = columns.length - 1; i >= 0; i--) { @@ -416,8 +416,7 @@ } } } - } - else { + } else { while (--count >= 0) { if (include(value, count)) { return true; @@ -428,11 +427,11 @@ } protected abstract boolean include( - Entry value, int index); + Entry value, int index); } - private static class RegexFilter extends GeneralFilter { + private static class RegexFilter extends GeneralFilter { private Matcher matcher; RegexFilter(Pattern regex, int[] columns) { @@ -443,15 +442,16 @@ matcher = regex.matcher(""); } + @Override protected boolean include( - Entry value, int index) { + Entry value, int index) { matcher.reset(value.getStringValue(index)); return matcher.find(); } } - private static class DateFilter extends GeneralFilter { + private static class DateFilter extends GeneralFilter { private long date; private ComparisonType type; @@ -464,8 +464,9 @@ this.date = date; } + @Override protected boolean include( - Entry value, int index) { + Entry value, int index) { Object v = value.getValue(index); if (v instanceof Date) { @@ -487,10 +488,7 @@ } } - - - - private static class NumberFilter extends GeneralFilter { + private static class NumberFilter extends GeneralFilter { private boolean isComparable; private Number number; private ComparisonType type; @@ -506,15 +504,16 @@ isComparable = (number instanceof Comparable); } + @Override @SuppressWarnings("unchecked") protected boolean include( - Entry value, int index) { + Entry value, int index) { Object v = value.getValue(index); if (v instanceof Number) { boolean compared = true; int compareResult; - Class vClass = v.getClass(); + Class vClass = v.getClass(); if (number.getClass() == vClass && isComparable) { compareResult = ((Comparable)number).compareTo(v); } --- old/src/share/classes/javax/swing/SpinnerDateModel.java 2014-07-02 23:35:13.000000000 -0700 +++ new/src/share/classes/javax/swing/SpinnerDateModel.java 2014-07-02 23:35:13.000000000 -0700 @@ -89,7 +89,7 @@ @SuppressWarnings("serial") // Superclass is not serializable across versions public class SpinnerDateModel extends AbstractSpinnerModel implements Serializable { - private Comparable start, end; + private Comparable start, end; private Calendar value; private int calendarField; @@ -173,7 +173,7 @@ * @see #setEnd * @see #setCalendarField */ - public SpinnerDateModel(Date value, Comparable start, Comparable end, int calendarField) { + public SpinnerDateModel(Date value, Comparable start, Comparable end, int calendarField) { if (value == null) { throw new IllegalArgumentException("value is null"); } @@ -241,7 +241,7 @@ * @see #setEnd * @see #addChangeListener */ - public void setStart(Comparable start) { + public void setStart(Comparable start) { if ((start == null) ? (this.start != null) : !start.equals(this.start)) { this.start = start; fireStateChanged(); @@ -255,7 +255,7 @@ * @return the value of the start property * @see #setStart */ - public Comparable getStart() { + public Comparable getStart() { return start; } @@ -282,7 +282,7 @@ * @see #setStart * @see #addChangeListener */ - public void setEnd(Comparable end) { + public void setEnd(Comparable end) { if ((end == null) ? (this.end != null) : !end.equals(this.end)) { this.end = end; fireStateChanged(); @@ -296,7 +296,7 @@ * @return the value of the end property * @see #setEnd */ - public Comparable getEnd() { + public Comparable getEnd() { return end; } --- old/src/share/classes/javax/swing/SpinnerListModel.java 2014-07-02 23:35:14.000000000 -0700 +++ new/src/share/classes/javax/swing/SpinnerListModel.java 2014-07-02 23:35:13.000000000 -0700 @@ -59,7 +59,7 @@ @SuppressWarnings("serial") // Superclass is not serializable across versions public class SpinnerListModel extends AbstractSpinnerModel implements Serializable { - private List list; + private List list; private int index; --- old/src/share/classes/javax/swing/SpinnerNumberModel.java 2014-07-02 23:35:14.000000000 -0700 +++ new/src/share/classes/javax/swing/SpinnerNumberModel.java 2014-07-02 23:35:14.000000000 -0700 @@ -84,7 +84,16 @@ public class SpinnerNumberModel extends AbstractSpinnerModel implements Serializable { private Number stepSize, value; - private Comparable minimum, maximum; + // Both minimum and maximum are logically Comparable, but that type is awkward to use since different + // instances of Number are not naturally Comparable. For example, + // a Double implements Comparable and an Integer + // implements Comparable. Neither Integer nor Double will + // have a bridge method for Comparable. However, it safe + // to cast Comparable to Comparable since all + // Comparables will have a compare(Object> method, possibly as a + // bridge. + private Comparable minimum, maximum; /** @@ -117,12 +126,16 @@ * null or if the following expression is false: * minimum <= value <= maximum */ - public SpinnerNumberModel(Number value, Comparable minimum, Comparable maximum, Number stepSize) { + @SuppressWarnings("unchecked") // Casts to Comparable + public SpinnerNumberModel(Number value, + Comparable minimum, + Comparable maximum, + Number stepSize) { if ((value == null) || (stepSize == null)) { throw new IllegalArgumentException("value and stepSize must be non-null"); } - if (!(((minimum == null) || (minimum.compareTo(value) <= 0)) && - ((maximum == null) || (maximum.compareTo(value) >= 0)))) { + if (!(((minimum == null) || (((Comparable)minimum).compareTo(value) <= 0)) && + ((maximum == null) || (((Comparable)maximum).compareTo(value) >= 0)))) { throw new IllegalArgumentException("(minimum <= value <= maximum) is false"); } this.value = value; @@ -212,7 +225,7 @@ * @see #setMaximum * @see SpinnerModel#addChangeListener */ - public void setMinimum(Comparable minimum) { + public void setMinimum(Comparable minimum) { if ((minimum == null) ? (this.minimum != null) : !minimum.equals(this.minimum)) { this.minimum = minimum; fireStateChanged(); @@ -226,7 +239,7 @@ * @return the value of the minimum property * @see #setMinimum */ - public Comparable getMinimum() { + public Comparable getMinimum() { return minimum; } @@ -259,7 +272,7 @@ * @see #setMinimum * @see SpinnerModel#addChangeListener */ - public void setMaximum(Comparable maximum) { + public void setMaximum(Comparable maximum) { if ((maximum == null) ? (this.maximum != null) : !maximum.equals(this.maximum)) { this.maximum = maximum; fireStateChanged(); @@ -273,7 +286,7 @@ * @return the value of the maximum property * @see #setMaximum */ - public Comparable getMaximum() { + public Comparable getMaximum() { return maximum; } @@ -317,7 +330,7 @@ return stepSize; } - + @SuppressWarnings("unchecked") // Casts to Comparable private Number incrValue(int dir) { Number newValue; @@ -329,8 +342,7 @@ else { newValue = new Float(v); } - } - else { + } else { long v = value.longValue() + (stepSize.longValue() * (long)dir); if (value instanceof Long) { @@ -347,10 +359,10 @@ } } - if ((maximum != null) && (maximum.compareTo(newValue) < 0)) { + if ((maximum != null) && (((Comparable)maximum).compareTo(newValue) < 0)) { return null; } - if ((minimum != null) && (minimum.compareTo(newValue) > 0)) { + if ((minimum != null) && (((Comparable)minimum).compareTo(newValue) > 0)) { return null; } else { --- old/src/share/classes/javax/swing/SpringLayout.java 2014-07-02 23:35:15.000000000 -0700 +++ new/src/share/classes/javax/swing/SpringLayout.java 2014-07-02 23:35:15.000000000 -0700 @@ -495,7 +495,7 @@ }; } - private boolean defined(List history, String s1, String s2) { + private boolean defined(List history, String s1, String s2) { return history.contains(s1) && history.contains(s2); } --- old/src/share/classes/javax/swing/SwingWorker.java 2014-07-02 23:35:16.000000000 -0700 +++ new/src/share/classes/javax/swing/SwingWorker.java 2014-07-02 23:35:15.000000000 -0700 @@ -820,7 +820,9 @@ doSubmit = new DoSubmitAccumulativeRunnable(); appContext.put(DO_SUBMIT_KEY, doSubmit); } - return (AccumulativeRunnable) doSubmit; + @SuppressWarnings("unchecked") + AccumulativeRunnable tmp = (AccumulativeRunnable) doSubmit; + return tmp; } } private static class DoSubmitAccumulativeRunnable --- old/src/share/classes/javax/swing/UIDefaults.java 2014-07-02 23:35:16.000000000 -0700 +++ new/src/share/classes/javax/swing/UIDefaults.java 2014-07-02 23:35:16.000000000 -0700 @@ -311,10 +311,10 @@ } else { b = ResourceBundle.getBundle(bundleName, l); } - Enumeration keys = b.getKeys(); + Enumeration keys = b.getKeys(); while (keys.hasMoreElements()) { - String key = (String)keys.nextElement(); + String key = keys.nextElement(); if (values.get(key) == null) { Object value = b.getObject(key); @@ -682,7 +682,7 @@ if (className != null) { ReflectUtil.checkPackageAccess(className); - Class cls = (Class)get(className); + Class cls = (Class)get(className); if (cls == null) { if (uiClassLoader == null) { cls = SwingUtilities.loadSystemClass(className); @@ -695,13 +695,12 @@ put(className, cls); } } - return cls; + @SuppressWarnings("unchecked") + Class tmp = (Class)cls; + return tmp; } } - catch (ClassNotFoundException e) { - return null; - } - catch (ClassCastException e) { + catch (ClassNotFoundException | ClassCastException e) { return null; } return null; @@ -767,7 +766,7 @@ try { Method m = (Method)get(uiClass); if (m == null) { - m = uiClass.getMethod("createUI", new Class[]{JComponent.class}); + m = uiClass.getMethod("createUI", new Class[]{JComponent.class}); put(uiClass, m); } uiObject = MethodUtil.invoke(m, null, new Object[]{target}); @@ -1106,12 +1105,12 @@ c = Class.forName(className, true, (ClassLoader)cl); SwingUtilities2.checkAccess(c.getModifiers()); if (methodName != null) { - Class[] types = getClassArray(args); + Class[] types = getClassArray(args); Method m = c.getMethod(methodName, types); return MethodUtil.invoke(m, c, args); } else { - Class[] types = getClassArray(args); - Constructor constructor = c.getConstructor(types); + Class[] types = getClassArray(args); + Constructor constructor = c.getConstructor(types); SwingUtilities2.checkAccess(constructor.getModifiers()); return constructor.newInstance(args); } @@ -1134,10 +1133,10 @@ * and superclasses for subclasses used to add the * UIResource tag. */ - private Class[] getClassArray(Object[] args) { - Class[] types = null; + private Class[] getClassArray(Object[] args) { + Class[] types = null; if (args!=null) { - types = new Class[args.length]; + types = new Class[args.length]; for (int i = 0; i< args.length; i++) { /* PENDING(ges): At present only the primitive types used are handled correctly; this should eventually --- old/src/share/classes/javax/swing/UIManager.java 2014-07-02 23:35:17.000000000 -0700 +++ new/src/share/classes/javax/swing/UIManager.java 2014-07-02 23:35:17.000000000 -0700 @@ -581,7 +581,7 @@ setLookAndFeel(new javax.swing.plaf.metal.MetalLookAndFeel()); } else { - Class lnfClass = SwingUtilities.loadSystemClass(className); + Class lnfClass = SwingUtilities.loadSystemClass(className); setLookAndFeel((LookAndFeel)(lnfClass.newInstance())); } } @@ -1049,7 +1049,7 @@ String defaultName = "javax.swing.plaf.multi.MultiLookAndFeel"; String className = getLAFState().swingProps.getProperty(multiplexingLAFKey, defaultName); try { - Class lnfClass = SwingUtilities.loadSystemClass(className); + Class lnfClass = SwingUtilities.loadSystemClass(className); multiLookAndFeel = (LookAndFeel)lnfClass.newInstance(); } catch (Exception exc) { System.err.println("UIManager: failed loading " + className); @@ -1337,10 +1337,11 @@ // Try to get default LAF from system property, then from AppContext // (6653395), then use cross-platform one by default. String lafName = null; - HashMap lafData = + @SuppressWarnings("unchecked") + HashMap lafData = (HashMap) AppContext.getAppContext().remove("swing.lafdata"); if (lafData != null) { - lafName = (String) lafData.remove("defaultlaf"); + lafName = lafData.remove("defaultlaf"); } if (lafName == null) { lafName = getCrossPlatformLookAndFeelClassName(); @@ -1380,7 +1381,7 @@ while (p.hasMoreTokens()) { String className = p.nextToken(); try { - Class lnfClass = SwingUtilities.loadSystemClass(className); + Class lnfClass = SwingUtilities.loadSystemClass(className); LookAndFeel newLAF = (LookAndFeel)lnfClass.newInstance(); newLAF.initialize(); auxLookAndFeels.addElement(newLAF); --- old/src/share/classes/javax/swing/event/EventListenerList.java 2014-07-02 23:35:17.000000000 -0700 +++ new/src/share/classes/javax/swing/event/EventListenerList.java 2014-07-02 23:35:17.000000000 -0700 @@ -141,11 +141,14 @@ public T[] getListeners(Class t) { Object[] lList = listenerList; int n = getListenerCount(lList, t); + @SuppressWarnings("unchecked") T[] result = (T[])Array.newInstance(t, n); int j = 0; for (int i = lList.length-2; i>=0; i-=2) { if (lList[i] == t) { - result[j++] = (T)lList[i+1]; + @SuppressWarnings("unchecked") + T tmp = (T)lList[i+1]; + result[j++] = tmp; } } return result; @@ -172,7 +175,7 @@ return getListenerCount(lList, t); } - private int getListenerCount(Object[] list, Class t) { + private int getListenerCount(Object[] list, Class t) { int count = 0; for (int i = 0; i < list.length; i+=2) { if (t == (Class)list[i]) @@ -288,7 +291,9 @@ EventListener l = (EventListener)s.readObject(); String name = (String) listenerTypeOrNull; ReflectUtil.checkPackageAccess(name); - add((Class)Class.forName(name, true, cl), l); + @SuppressWarnings("unchecked") + Class tmp = (Class)Class.forName(name, true, cl); + add(tmp, l); } } --- old/src/share/classes/javax/swing/event/RowSorterEvent.java 2014-07-02 23:35:18.000000000 -0700 +++ new/src/share/classes/javax/swing/event/RowSorterEvent.java 2014-07-02 23:35:18.000000000 -0700 @@ -71,7 +71,7 @@ * @throws IllegalArgumentException if source is * null */ - public RowSorterEvent(RowSorter source) { + public RowSorterEvent(RowSorter source) { this(source, Type.SORT_ORDER_CHANGED, null); } @@ -85,7 +85,7 @@ * @throws IllegalArgumentException if source or type is * null */ - public RowSorterEvent(RowSorter source, Type type, + public RowSorterEvent(RowSorter source, Type type, int[] previousRowIndexToModel) { super(source); if (type == null) { @@ -100,7 +100,8 @@ * * @return the source of the event as a RowSorter */ - public RowSorter getSource() { + @Override + public RowSorter getSource() { return (RowSorter)super.getSource(); } --- old/src/share/classes/javax/swing/table/DefaultTableColumnModel.java 2014-07-02 23:35:19.000000000 -0700 +++ new/src/share/classes/javax/swing/table/DefaultTableColumnModel.java 2014-07-02 23:35:19.000000000 -0700 @@ -269,12 +269,12 @@ throw new IllegalArgumentException("Identifier is null"); } - Enumeration enumeration = getColumns(); + Enumeration enumeration = getColumns(); TableColumn aColumn; int index = 0; while (enumeration.hasMoreElements()) { - aColumn = (TableColumn)enumeration.nextElement(); + aColumn = enumeration.nextElement(); // Compare them this way in case the column's identifier is null. if (identifier.equals(aColumn.getIdentifier())) return index; @@ -728,10 +728,10 @@ * totalColumnWidth property. */ protected void recalcWidthCache() { - Enumeration enumeration = getColumns(); + Enumeration enumeration = getColumns(); totalColumnWidth = 0; while (enumeration.hasMoreElements()) { - totalColumnWidth += ((TableColumn)enumeration.nextElement()).getWidth(); + totalColumnWidth += enumeration.nextElement().getWidth(); } } --- old/src/share/classes/javax/swing/table/DefaultTableModel.java 2014-07-02 23:35:19.000000000 -0700 +++ new/src/share/classes/javax/swing/table/DefaultTableModel.java 2014-07-02 23:35:19.000000000 -0700 @@ -70,10 +70,10 @@ * The Vector of Vectors of * Object values. */ - protected Vector dataVector; + protected Vector> dataVector; /** The Vector of column identifiers. */ - protected Vector columnIdentifiers; + protected Vector columnIdentifiers; // // Constructors @@ -87,8 +87,8 @@ this(0, 0); } - private static Vector newVector(int size) { - Vector v = new Vector(size); + private static Vector newVector(int size) { + Vector v = new Vector<>(size); v.setSize(size); return v; } @@ -121,7 +121,7 @@ * @see #setDataVector * @see #setValueAt */ - public DefaultTableModel(Vector columnNames, int rowCount) { + public DefaultTableModel(Vector columnNames, int rowCount) { setDataVector(newVector(rowCount), columnNames); } @@ -156,7 +156,7 @@ * @see #getDataVector * @see #setDataVector */ - public DefaultTableModel(Vector data, Vector columnNames) { + public DefaultTableModel(Vector> data, Vector columnNames) { setDataVector(data, columnNames); } @@ -191,12 +191,12 @@ * @see #newRowsAdded * @see #setDataVector */ - public Vector getDataVector() { + public Vector> getDataVector() { return dataVector; } - private static Vector nonNullVector(Vector v) { - return (v != null) ? v : new Vector(); + private static Vector nonNullVector(Vector v) { + return (v != null) ? v : new Vector<>(); } /** @@ -219,7 +219,8 @@ * @param columnIdentifiers the names of the columns * @see #getDataVector */ - public void setDataVector(Vector dataVector, Vector columnIdentifiers) { + public void setDataVector(Vector> dataVector, + Vector columnIdentifiers) { this.dataVector = nonNullVector(dataVector); this.columnIdentifiers = nonNullVector(columnIdentifiers); justifyRows(0, getRowCount()); @@ -264,7 +265,7 @@ for (int i = from; i < to; i++) { if (dataVector.elementAt(i) == null) { - dataVector.setElementAt(new Vector(), i); + dataVector.setElementAt(new Vector<>(), i); } ((Vector)dataVector.elementAt(i)).setSize(getColumnCount()); } @@ -349,7 +350,7 @@ * * @param rowData optional data of the row being added */ - public void addRow(Vector rowData) { + public void addRow(Vector rowData) { insertRow(getRowCount(), rowData); } @@ -373,7 +374,7 @@ * @param rowData optional data of the row being added * @exception ArrayIndexOutOfBoundsException if the row was invalid */ - public void insertRow(int row, Vector rowData) { + public void insertRow(int row, Vector rowData) { dataVector.insertElementAt(rowData, row); justifyRows(row, row+1); fireTableRowsInserted(row, row); @@ -396,13 +397,13 @@ return (j == 0) ? i : gcd(j, i%j); } - private static void rotate(Vector v, int a, int b, int shift) { + private static void rotate(Vector v, int a, int b, int shift) { int size = b - a; int r = size - shift; int g = gcd(size, r); for(int i = 0; i < g; i++) { int to = i; - Object tmp = v.elementAt(a + to); + E tmp = v.elementAt(a + to); for(int from = (to + r) % size; from != i; from = (to + r) % size) { v.setElementAt(v.elementAt(a + from), a + to); to = from; @@ -483,7 +484,7 @@ * to zero columns * @see #setNumRows */ - public void setColumnIdentifiers(Vector columnIdentifiers) { + public void setColumnIdentifiers(Vector columnIdentifiers) { setDataVector(dataVector, columnIdentifiers); } @@ -533,7 +534,7 @@ * @param columnName the identifier of the column being added */ public void addColumn(Object columnName) { - addColumn(columnName, (Vector)null); + addColumn(columnName, (Vector)null); } /** @@ -549,7 +550,7 @@ * @param columnName the identifier of the column being added * @param columnData optional data of the column being added */ - public void addColumn(Object columnName, Vector columnData) { + public void addColumn(Object columnName, Vector columnData) { columnIdentifiers.addElement(columnName); if (columnData != null) { int columnSize = columnData.size(); @@ -559,7 +560,7 @@ justifyRows(0, getRowCount()); int newColumn = getColumnCount() - 1; for(int i = 0; i < columnSize; i++) { - Vector row = (Vector)dataVector.elementAt(i); + Vector row = dataVector.elementAt(i); row.setElementAt(columnData.elementAt(i), newColumn); } } @@ -651,7 +652,7 @@ * column was given */ public Object getValueAt(int row, int column) { - Vector rowVector = (Vector)dataVector.elementAt(row); + Vector rowVector = dataVector.elementAt(row); return rowVector.elementAt(column); } @@ -667,7 +668,7 @@ * column was given */ public void setValueAt(Object aValue, int row, int column) { - Vector rowVector = (Vector)dataVector.elementAt(row); + Vector rowVector = dataVector.elementAt(row); rowVector.setElementAt(aValue, column); fireTableCellUpdated(row, column); } @@ -682,11 +683,11 @@ * @return the new vector; if anArray is null, * returns null */ - protected static Vector convertToVector(Object[] anArray) { + protected static Vector convertToVector(Object[] anArray) { if (anArray == null) { return null; } - Vector v = new Vector(anArray.length); + Vector v = new Vector<>(anArray.length); for (Object o : anArray) { v.addElement(o); } @@ -699,11 +700,11 @@ * @return the new vector of vectors; if anArray is * null, returns null */ - protected static Vector convertToVector(Object[][] anArray) { + protected static Vector> convertToVector(Object[][] anArray) { if (anArray == null) { return null; } - Vector v = new Vector(anArray.length); + Vector> v = new Vector<>(anArray.length); for (Object[] o : anArray) { v.addElement(convertToVector(o)); } --- old/src/share/classes/javax/swing/table/TableRowSorter.java 2014-07-02 23:35:20.000000000 -0700 +++ new/src/share/classes/javax/swing/table/TableRowSorter.java 2014-07-02 23:35:20.000000000 -0700 @@ -131,7 +131,7 @@ /** * Comparator that uses compareTo on the contents. */ - private static final Comparator COMPARABLE_COMPARATOR = + private static final Comparator COMPARABLE_COMPARATOR = new ComparableComparator(); /** @@ -214,11 +214,11 @@ * @throws IndexOutOfBoundsException {@inheritDoc} */ public Comparator getComparator(int column) { - Comparator comparator = super.getComparator(column); + Comparator comparator = super.getComparator(column); if (comparator != null) { return comparator; } - Class columnClass = getModel().getColumnClass(column); + Class columnClass = getModel().getColumnClass(column); if (columnClass == String.class) { return Collator.getInstance(); } @@ -234,11 +234,11 @@ * @throws IndexOutOfBoundsException {@inheritDoc} */ protected boolean useToString(int column) { - Comparator comparator = super.getComparator(column); + Comparator comparator = super.getComparator(column); if (comparator != null) { return false; } - Class columnClass = getModel().getColumnClass(column); + Class columnClass = getModel().getColumnClass(column); if (columnClass == String.class) { return false; } @@ -299,7 +299,7 @@ } - private static class ComparableComparator implements Comparator { + private static class ComparableComparator implements Comparator { @SuppressWarnings("unchecked") public int compare(Object o1, Object o2) { return ((Comparable)o1).compareTo(o2); --- old/src/share/classes/javax/swing/text/AbstractDocument.java 2014-07-02 23:35:21.000000000 -0700 +++ new/src/share/classes/javax/swing/text/AbstractDocument.java 2014-07-02 23:35:21.000000000 -0700 @@ -2193,7 +2193,7 @@ * Enumeration. * @return the children of the receiver as an Enumeration */ - public abstract Enumeration children(); + public abstract Enumeration children(); // --- serialization --------------------------------------------- @@ -2456,11 +2456,11 @@ * Enumeration. * @return the children of the receiver */ - public Enumeration children() { + public Enumeration children() { if(nchildren == 0) return null; - Vector tempVector = new Vector(nchildren); + Vector tempVector = new Vector<>(nchildren); for(int counter = 0; counter < nchildren; counter++) tempVector.addElement(children[counter]); @@ -2610,7 +2610,8 @@ * Enumeration. * @return the children of the receiver */ - public Enumeration children() { + @Override + public Enumeration children() { return null; } --- old/src/share/classes/javax/swing/tree/AbstractLayoutCache.java 2014-07-02 23:35:21.000000000 -0700 +++ new/src/share/classes/javax/swing/tree/AbstractLayoutCache.java 2014-07-02 23:35:21.000000000 -0700 @@ -228,10 +228,10 @@ endY = bounds.height + bounds.y; } - Enumeration paths = getVisiblePathsFrom(firstPath); + Enumeration paths = getVisiblePathsFrom(firstPath); if(paths != null && paths.hasMoreElements()) { - Rectangle pBounds = getBounds((TreePath)paths.nextElement(), + Rectangle pBounds = getBounds(paths.nextElement(), null); int width; @@ -244,7 +244,7 @@ else width = 0; while (pBounds != null && paths.hasMoreElements()) { - pBounds = getBounds((TreePath)paths.nextElement(), + pBounds = getBounds(paths.nextElement(), pBounds); if (pBounds != null && pBounds.y < endY) { width = Math.max(width, pBounds.x + pBounds.width); --- old/src/share/classes/javax/swing/tree/DefaultMutableTreeNode.java 2014-07-02 23:35:23.000000000 -0700 +++ new/src/share/classes/javax/swing/tree/DefaultMutableTreeNode.java 2014-07-02 23:35:23.000000000 -0700 @@ -102,7 +102,7 @@ protected MutableTreeNode parent; /** array of children, may be null if this node has no children */ - protected Vector children; + protected Vector children; /** optional user object */ transient protected Object userObject; @@ -187,7 +187,7 @@ } newChild.setParent(this); if (children == null) { - children = new Vector(); + children = new Vector<>(); } children.insertElementAt(newChild, childIndex); } @@ -243,7 +243,7 @@ if (children == null) { throw new ArrayIndexOutOfBoundsException("node has no children"); } - return (TreeNode)children.elementAt(index); + return children.elementAt(index); } /** @@ -290,7 +290,7 @@ * * @return an Enumeration of this node's children */ - public Enumeration children() { + public Enumeration children() { if (children == null) { return EMPTY_ENUMERATION; } else { @@ -557,7 +557,7 @@ */ public int getDepth() { Object last = null; - Enumeration enum_ = breadthFirstEnumeration(); + Enumeration enum_ = breadthFirstEnumeration(); while (enum_.hasMoreElements()) { last = enum_.nextElement(); @@ -765,7 +765,7 @@ * @see #postorderEnumeration * @return an enumeration for traversing the tree in preorder */ - public Enumeration preorderEnumeration() { + public Enumeration preorderEnumeration() { return new PreorderEnumeration(this); } @@ -782,7 +782,7 @@ * @see #preorderEnumeration * @return an enumeration for traversing the tree in postorder */ - public Enumeration postorderEnumeration() { + public Enumeration postorderEnumeration() { return new PostorderEnumeration(this); } @@ -797,7 +797,7 @@ * @see #depthFirstEnumeration * @return an enumeration for traversing the tree in breadth-first order */ - public Enumeration breadthFirstEnumeration() { + public Enumeration breadthFirstEnumeration() { return new BreadthFirstEnumeration(this); } @@ -814,7 +814,7 @@ * @see #postorderEnumeration * @return an enumeration for traversing the tree in depth-first order */ - public Enumeration depthFirstEnumeration() { + public Enumeration depthFirstEnumeration() { return postorderEnumeration(); } @@ -839,7 +839,7 @@ * @return an enumeration for following the path from an ancestor of * this node to this one */ - public Enumeration pathFromAncestorEnumeration(TreeNode ancestor) { + public Enumeration pathFromAncestorEnumeration(TreeNode ancestor) { return new PathBetweenNodesEnumeration(ancestor, this); } @@ -1218,10 +1218,10 @@ int count = 0; TreeNode node; - Enumeration enum_ = breadthFirstEnumeration(); // order matters not + Enumeration enum_ = breadthFirstEnumeration(); // order matters not while (enum_.hasMoreElements()) { - node = (TreeNode)enum_.nextElement(); + node = enum_.nextElement(); if (node.isLeaf()) { count++; } @@ -1308,7 +1308,7 @@ } private final class PreorderEnumeration implements Enumeration { - private final Stack stack = new Stack(); + private final Stack> stack = new Stack<>(); public PreorderEnumeration(TreeNode rootNode) { super(); @@ -1322,9 +1322,10 @@ } public TreeNode nextElement() { - Enumeration enumer = stack.peek(); - TreeNode node = (TreeNode)enumer.nextElement(); - Enumeration children = node.children(); + Enumeration enumer = stack.peek(); + TreeNode node = enumer.nextElement(); + @SuppressWarnings("unchecked") + Enumeration children = node.children(); if (!enumer.hasMoreElements()) { stack.pop(); @@ -1392,9 +1393,9 @@ } public TreeNode nextElement() { - Enumeration enumer = (Enumeration)queue.firstObject(); + Enumeration enumer = (Enumeration)queue.firstObject(); TreeNode node = (TreeNode)enumer.nextElement(); - Enumeration children = node.children(); + Enumeration children = node.children(); if (!enumer.hasMoreElements()) { queue.dequeue(); --- old/src/share/classes/javax/swing/tree/DefaultTreeCellEditor.java 2014-07-02 23:35:24.000000000 -0700 +++ new/src/share/classes/javax/swing/tree/DefaultTreeCellEditor.java 2014-07-02 23:35:23.000000000 -0700 @@ -573,7 +573,7 @@ throws IOException, ClassNotFoundException { s.defaultReadObject(); - Vector values = (Vector)s.readObject(); + Vector values = (Vector)s.readObject(); int indexCounter = 0; int maxCounter = values.size(); --- old/src/share/classes/javax/swing/tree/DefaultTreeModel.java 2014-07-02 23:35:25.000000000 -0700 +++ new/src/share/classes/javax/swing/tree/DefaultTreeModel.java 2014-07-02 23:35:24.000000000 -0700 @@ -693,7 +693,7 @@ throws IOException, ClassNotFoundException { s.defaultReadObject(); - Vector values = (Vector)s.readObject(); + Vector values = (Vector)s.readObject(); int indexCounter = 0; int maxCounter = values.size(); --- old/src/share/classes/javax/swing/tree/TreeNode.java 2014-07-02 23:35:25.000000000 -0700 +++ new/src/share/classes/javax/swing/tree/TreeNode.java 2014-07-02 23:35:25.000000000 -0700 @@ -99,5 +99,5 @@ * * @return the children of the receiver as an {@code Enumeration} */ - Enumeration children(); + Enumeration children(); } --- old/src/share/classes/javax/swing/tree/VariableHeightLayoutCache.java 2014-07-02 23:35:26.000000000 -0700 +++ new/src/share/classes/javax/swing/tree/VariableHeightLayoutCache.java 2014-07-02 23:35:26.000000000 -0700 @@ -742,7 +742,7 @@ if(!root.isExpanded()) root.expand(); else { - Enumeration cursor = root.children(); + Enumeration cursor = root.children(); while(cursor.hasMoreElements()) { visibleNodes.addElement(cursor.nextElement()); } @@ -1099,7 +1099,8 @@ * If the receiver is not currently expanded, this will return an * empty enumeration. */ - public Enumeration children() { + @Override + public Enumeration children() { if (!this.isExpanded()) { return DefaultMutableTreeNode.EMPTY_ENUMERATION; } else { @@ -1405,7 +1406,7 @@ * createIfNeeded is true, the children are first * loaded. */ - protected Enumeration getLoadedChildren(boolean createIfNeeded) { + protected Enumeration getLoadedChildren(boolean createIfNeeded) { if(!createIfNeeded || hasBeenExpanded) return super.children(); @@ -1499,7 +1500,7 @@ } int i = originalRow; - Enumeration cursor = preorderEnumeration(); + Enumeration cursor = preorderEnumeration(); cursor.nextElement(); // don't add me, I'm already in int newYOrigin; @@ -1513,7 +1514,7 @@ TreeStateNode aNode; if(!isFixed) { while (cursor.hasMoreElements()) { - aNode = (TreeStateNode)cursor.nextElement(); + aNode = (TreeStateNode) cursor.nextElement(); if(!updateNodeSizes && !aNode.hasValidSize()) aNode.updatePreferredSize(i + 1); aNode.setYOrigin(newYOrigin); @@ -1523,7 +1524,7 @@ } else { while (cursor.hasMoreElements()) { - aNode = (TreeStateNode)cursor.nextElement(); + aNode = (TreeStateNode) cursor.nextElement(); visibleNodes.insertElementAt(aNode, ++i); } } @@ -1559,7 +1560,7 @@ */ protected void collapse(boolean adjustTree) { if (isExpanded()) { - Enumeration cursor = preorderEnumeration(); + Enumeration cursor = preorderEnumeration(); cursor.nextElement(); // don't remove me, I'm still visible int rowsDeleted = 0; boolean isFixed = isFixedRowHeight(); --- old/src/share/classes/javax/swing/undo/CompoundEdit.java 2014-07-02 23:35:27.000000000 -0700 +++ new/src/share/classes/javax/swing/undo/CompoundEdit.java 2014-07-02 23:35:26.000000000 -0700 @@ -72,9 +72,9 @@ */ public void redo() throws CannotRedoException { super.redo(); - Enumeration cursor = edits.elements(); + Enumeration cursor = edits.elements(); while (cursor.hasMoreElements()) { - ((UndoableEdit)cursor.nextElement()).redo(); + cursor.nextElement().redo(); } } @@ -198,9 +198,9 @@ * Returns false if they all return false. */ public boolean isSignificant() { - Enumeration cursor = edits.elements(); + Enumeration cursor = edits.elements(); while (cursor.hasMoreElements()) { - if (((UndoableEdit)cursor.nextElement()).isSignificant()) { + if (cursor.nextElement().isSignificant()) { return true; } } --- old/src/share/classes/javax/swing/undo/StateEdit.java 2014-07-02 23:35:27.000000000 -0700 +++ new/src/share/classes/javax/swing/undo/StateEdit.java 2014-07-02 23:35:27.000000000 -0700 @@ -170,8 +170,8 @@ * Remove redundant key/values in state hashtables. */ protected void removeRedundantState() { - Vector uselessKeys = new Vector(); - Enumeration myKeys = preState.keys(); + Vector uselessKeys = new Vector<>(); + Enumeration myKeys = preState.keys(); // Locate redundant state while (myKeys.hasMoreElements()) { --- old/src/share/classes/javax/swing/undo/UndoableEditSupport.java 2014-07-02 23:35:28.000000000 -0700 +++ new/src/share/classes/javax/swing/undo/UndoableEditSupport.java 2014-07-02 23:35:28.000000000 -0700 @@ -101,10 +101,11 @@ */ protected void _postEdit(UndoableEdit e) { UndoableEditEvent ev = new UndoableEditEvent(realSource, e); - Enumeration cursor = ((Vector)listeners.clone()).elements(); + @SuppressWarnings("unchecked") + Enumeration cursor = + ((Vector)listeners.clone()).elements(); while (cursor.hasMoreElements()) { - ((UndoableEditListener)cursor.nextElement()). - undoableEditHappened(ev); + cursor.nextElement().undoableEditHappened(ev); } }