mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-05 00:29:40 +00:00
8005492: Reduce number of warnings in sun/awt/* classes
Reviewed-by: art, anthony
This commit is contained in:
parent
08f29b04df
commit
9a4e15eaf6
@ -300,7 +300,7 @@ public class Button extends Component implements Accessible {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized ActionListener[] getActionListeners() {
|
||||
return (ActionListener[]) (getListeners(ActionListener.class));
|
||||
return getListeners(ActionListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -470,7 +470,7 @@ public class Checkbox extends Component implements ItemSelectable, Accessible {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized ItemListener[] getItemListeners() {
|
||||
return (ItemListener[]) (getListeners(ItemListener.class));
|
||||
return getListeners(ItemListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -85,7 +85,7 @@ public class Choice extends Component implements ItemSelectable, Accessible {
|
||||
* @see #insert(String, int)
|
||||
* @see #remove(String)
|
||||
*/
|
||||
Vector pItems;
|
||||
Vector<String> pItems;
|
||||
|
||||
/**
|
||||
* The index of the current choice for this <code>Choice</code>
|
||||
@ -129,7 +129,7 @@ public class Choice extends Component implements ItemSelectable, Accessible {
|
||||
*/
|
||||
public Choice() throws HeadlessException {
|
||||
GraphicsEnvironment.checkHeadless();
|
||||
pItems = new Vector();
|
||||
pItems = new Vector<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,7 +191,7 @@ public class Choice extends Component implements ItemSelectable, Accessible {
|
||||
* be called on the toolkit thread.
|
||||
*/
|
||||
final String getItemImpl(int index) {
|
||||
return (String)pItems.elementAt(index);
|
||||
return pItems.elementAt(index);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -524,7 +524,7 @@ public class Choice extends Component implements ItemSelectable, Accessible {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized ItemListener[] getItemListeners() {
|
||||
return (ItemListener[])(getListeners(ItemListener.class));
|
||||
return getListeners(ItemListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -7287,6 +7287,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
|
||||
}
|
||||
final Set<AWTKeyStroke> getFocusTraversalKeys_NoIDCheck(int id) {
|
||||
// Okay to return Set directly because it is an unmodifiable view
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<AWTKeyStroke> keystrokes = (focusTraversalKeys != null)
|
||||
? focusTraversalKeys[id]
|
||||
: null;
|
||||
|
||||
@ -161,7 +161,7 @@ public class Container extends Component {
|
||||
private boolean focusTraversalPolicyProvider;
|
||||
|
||||
// keeps track of the threads that are printing this component
|
||||
private transient Set printingThreads;
|
||||
private transient Set<Thread> printingThreads;
|
||||
// True if there is at least one thread that's printing this component
|
||||
private transient boolean printing = false;
|
||||
|
||||
@ -275,7 +275,7 @@ public class Container extends Component {
|
||||
*/
|
||||
public Container() {
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked","rawtypes"})
|
||||
void initializeFocusTraversalKeys() {
|
||||
focusTraversalKeys = new Set[4];
|
||||
}
|
||||
@ -2006,7 +2006,7 @@ public class Container extends Component {
|
||||
try {
|
||||
synchronized (getObjectLock()) {
|
||||
if (printingThreads == null) {
|
||||
printingThreads = new HashSet();
|
||||
printingThreads = new HashSet<>();
|
||||
}
|
||||
printingThreads.add(t);
|
||||
printing = true;
|
||||
@ -2148,7 +2148,7 @@ public class Container extends Component {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized ContainerListener[] getContainerListeners() {
|
||||
return (ContainerListener[]) (getListeners(ContainerListener.class));
|
||||
return getListeners(ContainerListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2599,9 +2599,9 @@ public class Container extends Component {
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new HeadlessException();
|
||||
}
|
||||
PointerInfo pi = (PointerInfo)java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction() {
|
||||
public Object run() {
|
||||
PointerInfo pi = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<PointerInfo>() {
|
||||
public PointerInfo run() {
|
||||
return MouseInfo.getPointerInfo();
|
||||
}
|
||||
}
|
||||
@ -2682,7 +2682,7 @@ public class Container extends Component {
|
||||
y - comp.y,
|
||||
ignoreEnabled);
|
||||
} else {
|
||||
comp = comp.locate(x - comp.x, y - comp.y);
|
||||
comp = comp.getComponentAt(x - comp.x, y - comp.y);
|
||||
}
|
||||
if (comp != null && comp.visible &&
|
||||
(ignoreEnabled || comp.enabled))
|
||||
@ -2700,7 +2700,7 @@ public class Container extends Component {
|
||||
y - comp.y,
|
||||
ignoreEnabled);
|
||||
} else {
|
||||
comp = comp.locate(x - comp.x, y - comp.y);
|
||||
comp = comp.getComponentAt(x - comp.x, y - comp.y);
|
||||
}
|
||||
if (comp != null && comp.visible &&
|
||||
(ignoreEnabled || comp.enabled))
|
||||
@ -4637,7 +4637,7 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
|
||||
private void startListeningForOtherDrags() {
|
||||
//System.out.println("Adding AWTEventListener");
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction() {
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
nativeContainer.getToolkit().addAWTEventListener(
|
||||
LightweightDispatcher.this,
|
||||
@ -4652,7 +4652,7 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
|
||||
private void stopListeningForOtherDrags() {
|
||||
//System.out.println("Removing AWTEventListener");
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction() {
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
nativeContainer.getToolkit().removeAWTEventListener(LightweightDispatcher.this);
|
||||
return null;
|
||||
|
||||
@ -1047,9 +1047,9 @@ public class Dialog extends Window {
|
||||
// if this dialog is toolkit-modal, the filter should be added
|
||||
// to all EDTs (for all AppContexts)
|
||||
if (modalityType == ModalityType.TOOLKIT_MODAL) {
|
||||
Iterator it = AppContext.getAppContexts().iterator();
|
||||
Iterator<AppContext> it = AppContext.getAppContexts().iterator();
|
||||
while (it.hasNext()) {
|
||||
AppContext appContext = (AppContext)it.next();
|
||||
AppContext appContext = it.next();
|
||||
if (appContext == showAppContext) {
|
||||
continue;
|
||||
}
|
||||
@ -1084,9 +1084,9 @@ public class Dialog extends Window {
|
||||
// if this dialog is toolkit-modal, its filter must be removed
|
||||
// from all EDTs (for all AppContexts)
|
||||
if (modalityType == ModalityType.TOOLKIT_MODAL) {
|
||||
Iterator it = AppContext.getAppContexts().iterator();
|
||||
Iterator<AppContext> it = AppContext.getAppContexts().iterator();
|
||||
while (it.hasNext()) {
|
||||
AppContext appContext = (AppContext)it.next();
|
||||
AppContext appContext = it.next();
|
||||
if (appContext == showAppContext) {
|
||||
continue;
|
||||
}
|
||||
@ -1396,7 +1396,7 @@ public class Dialog extends Window {
|
||||
if (d.shouldBlock(this)) {
|
||||
Window w = d;
|
||||
while ((w != null) && (w != this)) {
|
||||
w = (Window)(w.getOwner_NoClientCode());
|
||||
w = w.getOwner_NoClientCode();
|
||||
}
|
||||
if ((w == this) || !shouldBlock(d) || (modalityType.compareTo(d.getModalityType()) < 0)) {
|
||||
blockers.add(d);
|
||||
@ -1611,7 +1611,7 @@ public class Dialog extends Window {
|
||||
setModal(modal);
|
||||
}
|
||||
|
||||
blockedWindows = new IdentityArrayList();
|
||||
blockedWindows = new IdentityArrayList<>();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -353,7 +353,7 @@ public class Frame extends Window implements MenuContainer {
|
||||
* @serial
|
||||
* @see java.awt.Window#ownedWindowList
|
||||
*/
|
||||
Vector ownedWindows;
|
||||
Vector<Window> ownedWindows;
|
||||
|
||||
private static final String base = "frame";
|
||||
private static int nameCounter = 0;
|
||||
@ -1242,7 +1242,7 @@ public class Frame extends Window implements MenuContainer {
|
||||
//
|
||||
if (ownedWindows != null) {
|
||||
for (int i = 0; i < ownedWindows.size(); i++) {
|
||||
connectOwnedWindow((Window) ownedWindows.elementAt(i));
|
||||
connectOwnedWindow(ownedWindows.elementAt(i));
|
||||
}
|
||||
ownedWindows = null;
|
||||
}
|
||||
|
||||
@ -416,7 +416,7 @@ public abstract class KeyboardFocusManager
|
||||
}
|
||||
}
|
||||
|
||||
static Set initFocusTraversalKeysSet(String value, Set targetSet) {
|
||||
static Set<AWTKeyStroke> initFocusTraversalKeysSet(String value, Set<AWTKeyStroke> targetSet) {
|
||||
StringTokenizer tokens = new StringTokenizer(value, ",");
|
||||
while (tokens.hasMoreTokens()) {
|
||||
targetSet.add(AWTKeyStroke.getAWTKeyStroke(tokens.nextToken()));
|
||||
|
||||
@ -1012,7 +1012,7 @@ public class Scrollbar extends Component implements Adjustable, Accessible {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized AdjustmentListener[] getAdjustmentListeners() {
|
||||
return (AdjustmentListener[])(getListeners(AdjustmentListener.class));
|
||||
return getListeners(AdjustmentListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -123,7 +123,7 @@ public class TextArea extends TextComponent {
|
||||
* Cache the Sets of forward and backward traversal keys so we need not
|
||||
* look them up each time.
|
||||
*/
|
||||
private static Set forwardTraversalKeys, backwardTraversalKeys;
|
||||
private static Set<AWTKeyStroke> forwardTraversalKeys, backwardTraversalKeys;
|
||||
|
||||
/*
|
||||
* JDK 1.1 serialVersionUID
|
||||
@ -143,10 +143,10 @@ public class TextArea extends TextComponent {
|
||||
}
|
||||
forwardTraversalKeys = KeyboardFocusManager.initFocusTraversalKeysSet(
|
||||
"ctrl TAB",
|
||||
new HashSet());
|
||||
new HashSet<AWTKeyStroke>());
|
||||
backwardTraversalKeys = KeyboardFocusManager.initFocusTraversalKeysSet(
|
||||
"ctrl shift TAB",
|
||||
new HashSet());
|
||||
new HashSet<AWTKeyStroke>());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -606,7 +606,7 @@ public class TextComponent extends Component implements Accessible {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized TextListener[] getTextListeners() {
|
||||
return (TextListener[])(getListeners(TextListener.class));
|
||||
return getListeners(TextListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -507,7 +507,7 @@ public class TextField extends TextComponent {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized ActionListener[] getActionListeners() {
|
||||
return (ActionListener[])(getListeners(ActionListener.class));
|
||||
return getListeners(ActionListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -863,7 +863,7 @@ public abstract class Toolkit {
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
String nm = null;
|
||||
Class cls = null;
|
||||
Class<?> cls = null;
|
||||
try {
|
||||
nm = System.getProperty("awt.toolkit");
|
||||
try {
|
||||
|
||||
@ -441,7 +441,7 @@ public class Window extends Container implements Accessible {
|
||||
transient Object anchor = new Object();
|
||||
static class WindowDisposerRecord implements sun.java2d.DisposerRecord {
|
||||
final WeakReference<Window> owner;
|
||||
final WeakReference weakThis;
|
||||
final WeakReference<Window> weakThis;
|
||||
final WeakReference<AppContext> context;
|
||||
WindowDisposerRecord(AppContext context, Window victim) {
|
||||
owner = new WeakReference<Window>(victim.getOwner());
|
||||
@ -1542,6 +1542,7 @@ public class Window extends Container implements Accessible {
|
||||
private static Window[] getWindows(AppContext appContext) {
|
||||
synchronized (Window.class) {
|
||||
Window realCopy[];
|
||||
@SuppressWarnings("unchecked")
|
||||
Vector<WeakReference<Window>> windowList =
|
||||
(Vector<WeakReference<Window>>)appContext.get(Window.class);
|
||||
if (windowList != null) {
|
||||
@ -1866,7 +1867,7 @@ public class Window extends Container implements Accessible {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized WindowListener[] getWindowListeners() {
|
||||
return (WindowListener[])(getListeners(WindowListener.class));
|
||||
return getListeners(WindowListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1882,7 +1883,7 @@ public class Window extends Container implements Accessible {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized WindowFocusListener[] getWindowFocusListeners() {
|
||||
return (WindowFocusListener[])(getListeners(WindowFocusListener.class));
|
||||
return getListeners(WindowFocusListener.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1898,7 +1899,7 @@ public class Window extends Container implements Accessible {
|
||||
* @since 1.4
|
||||
*/
|
||||
public synchronized WindowStateListener[] getWindowStateListeners() {
|
||||
return (WindowStateListener[])(getListeners(WindowStateListener.class));
|
||||
return getListeners(WindowStateListener.class);
|
||||
}
|
||||
|
||||
|
||||
@ -2014,7 +2015,6 @@ public class Window extends Container implements Accessible {
|
||||
break;
|
||||
case WindowEvent.WINDOW_STATE_CHANGED:
|
||||
processWindowStateEvent((WindowEvent)e);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
@ -2382,12 +2382,14 @@ public class Window extends Container implements Accessible {
|
||||
* KeyboardFocusManager.DOWN_CYCLE_TRAVERSAL_KEYS
|
||||
* @since 1.4
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set<AWTKeyStroke> getFocusTraversalKeys(int id) {
|
||||
if (id < 0 || id >= KeyboardFocusManager.TRAVERSAL_KEY_LENGTH) {
|
||||
throw new IllegalArgumentException("invalid focus traversal key identifier");
|
||||
}
|
||||
|
||||
// Okay to return Set directly because it is an unmodifiable view
|
||||
@SuppressWarnings("rawtypes")
|
||||
Set keystrokes = (focusTraversalKeys != null)
|
||||
? focusTraversalKeys[id]
|
||||
: null;
|
||||
@ -2765,7 +2767,7 @@ public class Window extends Container implements Accessible {
|
||||
/*
|
||||
* Support for tracking all windows owned by this window
|
||||
*/
|
||||
void addOwnedWindow(WeakReference weakWindow) {
|
||||
void addOwnedWindow(WeakReference<Window> weakWindow) {
|
||||
if (weakWindow != null) {
|
||||
synchronized(ownedWindowList) {
|
||||
// this if statement should really be an assert, but we don't
|
||||
@ -2777,7 +2779,7 @@ public class Window extends Container implements Accessible {
|
||||
}
|
||||
}
|
||||
|
||||
void removeOwnedWindow(WeakReference weakWindow) {
|
||||
void removeOwnedWindow(WeakReference<Window> weakWindow) {
|
||||
if (weakWindow != null) {
|
||||
// synchronized block not required since removeElement is
|
||||
// already synchronized
|
||||
@ -2792,6 +2794,7 @@ public class Window extends Container implements Accessible {
|
||||
|
||||
private void addToWindowList() {
|
||||
synchronized (Window.class) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)appContext.get(Window.class);
|
||||
if (windowList == null) {
|
||||
windowList = new Vector<WeakReference<Window>>();
|
||||
@ -2801,8 +2804,9 @@ public class Window extends Container implements Accessible {
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeFromWindowList(AppContext context, WeakReference weakThis) {
|
||||
private static void removeFromWindowList(AppContext context, WeakReference<Window> weakThis) {
|
||||
synchronized (Window.class) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>)context.get(Window.class);
|
||||
if (windowList != null) {
|
||||
windowList.remove(weakThis);
|
||||
@ -2945,7 +2949,7 @@ public class Window extends Container implements Accessible {
|
||||
// Deserialized Windows are not yet visible.
|
||||
visible = false;
|
||||
|
||||
weakThis = new WeakReference(this);
|
||||
weakThis = new WeakReference<>(this);
|
||||
|
||||
anchor = new Object();
|
||||
sun.java2d.Disposer.addRecord(anchor, new WindowDisposerRecord(appContext, this));
|
||||
@ -2956,7 +2960,7 @@ public class Window extends Container implements Accessible {
|
||||
|
||||
private void deserializeResources(ObjectInputStream s)
|
||||
throws ClassNotFoundException, IOException, HeadlessException {
|
||||
ownedWindowList = new Vector();
|
||||
ownedWindowList = new Vector<>();
|
||||
|
||||
if (windowSerializedDataVersion < 2) {
|
||||
// Translate old-style focus tracking to new model. For 1.4 and
|
||||
|
||||
@ -88,7 +88,7 @@ public abstract class SurfaceManager {
|
||||
imgaccessor.setSurfaceManager(img, mgr);
|
||||
}
|
||||
|
||||
private ConcurrentHashMap cacheMap;
|
||||
private ConcurrentHashMap<Object,Object> cacheMap;
|
||||
|
||||
/**
|
||||
* Return an arbitrary cached object for an arbitrary cache key.
|
||||
@ -123,7 +123,7 @@ public abstract class SurfaceManager {
|
||||
if (cacheMap == null) {
|
||||
synchronized (this) {
|
||||
if (cacheMap == null) {
|
||||
cacheMap = new ConcurrentHashMap(2);
|
||||
cacheMap = new ConcurrentHashMap<>(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -245,7 +245,7 @@ public abstract class SurfaceManager {
|
||||
|
||||
synchronized void flush(boolean deaccelerate) {
|
||||
if (cacheMap != null) {
|
||||
Iterator i = cacheMap.values().iterator();
|
||||
Iterator<Object> i = cacheMap.values().iterator();
|
||||
while (i.hasNext()) {
|
||||
Object o = i.next();
|
||||
if (o instanceof FlushableCacheData) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user