8033525: Fix raw and unchecked lint warnings in sun.swing.*

Reviewed-by: alexsch
This commit is contained in:
Joe Darcy 2014-02-04 08:58:06 -08:00
parent 5fc6cd2aa9
commit 8d903056f3
6 changed files with 48 additions and 47 deletions

View File

@ -44,7 +44,7 @@ import java.util.*;
* @author Scott Violet
*/
@SuppressWarnings("serial") // JDK-implementation class
public class BakedArrayList extends ArrayList {
public class BakedArrayList extends ArrayList<Object> {
/**
* The cached hashCode.
*/
@ -54,7 +54,7 @@ public class BakedArrayList extends ArrayList {
super(size);
}
public BakedArrayList(java.util.List data) {
public BakedArrayList(java.util.List<?> data) {
this(data.size());
for (int counter = 0, max = data.size(); counter < max; counter++){
add(data.get(counter));

View File

@ -240,7 +240,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
}
}
private void repaintListSelection(JList list) {
private void repaintListSelection(JList<?> list) {
int[] indices = list.getSelectedIndices();
for (int i : indices) {
Rectangle bounds = list.getCellBounds(i, i);
@ -272,7 +272,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
private boolean fullRowSelection = false;
private ListSelectionModel listSelectionModel;
private JList list;
private JList<?> list;
private JTable detailsTable;
private static final int COLUMN_FILENAME = 0;
@ -332,7 +332,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
createdViewPanel = createList();
}
list = (JList) findChildComponent(createdViewPanel, JList.class);
list = findChildComponent(createdViewPanel, JList.class);
if (listSelectionModel == null) {
listSelectionModel = list.getSelectionModel();
if (detailsTable != null) {
@ -353,7 +353,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
createdViewPanel = createDetailsView();
}
detailsTable = (JTable) findChildComponent(createdViewPanel, JTable.class);
detailsTable = findChildComponent(createdViewPanel, JTable.class);
detailsTable.setRowHeight(Math.max(detailsTable.getFont().getSize() + 4, 16 + 1));
if (listSelectionModel != null) {
detailsTable.setSelectionModel(listSelectionModel);
@ -569,7 +569,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
}
private void updateListRowCount(JList list) {
private void updateListRowCount(JList<?> list) {
if (smallIconsView) {
list.setVisibleRowCount(getModel().getSize() / 3);
} else {
@ -584,7 +584,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
@SuppressWarnings("serial") // anonymous class
final JList<Object> list = new JList<Object>() {
public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
ListModel model = getModel();
ListModel<?> model = getModel();
int max = model.getSize();
if (prefix == null || startIndex < 0 || startIndex >= max) {
throw new IllegalArgumentException();
@ -918,7 +918,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
public void updateComparators(ShellFolderColumnInfo [] columns) {
for (int i = 0; i < columns.length; i++) {
Comparator c = columns[i].getComparator();
Comparator<?> c = columns[i].getComparator();
if (c != null) {
c = new DirectoriesFirstComparatorWrapper(i, c);
}
@ -969,12 +969,13 @@ public class FilePane extends JPanel implements PropertyChangeListener {
* directory and file to file using the wrapped comparator.
*/
private class DirectoriesFirstComparatorWrapper implements Comparator<File> {
private Comparator comparator;
private Comparator<Object> comparator;
private int column;
public DirectoriesFirstComparatorWrapper(int column, Comparator comparator) {
@SuppressWarnings("unchecked")
public DirectoriesFirstComparatorWrapper(int column, Comparator<?> comparator) {
this.column = column;
this.comparator = comparator;
this.comparator = (Comparator<Object>)comparator;
}
public int compare(File f1, File f2) {
@ -1492,7 +1493,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
@SuppressWarnings("serial") // JDK-implementation class
protected class FileRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList list, Object value,
public Component getListCellRendererComponent(JList<?> list, Object value,
int index, boolean isSelected,
boolean cellHasFocus) {
@ -1968,14 +1969,14 @@ public class FilePane extends JPanel implements PropertyChangeListener {
return fileChooserUIAccessor.getDirectory();
}
private Component findChildComponent(Container container, Class cls) {
private <T> T findChildComponent(Container container, Class<T> cls) {
int n = container.getComponentCount();
for (int i = 0; i < n; i++) {
Component comp = container.getComponent(i);
if (cls.isInstance(comp)) {
return comp;
return cls.cast(comp);
} else if (comp instanceof Container) {
Component c = findChildComponent((Container)comp, cls);
T c = findChildComponent((Container)comp, cls);
if (c != null) {
return c;
}
@ -2029,7 +2030,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
public Action getApproveSelectionAction();
public Action getChangeToParentDirectoryAction();
public Action getNewFolderAction();
public MouseListener createDoubleClickListener(JList list);
public MouseListener createDoubleClickListener(JList<?> list);
public ListSelectionListener createListSelectionListener();
}
}

View File

@ -67,13 +67,13 @@ public class SwingLazyValue implements UIDefaults.LazyValue {
ReflectUtil.checkPackageAccess(className);
Class<?> c = Class.forName(className, true, null);
if (methodName != null) {
Class[] types = getClassArray(args);
Class<?>[] types = getClassArray(args);
Method m = c.getMethod(methodName, types);
makeAccessible(m);
return m.invoke(c, args);
} else {
Class[] types = getClassArray(args);
Constructor constructor = c.getConstructor(types);
Class<?>[] types = getClassArray(args);
Constructor<?> constructor = c.getConstructor(types);
makeAccessible(constructor);
return constructor.newInstance(args);
}
@ -96,10 +96,10 @@ public class SwingLazyValue implements UIDefaults.LazyValue {
});
}
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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -127,7 +127,7 @@ public class SwingUtilities2 {
*/
public static class AATextInfo {
private static AATextInfo getAATextInfoFromMap(Map hints) {
private static AATextInfo getAATextInfoFromMap(Map<java.awt.RenderingHints.Key, Object> hints) {
Object aaHint = hints.get(KEY_TEXT_ANTIALIASING);
Object contHint = hints.get(KEY_TEXT_LCD_CONTRAST);
@ -141,12 +141,13 @@ public class SwingUtilities2 {
}
}
@SuppressWarnings("unchecked")
public static AATextInfo getAATextInfo(boolean lafCondition) {
SunToolkit.setAAFontSettingsCondition(lafCondition);
Toolkit tk = Toolkit.getDefaultToolkit();
Object map = tk.getDesktopProperty(SunToolkit.DESKTOPFONTHINTS);
if (map instanceof Map) {
return getAATextInfoFromMap((Map)map);
return getAATextInfoFromMap((Map<java.awt.RenderingHints.Key, Object>)map);
} else {
return null;
}
@ -663,7 +664,7 @@ public class SwingUtilities2 {
* Otherwise, this method returns -1.
* This is used to make WindowsL&F JFileChooser act like native dialogs.
*/
public static int loc2IndexFileList(JList list, Point point) {
public static int loc2IndexFileList(JList<?> list, Point point) {
int index = list.locationToIndex(point);
if (index != -1) {
Object bySize = list.getClientProperty("List.isFileList");
@ -680,11 +681,10 @@ public class SwingUtilities2 {
* Returns true if the given point is within the actual bounds of the
* JList item at index (not just inside the cell).
*/
private static boolean pointIsInActualBounds(JList list, int index,
private static <T> boolean pointIsInActualBounds(JList<T> list, int index,
Point point) {
ListCellRenderer renderer = list.getCellRenderer();
ListModel dataModel = list.getModel();
Object value = dataModel.getElementAt(index);
ListCellRenderer<? super T> renderer = list.getCellRenderer();
T value = list.getModel().getElementAt(index);
Component item = renderer.getListCellRendererComponent(list,
value, index, false, false);
Dimension itemSize = item.getPreferredSize();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -61,7 +61,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
/**
* User specific data.
*/
private Map data;
private Map<Object, Object> data;
/**
* Font to use if there is no matching StateInfo, or the StateInfo doesn't
@ -106,7 +106,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
}
}
if (style.data != null) {
data = new HashMap();
data = new HashMap<>();
data.putAll(style.data);
}
font = style.font;
@ -124,7 +124,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
* @param data Style specific data.
*/
public DefaultSynthStyle(Insets insets, boolean opaque,
StateInfo[] states, Map data) {
StateInfo[] states, Map<Object, Object> data) {
this.insets = insets;
this.opaque = opaque;
this.states = states;
@ -366,7 +366,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
*
* @param data Style specific values
*/
public void setData(Map data) {
public void setData(Map<Object, Object> data) {
this.data = data;
}
@ -375,7 +375,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
*
* @return Style specific data.
*/
public Map getData() {
public Map<Object, Object> getData() {
return data;
}
@ -402,7 +402,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
}
private Object getKeyFromData(Map stateData, Object key) {
private Object getKeyFromData(Map<Object, Object> stateData, Object key) {
Object value = null;
if (stateData != null) {
@ -462,7 +462,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
}
}
if (data != null) {
style.data = new HashMap();
style.data = new HashMap<>();
style.data.putAll(data);
}
return style;
@ -570,7 +570,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
}
if (data != null) {
if (style.data == null) {
style.data = new HashMap();
style.data = new HashMap<>();
}
style.data.putAll(data);
}
@ -708,7 +708,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
* a component.
*/
public static class StateInfo {
private Map data;
private Map<Object, Object> data;
private Font font;
private Color[] colors;
private int state;
@ -746,7 +746,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
this.font = info.font;
if(info.data != null) {
if(data == null) {
data = new HashMap();
data = new HashMap<>();
}
data.putAll(info.data);
}
@ -756,11 +756,11 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
}
}
public Map getData() {
public Map<Object, Object> getData() {
return data;
}
public void setData(Map data) {
public void setData(Map<Object, Object> data) {
this.data = data;
}
@ -836,7 +836,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
}
if(data != null) {
if(info.data == null) {
info.data = new HashMap();
info.data = new HashMap<>();
}
info.data.putAll(data);
}

View File

@ -175,7 +175,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
return SynthFileChooserUIImpl.this.getNewFolderAction();
}
public MouseListener createDoubleClickListener(JList list) {
public MouseListener createDoubleClickListener(JList<?> list) {
return SynthFileChooserUIImpl.this.createDoubleClickListener(getFileChooser(),
list);
}
@ -563,7 +563,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
if (currentDirectory != null) {
JComponent cb = getDirectoryComboBox();
if (cb instanceof JComboBox) {
ComboBoxModel model = ((JComboBox)cb).getModel();
ComboBoxModel<?> model = ((JComboBox)cb).getModel();
if (model instanceof DirectoryComboBoxModel) {
((DirectoryComboBoxModel)model).addItem(currentDirectory);
}