8043550: Fix raw and unchecked lint warnings in javax.swing.*
Reviewed-by: pchelko, mchung
--- a/jdk/src/share/classes/javax/swing/AbstractButton.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/AbstractButton.java Thu Jul 03 15:24:27 2014 -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) {
--- a/jdk/src/share/classes/javax/swing/ArrayTable.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/ArrayTable.java Thu Jul 03 15:24:27 2014 -0700
@@ -133,7 +133,9 @@
if ((size==ARRAY_BOUNDARY) && isArray()) {
grow();
}
- ((Hashtable<Object,Object>)table).put(key, value);
+ @SuppressWarnings("unchecked")
+ Hashtable<Object,Object> tmp = (Hashtable<Object,Object>)table;
+ tmp.put(key, value);
}
}
}
--- a/jdk/src/share/classes/javax/swing/DebugGraphics.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/DebugGraphics.java Thu Jul 03 15:24:27 2014 -0700
@@ -1463,7 +1463,5 @@
}
return debugGraphicsInfo;
}
- private static final Class debugGraphicsInfoKey = DebugGraphicsInfo.class;
-
-
+ private static final Class<DebugGraphicsInfo> debugGraphicsInfoKey = DebugGraphicsInfo.class;
}
--- a/jdk/src/share/classes/javax/swing/DefaultCellEditor.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/DefaultCellEditor.java Thu Jul 03 15:24:27 2014 -0700
@@ -131,7 +131,7 @@
*
* @param comboBox a <code>JComboBox</code> object
*/
- public DefaultCellEditor(final JComboBox comboBox) {
+ public DefaultCellEditor(final JComboBox<?> comboBox) {
editorComponent = comboBox;
comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
delegate = new EditorDelegate() {
--- a/jdk/src/share/classes/javax/swing/DefaultRowSorter.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/DefaultRowSorter.java Thu Jul 03 15:24:27 2014 -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<? extends SortKey> 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<Object> c =
+ (Comparator<Object>)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<Row> {
- 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;
}
--- a/jdk/src/share/classes/javax/swing/JComponent.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/JComponent.java Thu Jul 03 15:24:27 2014 -0700
@@ -2111,6 +2111,7 @@
private void registerWithKeyboardManager(boolean onlyIfNew) {
InputMap inputMap = getInputMap(WHEN_IN_FOCUSED_WINDOW, false);
KeyStroke[] strokes;
+ @SuppressWarnings("unchecked")
Hashtable<KeyStroke, KeyStroke> registered =
(Hashtable<KeyStroke, KeyStroke>)getClientProperty
(WHEN_IN_FOCUSED_WINDOW_BINDINGS);
@@ -2164,6 +2165,7 @@
* <code>WHEN_IN_FOCUSED_WINDOW</code> <code>KeyStroke</code> bindings.
*/
private void unregisterWithKeyboardManager() {
+ @SuppressWarnings("unchecked")
Hashtable<KeyStroke, KeyStroke> registered =
(Hashtable<KeyStroke, KeyStroke>)getClientProperty
(WHEN_IN_FOCUSED_WINDOW_BINDINGS);
@@ -4126,16 +4128,20 @@
setFlag(AUTOSCROLLS_SET, false);
}
} else if (propertyName == "focusTraversalKeysForward") {
+ @SuppressWarnings("unchecked")
+ Set<AWTKeyStroke> strokeSet = (Set<AWTKeyStroke>) value;
if (!getFlag(FOCUS_TRAVERSAL_KEYS_FORWARD_SET)) {
super.setFocusTraversalKeys(KeyboardFocusManager.
FORWARD_TRAVERSAL_KEYS,
- (Set<AWTKeyStroke>)value);
+ strokeSet);
}
} else if (propertyName == "focusTraversalKeysBackward") {
+ @SuppressWarnings("unchecked")
+ Set<AWTKeyStroke> strokeSet = (Set<AWTKeyStroke>) value;
if (!getFlag(FOCUS_TRAVERSAL_KEYS_BACKWARD_SET)) {
super.setFocusTraversalKeys(KeyboardFocusManager.
BACKWARD_TRAVERSAL_KEYS,
- (Set<AWTKeyStroke>)value);
+ strokeSet);
}
} else {
throw new IllegalArgumentException("property \""+
@@ -4713,6 +4719,7 @@
* @see #getVetoableChangeListeners
* @see #getAncestorListeners
*/
+ @SuppressWarnings("unchecked") // Casts to (T[])
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
T[] result;
if (listenerType == AncestorListener.class) {
--- a/jdk/src/share/classes/javax/swing/JEditorPane.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/JEditorPane.java Thu Jul 03 15:24:27 2014 -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<String, String> getKitTypeRegistry() {
loadDefaultKitsIfNecessary();
- return (Hashtable)SwingUtilities.appContextGet(kitTypeRegistryKey);
+ @SuppressWarnings("unchecked")
+ Hashtable<String, String> tmp =
+ (Hashtable)SwingUtilities.appContextGet(kitTypeRegistryKey);
+ return tmp;
}
private static Hashtable<String, ClassLoader> getKitLoaderRegistry() {
loadDefaultKitsIfNecessary();
- return (Hashtable)SwingUtilities.appContextGet(kitLoaderRegistryKey);
+ @SuppressWarnings("unchecked")
+ Hashtable<String, ClassLoader> tmp =
+ (Hashtable)SwingUtilities.appContextGet(kitLoaderRegistryKey);
+ return tmp;
}
private static Hashtable<String, EditorKit> getKitRegisty() {
- Hashtable ht = (Hashtable)SwingUtilities.appContextGet(kitRegistryKey);
+ @SuppressWarnings("unchecked")
+ Hashtable<String, EditorKit> 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<Object, Object> 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));
--- a/jdk/src/share/classes/javax/swing/JLayer.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/JLayer.java Thu Jul 03 15:24:27 2014 -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())) {
--- a/jdk/src/share/classes/javax/swing/JOptionPane.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/JOptionPane.java Thu Jul 03 15:24:27 2014 -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();
--- a/jdk/src/share/classes/javax/swing/JSpinner.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/JSpinner.java Thu Jul 03 15:24:27 2014 -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<Date>)min);
}
- public Comparable getMinimum() {
+ @Override
+ public Comparable<Date> getMinimum() {
return model.getStart();
}
- public void setMaximum(Comparable max) {
- model.setEnd(max);
+ @Override
+ @SuppressWarnings("unchecked")
+ public void setMaximum(Comparable<?> max) {
+ model.setEnd((Comparable<Date>)max);
}
- public Comparable getMaximum() {
+ @Override
+ public Comparable<Date> 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();
}
}
--- a/jdk/src/share/classes/javax/swing/JTable.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/JTable.java Thu Jul 03 15:24:27 2014 -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 <code>getColumnClass</code>
* in the <code>TableModel</code> interface.
*/
- transient protected Hashtable defaultRenderersByColumnClass;
+ transient protected Hashtable<Object, Object> defaultRenderersByColumnClass;
+ // Logicaly, the above is a Hashtable<Class<?>, 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 <code>getColumnClass</code>
* in the <code>TableModel</code> interface.
*/
- transient protected Hashtable defaultEditorsByColumnClass;
+ transient protected Hashtable<Object, Object> defaultEditorsByColumnClass;
+ // Logicaly, the above is a Hashtable<Class<?>, 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<Vector<Object>> rowData, Vector<Object> 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() {
--- a/jdk/src/share/classes/javax/swing/JTextField.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/JTextField.java Thu Jul 03 15:24:27 2014 -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) {
--- a/jdk/src/share/classes/javax/swing/JTree.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/JTree.java Thu Jul 03 15:24:27 2014 -0700
@@ -4032,7 +4032,7 @@
/**
* Subclassed to load the children, if necessary.
*/
- public Enumeration children() {
+ public Enumeration<TreeNode> children() {
if(!loadedChildren)
loadChildren();
return super.children();
--- a/jdk/src/share/classes/javax/swing/KeyboardManager.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/KeyboardManager.java Thu Jul 03 15:24:27 2014 -0700
@@ -68,13 +68,13 @@
/**
* maps top-level containers to a sub-hashtable full of keystrokes
*/
- Hashtable<Container, Hashtable> containerMap = new Hashtable<Container, Hashtable>();
+ Hashtable<Container, Hashtable<Object, Object>> containerMap = new Hashtable<>();
/**
* Maps component/keystroke pairs to a topLevel container
* This is mainly used for fast unregister operations
*/
- Hashtable<ComponentKeyStrokePair, Container> componentKeyStrokeMap = new Hashtable<ComponentKeyStrokePair, Container>();
+ Hashtable<ComponentKeyStrokePair, Container> componentKeyStrokeMap = new Hashtable<>();
public static KeyboardManager getCurrentManager() {
return currentManager;
@@ -95,7 +95,7 @@
if (topContainer == null) {
return;
}
- Hashtable keyMap = containerMap.get(topContainer);
+ Hashtable<Object, Object> 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<Object> 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<JComponent> v = new Vector<JComponent>();
+ Vector<JComponent> 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<Object, Object> 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<Object, Object> 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<JMenuBar> v = (Vector)keyMap.get(JMenuBar.class);
if (v != null) {
- Enumeration iter = v.elements();
+ Enumeration<JMenuBar> 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<Object, Object> 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<Object> 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<Object, Object> 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<Object, Object> registerNewTopContainer(Container topContainer) {
+ Hashtable<Object, Object> keyMap = new Hashtable<>();
containerMap.put(topContainer, keyMap);
return keyMap;
}
--- a/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java Thu Jul 03 15:24:27 2014 -0700
@@ -98,7 +98,7 @@
if (aContainer == null || aComponent == null) {
throw new IllegalArgumentException("aContainer and aComponent cannot be null");
}
- Comparator comparator = getComparator();
+ Comparator<? super Component> 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<? super Component> 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<? super Component> 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<? super Component> 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<? super Component>)
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{
- setComparator((Comparator)in.readObject());
+ setComparator((Comparator<? super Component>)in.readObject());
setImplicitDownCycleTraversal(in.readBoolean());
}
}
--- a/jdk/src/share/classes/javax/swing/MenuSelectionManager.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/MenuSelectionManager.java Thu Jul 03 15:24:27 2014 -0700
@@ -221,7 +221,6 @@
MenuElement menuElement;
MenuElement subElements[];
MenuElement path[];
- Vector<MenuElement> tmp;
int selectionSize;
p = event.getPoint();
@@ -250,7 +249,8 @@
screenX = p.x;
screenY = p.y;
- tmp = (Vector<MenuElement>)selection.clone();
+ @SuppressWarnings("unchecked")
+ Vector<MenuElement> tmp = (Vector<MenuElement>)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<MenuElement> tmp;
int selectionSize;
SwingUtilities.convertPointToScreen(p,source);
@@ -393,7 +392,8 @@
screenX = p.x;
screenY = p.y;
- tmp = (Vector<MenuElement>)selection.clone();
+ @SuppressWarnings("unchecked")
+ Vector<MenuElement> tmp = (Vector<MenuElement>)selection.clone();
selectionSize = tmp.size();
for(i=selectionSize - 1 ; i >= 0 ; i--) {
menuElement = tmp.elementAt(i);
--- a/jdk/src/share/classes/javax/swing/MultiUIDefaults.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/MultiUIDefaults.java Thu Jul 03 15:24:27 2014 -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) + ", ");
--- a/jdk/src/share/classes/javax/swing/PopupFactory.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/PopupFactory.java Thu Jul 03 15:24:27 2014 -0700
@@ -402,13 +402,14 @@
* <code>Window</code> to a <code>List</code> of
* <code>HeavyWeightPopup</code>s.
*/
+ @SuppressWarnings("unchecked")
private static Map<Window, List<HeavyWeightPopup>> getHeavyWeightPopupCache() {
synchronized (HeavyWeightPopup.class) {
Map<Window, List<HeavyWeightPopup>> cache = (Map<Window, List<HeavyWeightPopup>>)SwingUtilities.appContextGet(
heavyWeightPopupCacheKey);
if (cache == null) {
- cache = new HashMap<Window, List<HeavyWeightPopup>>(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<LightWeightPopup> getLightWeightPopupCache() {
List<LightWeightPopup> cache = (List<LightWeightPopup>)SwingUtilities.appContextGet(
lightWeightPopupCacheKey);
if (cache == null) {
- cache = new ArrayList<LightWeightPopup>();
+ 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<MediumWeightPopup> getMediumWeightPopupCache() {
List<MediumWeightPopup> cache = (List<MediumWeightPopup>)SwingUtilities.appContextGet(
mediumWeightPopupCacheKey);
if (cache == null) {
- cache = new ArrayList<MediumWeightPopup>();
+ cache = new ArrayList<>();
SwingUtilities.appContextPut(mediumWeightPopupCacheKey, cache);
}
return cache;
--- a/jdk/src/share/classes/javax/swing/RowFilter.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/RowFilter.java Thu Jul 03 15:24:27 2014 -0700
@@ -173,8 +173,7 @@
*/
public static <M,I> RowFilter<M,I> regexFilter(String regex,
int... indices) {
- return (RowFilter<M,I>)new RegexFilter(Pattern.compile(regex),
- indices);
+ return new RegexFilter<M, I>(Pattern.compile(regex), indices);
}
/**
@@ -201,7 +200,7 @@
*/
public static <M,I> RowFilter<M,I> dateFilter(ComparisonType type,
Date date, int... indices) {
- return (RowFilter<M,I>)new DateFilter(type, date.getTime(), indices);
+ return new DateFilter<M, I>(type, date.getTime(), indices);
}
/**
@@ -224,7 +223,7 @@
*/
public static <M,I> RowFilter<M,I> numberFilter(ComparisonType type,
Number number, int... indices) {
- return (RowFilter<M,I>)new NumberFilter(type, number, indices);
+ return new NumberFilter<M, I>(type, number, indices);
}
/**
@@ -397,7 +396,7 @@
}
- private static abstract class GeneralFilter extends RowFilter<Object,Object> {
+ private static abstract class GeneralFilter<M, I> extends RowFilter<M, I> {
private int[] columns;
GeneralFilter(int[] columns) {
@@ -405,7 +404,8 @@
this.columns = columns;
}
- public boolean include(Entry<? extends Object,? extends Object> value){
+ @Override
+ public boolean include(Entry<? extends M, ? extends I> 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<? extends Object,? extends Object> value, int index);
+ Entry<? extends M, ? extends I> value, int index);
}
- private static class RegexFilter extends GeneralFilter {
+ private static class RegexFilter<M, I> extends GeneralFilter<M, I> {
private Matcher matcher;
RegexFilter(Pattern regex, int[] columns) {
@@ -443,15 +442,16 @@
matcher = regex.matcher("");
}
+ @Override
protected boolean include(
- Entry<? extends Object,? extends Object> value, int index) {
+ Entry<? extends M, ? extends I> value, int index) {
matcher.reset(value.getStringValue(index));
return matcher.find();
}
}
- private static class DateFilter extends GeneralFilter {
+ private static class DateFilter<M, I> extends GeneralFilter<M, I> {
private long date;
private ComparisonType type;
@@ -464,8 +464,9 @@
this.date = date;
}
+ @Override
protected boolean include(
- Entry<? extends Object,? extends Object> value, int index) {
+ Entry<? extends M, ? extends I> 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<M, I> extends GeneralFilter<M, I> {
private boolean isComparable;
private Number number;
private ComparisonType type;
@@ -506,15 +504,16 @@
isComparable = (number instanceof Comparable);
}
+ @Override
@SuppressWarnings("unchecked")
protected boolean include(
- Entry<? extends Object,? extends Object> value, int index) {
+ Entry<? extends M, ? extends I> 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);
}
--- a/jdk/src/share/classes/javax/swing/SpinnerDateModel.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/SpinnerDateModel.java Thu Jul 03 15:24:27 2014 -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<Date> 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<Date> start, Comparable<Date> 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<Date> start) {
if ((start == null) ? (this.start != null) : !start.equals(this.start)) {
this.start = start;
fireStateChanged();
@@ -255,7 +255,7 @@
* @return the value of the <code>start</code> property
* @see #setStart
*/
- public Comparable getStart() {
+ public Comparable<Date> getStart() {
return start;
}
@@ -282,7 +282,7 @@
* @see #setStart
* @see #addChangeListener
*/
- public void setEnd(Comparable end) {
+ public void setEnd(Comparable<Date> end) {
if ((end == null) ? (this.end != null) : !end.equals(this.end)) {
this.end = end;
fireStateChanged();
@@ -296,7 +296,7 @@
* @return the value of the <code>end</code> property
* @see #setEnd
*/
- public Comparable getEnd() {
+ public Comparable<Date> getEnd() {
return end;
}
--- a/jdk/src/share/classes/javax/swing/SpinnerListModel.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/SpinnerListModel.java Thu Jul 03 15:24:27 2014 -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;
--- a/jdk/src/share/classes/javax/swing/SpinnerNumberModel.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/SpinnerNumberModel.java Thu Jul 03 15:24:27 2014 -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<? extends
+ // Number>, but that type is awkward to use since different
+ // instances of Number are not naturally Comparable. For example,
+ // a Double implements Comparable<Double> and an Integer
+ // implements Comparable<Integer>. Neither Integer nor Double will
+ // have a bridge method for Comparable<Number>. However, it safe
+ // to cast Comparable<?> to Comparable<Object> since all
+ // Comparables will have a compare(Object> method, possibly as a
+ // bridge.
+ private Comparable<?> minimum, maximum;
/**
@@ -117,12 +126,16 @@
* <code>null</code> or if the following expression is false:
* <code>minimum <= value <= maximum</code>
*/
- public SpinnerNumberModel(Number value, Comparable minimum, Comparable maximum, Number stepSize) {
+ @SuppressWarnings("unchecked") // Casts to Comparable<Object>
+ 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<Object>)minimum).compareTo(value) <= 0)) &&
+ ((maximum == null) || (((Comparable<Object>)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 <code>minimum</code> 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 <code>maximum</code> property
* @see #setMaximum
*/
- public Comparable getMaximum() {
+ public Comparable<?> getMaximum() {
return maximum;
}
@@ -317,7 +330,7 @@
return stepSize;
}
-
+ @SuppressWarnings("unchecked") // Casts to Comparable<Object>
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<Object>)maximum).compareTo(newValue) < 0)) {
return null;
}
- if ((minimum != null) && (minimum.compareTo(newValue) > 0)) {
+ if ((minimum != null) && (((Comparable<Object>)minimum).compareTo(newValue) > 0)) {
return null;
}
else {
--- a/jdk/src/share/classes/javax/swing/SpringLayout.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/SpringLayout.java Thu Jul 03 15:24:27 2014 -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);
}
--- a/jdk/src/share/classes/javax/swing/SwingWorker.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/SwingWorker.java Thu Jul 03 15:24:27 2014 -0700
@@ -820,7 +820,9 @@
doSubmit = new DoSubmitAccumulativeRunnable();
appContext.put(DO_SUBMIT_KEY, doSubmit);
}
- return (AccumulativeRunnable<Runnable>) doSubmit;
+ @SuppressWarnings("unchecked")
+ AccumulativeRunnable<Runnable> tmp = (AccumulativeRunnable<Runnable>) doSubmit;
+ return tmp;
}
}
private static class DoSubmitAccumulativeRunnable
--- a/jdk/src/share/classes/javax/swing/UIDefaults.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/UIDefaults.java Thu Jul 03 15:24:27 2014 -0700
@@ -311,10 +311,10 @@
} else {
b = ResourceBundle.getBundle(bundleName, l);
}
- Enumeration keys = b.getKeys();
+ Enumeration<String> 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<? extends ComponentUI> tmp = (Class<? extends ComponentUI>)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
* <code>UIResource</code> 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
--- a/jdk/src/share/classes/javax/swing/UIManager.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/UIManager.java Thu Jul 03 15:24:27 2014 -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<Object, String> 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);
--- a/jdk/src/share/classes/javax/swing/event/EventListenerList.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/event/EventListenerList.java Thu Jul 03 15:24:27 2014 -0700
@@ -141,11 +141,14 @@
public <T extends EventListener> T[] getListeners(Class<T> 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<EventListener>)Class.forName(name, true, cl), l);
+ @SuppressWarnings("unchecked")
+ Class<EventListener> tmp = (Class<EventListener>)Class.forName(name, true, cl);
+ add(tmp, l);
}
}
--- a/jdk/src/share/classes/javax/swing/event/RowSorterEvent.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/event/RowSorterEvent.java Thu Jul 03 15:24:27 2014 -0700
@@ -71,7 +71,7 @@
* @throws IllegalArgumentException if <code>source</code> is
* <code>null</code>
*/
- public RowSorterEvent(RowSorter source) {
+ public RowSorterEvent(RowSorter<?> source) {
this(source, Type.SORT_ORDER_CHANGED, null);
}
@@ -85,7 +85,7 @@
* @throws IllegalArgumentException if source or <code>type</code> is
* <code>null</code>
*/
- 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 <code>RowSorter</code>
*/
- public RowSorter getSource() {
+ @Override
+ public RowSorter<?> getSource() {
return (RowSorter)super.getSource();
}
--- a/jdk/src/share/classes/javax/swing/table/DefaultTableColumnModel.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/table/DefaultTableColumnModel.java Thu Jul 03 15:24:27 2014 -0700
@@ -269,12 +269,12 @@
throw new IllegalArgumentException("Identifier is null");
}
- Enumeration enumeration = getColumns();
+ Enumeration<TableColumn> 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 @@
* <code>totalColumnWidth</code> property.
*/
protected void recalcWidthCache() {
- Enumeration enumeration = getColumns();
+ Enumeration<TableColumn> enumeration = getColumns();
totalColumnWidth = 0;
while (enumeration.hasMoreElements()) {
- totalColumnWidth += ((TableColumn)enumeration.nextElement()).getWidth();
+ totalColumnWidth += enumeration.nextElement().getWidth();
}
}
--- a/jdk/src/share/classes/javax/swing/table/DefaultTableModel.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/table/DefaultTableModel.java Thu Jul 03 15:24:27 2014 -0700
@@ -70,10 +70,10 @@
* The <code>Vector</code> of <code>Vectors</code> of
* <code>Object</code> values.
*/
- protected Vector dataVector;
+ protected Vector<Vector<Object>> dataVector;
/** The <code>Vector</code> of column identifiers. */
- protected Vector columnIdentifiers;
+ protected Vector<Object> columnIdentifiers;
//
// Constructors
@@ -87,8 +87,8 @@
this(0, 0);
}
- private static Vector newVector(int size) {
- Vector v = new Vector(size);
+ private static <E> Vector<E> newVector(int size) {
+ Vector<E> 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<Object> columnNames, int rowCount) {
setDataVector(newVector(rowCount), columnNames);
}
@@ -156,7 +156,7 @@
* @see #getDataVector
* @see #setDataVector
*/
- public DefaultTableModel(Vector data, Vector columnNames) {
+ public DefaultTableModel(Vector<Vector<Object>> data, Vector<Object> columnNames) {
setDataVector(data, columnNames);
}
@@ -191,12 +191,12 @@
* @see #newRowsAdded
* @see #setDataVector
*/
- public Vector getDataVector() {
+ public Vector<Vector<Object>> getDataVector() {
return dataVector;
}
- private static Vector nonNullVector(Vector v) {
- return (v != null) ? v : new Vector();
+ private static <E> Vector<E> nonNullVector(Vector<E> 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<Vector<Object>> dataVector,
+ Vector<Object> 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<Object> 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<Object> 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 <E> void rotate(Vector<E> 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<Object> 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<Object>)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<Object> 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<Object> 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<Object> 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<Object> rowVector = dataVector.elementAt(row);
rowVector.setElementAt(aValue, column);
fireTableCellUpdated(row, column);
}
@@ -682,11 +683,11 @@
* @return the new vector; if <code>anArray</code> is <code>null</code>,
* returns <code>null</code>
*/
- protected static Vector convertToVector(Object[] anArray) {
+ protected static Vector<Object> convertToVector(Object[] anArray) {
if (anArray == null) {
return null;
}
- Vector<Object> v = new Vector<Object>(anArray.length);
+ Vector<Object> v = new Vector<>(anArray.length);
for (Object o : anArray) {
v.addElement(o);
}
@@ -699,11 +700,11 @@
* @return the new vector of vectors; if <code>anArray</code> is
* <code>null</code>, returns <code>null</code>
*/
- protected static Vector convertToVector(Object[][] anArray) {
+ protected static Vector<Vector<Object>> convertToVector(Object[][] anArray) {
if (anArray == null) {
return null;
}
- Vector<Vector> v = new Vector<Vector>(anArray.length);
+ Vector<Vector<Object>> v = new Vector<>(anArray.length);
for (Object[] o : anArray) {
v.addElement(convertToVector(o));
}
--- a/jdk/src/share/classes/javax/swing/table/TableRowSorter.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/table/TableRowSorter.java Thu Jul 03 15:24:27 2014 -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<Object> {
@SuppressWarnings("unchecked")
public int compare(Object o1, Object o2) {
return ((Comparable)o1).compareTo(o2);
--- a/jdk/src/share/classes/javax/swing/text/AbstractDocument.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/text/AbstractDocument.java Thu Jul 03 15:24:27 2014 -0700
@@ -2193,7 +2193,7 @@
* <code>Enumeration</code>.
* @return the children of the receiver as an <code>Enumeration</code>
*/
- public abstract Enumeration<?> children();
+ public abstract Enumeration<TreeNode> children();
// --- serialization ---------------------------------------------
@@ -2456,11 +2456,11 @@
* <code>Enumeration</code>.
* @return the children of the receiver
*/
- public Enumeration<AbstractElement> children() {
+ public Enumeration<TreeNode> children() {
if(nchildren == 0)
return null;
- Vector<AbstractElement> tempVector = new Vector<AbstractElement>(nchildren);
+ Vector<TreeNode> tempVector = new Vector<>(nchildren);
for(int counter = 0; counter < nchildren; counter++)
tempVector.addElement(children[counter]);
@@ -2610,7 +2610,8 @@
* <code>Enumeration</code>.
* @return the children of the receiver
*/
- public Enumeration<?> children() {
+ @Override
+ public Enumeration<TreeNode> children() {
return null;
}
--- a/jdk/src/share/classes/javax/swing/tree/AbstractLayoutCache.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/tree/AbstractLayoutCache.java Thu Jul 03 15:24:27 2014 -0700
@@ -228,10 +228,10 @@
endY = bounds.height + bounds.y;
}
- Enumeration paths = getVisiblePathsFrom(firstPath);
+ Enumeration<TreePath> 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);
--- a/jdk/src/share/classes/javax/swing/tree/DefaultMutableTreeNode.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/tree/DefaultMutableTreeNode.java Thu Jul 03 15:24:27 2014 -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<TreeNode> 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<TreeNode> children() {
if (children == null) {
return EMPTY_ENUMERATION;
} else {
@@ -557,7 +557,7 @@
*/
public int getDepth() {
Object last = null;
- Enumeration enum_ = breadthFirstEnumeration();
+ Enumeration<TreeNode> 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<TreeNode> 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<TreeNode> 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<TreeNode> 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<TreeNode> 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<TreeNode> pathFromAncestorEnumeration(TreeNode ancestor) {
return new PathBetweenNodesEnumeration(ancestor, this);
}
@@ -1218,10 +1218,10 @@
int count = 0;
TreeNode node;
- Enumeration enum_ = breadthFirstEnumeration(); // order matters not
+ Enumeration<TreeNode> 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<TreeNode> {
- private final Stack<Enumeration> stack = new Stack<Enumeration>();
+ private final Stack<Enumeration<TreeNode>> 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<TreeNode> enumer = stack.peek();
+ TreeNode node = enumer.nextElement();
+ @SuppressWarnings("unchecked")
+ Enumeration<TreeNode> 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();
--- a/jdk/src/share/classes/javax/swing/tree/DefaultTreeCellEditor.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/tree/DefaultTreeCellEditor.java Thu Jul 03 15:24:27 2014 -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();
--- a/jdk/src/share/classes/javax/swing/tree/DefaultTreeModel.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/tree/DefaultTreeModel.java Thu Jul 03 15:24:27 2014 -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();
--- a/jdk/src/share/classes/javax/swing/tree/TreeNode.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/tree/TreeNode.java Thu Jul 03 15:24:27 2014 -0700
@@ -99,5 +99,5 @@
*
* @return the children of the receiver as an {@code Enumeration}
*/
- Enumeration children();
+ Enumeration<TreeNode> children();
}
--- a/jdk/src/share/classes/javax/swing/tree/VariableHeightLayoutCache.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/tree/VariableHeightLayoutCache.java Thu Jul 03 15:24:27 2014 -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<TreeNode> children() {
if (!this.isExpanded()) {
return DefaultMutableTreeNode.EMPTY_ENUMERATION;
} else {
@@ -1405,7 +1406,7 @@
* <code>createIfNeeded</code> is true, the children are first
* loaded.
*/
- protected Enumeration getLoadedChildren(boolean createIfNeeded) {
+ protected Enumeration<TreeNode> getLoadedChildren(boolean createIfNeeded) {
if(!createIfNeeded || hasBeenExpanded)
return super.children();
@@ -1499,7 +1500,7 @@
}
int i = originalRow;
- Enumeration cursor = preorderEnumeration();
+ Enumeration<TreeNode> 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<TreeNode> cursor = preorderEnumeration();
cursor.nextElement(); // don't remove me, I'm still visible
int rowsDeleted = 0;
boolean isFixed = isFixedRowHeight();
--- a/jdk/src/share/classes/javax/swing/undo/CompoundEdit.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/undo/CompoundEdit.java Thu Jul 03 15:24:27 2014 -0700
@@ -72,9 +72,9 @@
*/
public void redo() throws CannotRedoException {
super.redo();
- Enumeration cursor = edits.elements();
+ Enumeration<UndoableEdit> 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<UndoableEdit> cursor = edits.elements();
while (cursor.hasMoreElements()) {
- if (((UndoableEdit)cursor.nextElement()).isSignificant()) {
+ if (cursor.nextElement().isSignificant()) {
return true;
}
}
--- a/jdk/src/share/classes/javax/swing/undo/StateEdit.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/undo/StateEdit.java Thu Jul 03 15:24:27 2014 -0700
@@ -170,8 +170,8 @@
* Remove redundant key/values in state hashtables.
*/
protected void removeRedundantState() {
- Vector<Object> uselessKeys = new Vector<Object>();
- Enumeration myKeys = preState.keys();
+ Vector<Object> uselessKeys = new Vector<>();
+ Enumeration<Object> myKeys = preState.keys();
// Locate redundant state
while (myKeys.hasMoreElements()) {
--- a/jdk/src/share/classes/javax/swing/undo/UndoableEditSupport.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/javax/swing/undo/UndoableEditSupport.java Thu Jul 03 15:24:27 2014 -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<UndoableEditListener> cursor =
+ ((Vector<UndoableEditListener>)listeners.clone()).elements();
while (cursor.hasMoreElements()) {
- ((UndoableEditListener)cursor.nextElement()).
- undoableEditHappened(ev);
+ cursor.nextElement().undoableEditHappened(ev);
}
}
--- a/jdk/src/share/classes/sun/tools/jconsole/inspector/TableSorter.java Thu Jul 03 18:47:42 2014 +0400
+++ b/jdk/src/share/classes/sun/tools/jconsole/inspector/TableSorter.java Thu Jul 03 15:24:27 2014 -0700
@@ -217,17 +217,17 @@
}
}
- private Vector<?> getRow(int row) {
- return (Vector) dataVector.elementAt(row);
+ private Vector<Object> getRow(int row) {
+ return dataVector.elementAt(row);
}
@SuppressWarnings("unchecked")
- private void setRow(Vector<?> data, int row) {
+ private void setRow(Vector<Object> data, int row) {
dataVector.setElementAt(data,row);
}
private void swap(int i, int j, int column) {
- Vector<?> data = getRow(i);
+ Vector<Object> data = getRow(i);
setRow(getRow(j),i);
setRow(data,j);