提交 05c45bb5 编写于 作者: B bagiras

7117334: Warnings cleanup day: reduce number of javac warnings in the java.awt package

Reviewed-by: art, denis, alexsch
上级 5295a14d
...@@ -278,9 +278,9 @@ public abstract class AWTEvent extends EventObject { ...@@ -278,9 +278,9 @@ public abstract class AWTEvent extends EventObject {
private static synchronized Field get_InputEvent_CanAccessSystemClipboard() { private static synchronized Field get_InputEvent_CanAccessSystemClipboard() {
if (inputEvent_CanAccessSystemClipboard_Field == null) { if (inputEvent_CanAccessSystemClipboard_Field == null) {
inputEvent_CanAccessSystemClipboard_Field = inputEvent_CanAccessSystemClipboard_Field =
(Field)java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Field>() {
public Object run() { public Field run() {
Field field = null; Field field = null;
try { try {
field = InputEvent.class. field = InputEvent.class.
......
...@@ -953,7 +953,7 @@ public class AWTEventMulticaster implements ...@@ -953,7 +953,7 @@ public class AWTEventMulticaster implements
* AWTEventMulticaster. Additionally, only listeners of type listenerType * AWTEventMulticaster. Additionally, only listeners of type listenerType
* are counted. Method modified to fix bug 4513402. -bchristi * are counted. Method modified to fix bug 4513402. -bchristi
*/ */
private static int getListenerCount(EventListener l, Class listenerType) { private static int getListenerCount(EventListener l, Class<?> listenerType) {
if (l instanceof AWTEventMulticaster) { if (l instanceof AWTEventMulticaster) {
AWTEventMulticaster mc = (AWTEventMulticaster)l; AWTEventMulticaster mc = (AWTEventMulticaster)l;
return getListenerCount(mc.a, listenerType) + return getListenerCount(mc.a, listenerType) +
...@@ -1017,6 +1017,7 @@ public class AWTEventMulticaster implements ...@@ -1017,6 +1017,7 @@ public class AWTEventMulticaster implements
* *
* @since 1.4 * @since 1.4
*/ */
@SuppressWarnings("unchecked")
public static <T extends EventListener> T[] public static <T extends EventListener> T[]
getListeners(EventListener l, Class<T> listenerType) getListeners(EventListener l, Class<T> listenerType)
{ {
......
...@@ -382,7 +382,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -382,7 +382,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @serial * @serial
* @see #add * @see #add
*/ */
Vector popups; Vector<PopupMenu> popups;
/** /**
* A component's name. * A component's name.
...@@ -441,7 +441,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -441,7 +441,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @see #getFocusTraversalKeys * @see #getFocusTraversalKeys
* @since 1.4 * @since 1.4
*/ */
Set[] focusTraversalKeys; Set<AWTKeyStroke>[] focusTraversalKeys;
private static final String[] focusTraversalKeyPropertyNames = { private static final String[] focusTraversalKeyPropertyNames = {
"forwardFocusTraversalKeys", "forwardFocusTraversalKeys",
...@@ -598,11 +598,11 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -598,11 +598,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
initIDs(); initIDs();
} }
String s = (String) java.security.AccessController.doPrivileged( String s = java.security.AccessController.doPrivileged(
new GetPropertyAction("awt.image.incrementaldraw")); new GetPropertyAction("awt.image.incrementaldraw"));
isInc = (s == null || s.equals("true")); isInc = (s == null || s.equals("true"));
s = (String) java.security.AccessController.doPrivileged( s = java.security.AccessController.doPrivileged(
new GetPropertyAction("awt.image.redrawrate")); new GetPropertyAction("awt.image.redrawrate"));
incRate = (s != null) ? Integer.parseInt(s) : 100; incRate = (s != null) ? Integer.parseInt(s) : 100;
} }
...@@ -986,6 +986,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -986,6 +986,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
appContext = AppContext.getAppContext(); appContext = AppContext.getAppContext();
} }
@SuppressWarnings({"rawtypes", "unchecked"})
void initializeFocusTraversalKeys() { void initializeFocusTraversalKeys() {
focusTraversalKeys = new Set[3]; focusTraversalKeys = new Set[3];
} }
...@@ -1369,9 +1370,9 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -1369,9 +1370,9 @@ public abstract class Component implements ImageObserver, MenuContainer,
throw new HeadlessException(); throw new HeadlessException();
} }
PointerInfo pi = (PointerInfo)java.security.AccessController.doPrivileged( PointerInfo pi = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<PointerInfo>() {
public Object run() { public PointerInfo run() {
return MouseInfo.getPointerInfo(); return MouseInfo.getPointerInfo();
} }
} }
...@@ -2334,7 +2335,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -2334,7 +2335,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
peer.setBounds(nativeX, nativeY, width, height, op); peer.setBounds(nativeX, nativeY, width, height, op);
} }
@SuppressWarnings("deprecation")
private void notifyNewBounds(boolean resized, boolean moved) { private void notifyNewBounds(boolean resized, boolean moved) {
if (componentListener != null if (componentListener != null
|| (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0
...@@ -4690,6 +4691,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -4690,6 +4691,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
dispatchEventImpl(e); dispatchEventImpl(e);
} }
@SuppressWarnings("deprecation")
void dispatchEventImpl(AWTEvent e) { void dispatchEventImpl(AWTEvent e) {
int id = e.getID(); int id = e.getID();
...@@ -5242,7 +5244,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -5242,7 +5244,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @since 1.4 * @since 1.4
*/ */
public synchronized ComponentListener[] getComponentListeners() { public synchronized ComponentListener[] getComponentListeners() {
return (ComponentListener[]) (getListeners(ComponentListener.class)); return getListeners(ComponentListener.class);
} }
/** /**
...@@ -5311,7 +5313,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -5311,7 +5313,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @since 1.4 * @since 1.4
*/ */
public synchronized FocusListener[] getFocusListeners() { public synchronized FocusListener[] getFocusListeners() {
return (FocusListener[]) (getListeners(FocusListener.class)); return getListeners(FocusListener.class);
} }
/** /**
...@@ -5402,7 +5404,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -5402,7 +5404,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @since 1.4 * @since 1.4
*/ */
public synchronized HierarchyListener[] getHierarchyListeners() { public synchronized HierarchyListener[] getHierarchyListeners() {
return (HierarchyListener[])(getListeners(HierarchyListener.class)); return getListeners(HierarchyListener.class);
} }
/** /**
...@@ -5564,8 +5566,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -5564,8 +5566,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @since 1.4 * @since 1.4
*/ */
public synchronized HierarchyBoundsListener[] getHierarchyBoundsListeners() { public synchronized HierarchyBoundsListener[] getHierarchyBoundsListeners() {
return (HierarchyBoundsListener[]) return getListeners(HierarchyBoundsListener.class);
(getListeners(HierarchyBoundsListener.class));
} }
/* /*
...@@ -5644,7 +5645,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -5644,7 +5645,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @since 1.4 * @since 1.4
*/ */
public synchronized KeyListener[] getKeyListeners() { public synchronized KeyListener[] getKeyListeners() {
return (KeyListener[]) (getListeners(KeyListener.class)); return getListeners(KeyListener.class);
} }
/** /**
...@@ -5713,7 +5714,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -5713,7 +5714,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @since 1.4 * @since 1.4
*/ */
public synchronized MouseListener[] getMouseListeners() { public synchronized MouseListener[] getMouseListeners() {
return (MouseListener[]) (getListeners(MouseListener.class)); return getListeners(MouseListener.class);
} }
/** /**
...@@ -5782,7 +5783,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -5782,7 +5783,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @since 1.4 * @since 1.4
*/ */
public synchronized MouseMotionListener[] getMouseMotionListeners() { public synchronized MouseMotionListener[] getMouseMotionListeners() {
return (MouseMotionListener[]) (getListeners(MouseMotionListener.class)); return getListeners(MouseMotionListener.class);
} }
/** /**
...@@ -5855,7 +5856,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -5855,7 +5856,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @since 1.4 * @since 1.4
*/ */
public synchronized MouseWheelListener[] getMouseWheelListeners() { public synchronized MouseWheelListener[] getMouseWheelListeners() {
return (MouseWheelListener[]) (getListeners(MouseWheelListener.class)); return getListeners(MouseWheelListener.class);
} }
/** /**
...@@ -5922,7 +5923,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -5922,7 +5923,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @since 1.4 * @since 1.4
*/ */
public synchronized InputMethodListener[] getInputMethodListeners() { public synchronized InputMethodListener[] getInputMethodListeners() {
return (InputMethodListener[]) (getListeners(InputMethodListener.class)); return getListeners(InputMethodListener.class);
} }
/** /**
...@@ -5967,6 +5968,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -5967,6 +5968,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* *
* @since 1.3 * @since 1.3
*/ */
@SuppressWarnings("unchecked")
public <T extends EventListener> T[] getListeners(Class<T> listenerType) { public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
EventListener l = null; EventListener l = null;
if (listenerType == ComponentListener.class) { if (listenerType == ComponentListener.class) {
...@@ -6909,7 +6911,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -6909,7 +6911,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
int npopups = (popups != null? popups.size() : 0); int npopups = (popups != null? popups.size() : 0);
for (int i = 0 ; i < npopups ; i++) { for (int i = 0 ; i < npopups ; i++) {
PopupMenu popup = (PopupMenu)popups.elementAt(i); PopupMenu popup = popups.elementAt(i);
popup.addNotify(); popup.addNotify();
} }
...@@ -6979,7 +6981,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -6979,7 +6981,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
int npopups = (popups != null? popups.size() : 0); int npopups = (popups != null? popups.size() : 0);
for (int i = 0 ; i < npopups ; i++) { for (int i = 0 ; i < npopups ; i++) {
PopupMenu popup = (PopupMenu)popups.elementAt(i); PopupMenu popup = popups.elementAt(i);
popup.removeNotify(); popup.removeNotify();
} }
// If there is any input context for this component, notify // If there is any input context for this component, notify
...@@ -7238,7 +7240,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -7238,7 +7240,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
// would erroneously generate an IllegalArgumentException for // would erroneously generate an IllegalArgumentException for
// DOWN_CYCLE_TRAVERSAL_KEY. // DOWN_CYCLE_TRAVERSAL_KEY.
final void setFocusTraversalKeys_NoIDCheck(int id, Set<? extends AWTKeyStroke> keystrokes) { final void setFocusTraversalKeys_NoIDCheck(int id, Set<? extends AWTKeyStroke> keystrokes) {
Set oldKeys; Set<AWTKeyStroke> oldKeys;
synchronized (this) { synchronized (this) {
if (focusTraversalKeys == null) { if (focusTraversalKeys == null) {
...@@ -7246,20 +7248,12 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -7246,20 +7248,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
} }
if (keystrokes != null) { if (keystrokes != null) {
for (Iterator iter = keystrokes.iterator(); iter.hasNext(); ) { for (AWTKeyStroke keystroke : keystrokes ) {
Object obj = iter.next();
if (obj == null) { if (keystroke == null) {
throw new IllegalArgumentException("cannot set null focus traversal key"); throw new IllegalArgumentException("cannot set null focus traversal key");
} }
// Fix for 6195828:
//According to javadoc this method should throw IAE instead of ClassCastException
if (!(obj instanceof AWTKeyStroke)) {
throw new IllegalArgumentException("object is expected to be AWTKeyStroke");
}
AWTKeyStroke keystroke = (AWTKeyStroke)obj;
if (keystroke.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { if (keystroke.getKeyChar() != KeyEvent.CHAR_UNDEFINED) {
throw new IllegalArgumentException("focus traversal keys cannot map to KEY_TYPED events"); throw new IllegalArgumentException("focus traversal keys cannot map to KEY_TYPED events");
} }
...@@ -7279,16 +7273,16 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -7279,16 +7273,16 @@ public abstract class Component implements ImageObserver, MenuContainer,
oldKeys = focusTraversalKeys[id]; oldKeys = focusTraversalKeys[id];
focusTraversalKeys[id] = (keystrokes != null) focusTraversalKeys[id] = (keystrokes != null)
? Collections.unmodifiableSet(new HashSet(keystrokes)) ? Collections.unmodifiableSet(new HashSet<AWTKeyStroke>(keystrokes))
: null; : null;
} }
firePropertyChange(focusTraversalKeyPropertyNames[id], oldKeys, firePropertyChange(focusTraversalKeyPropertyNames[id], oldKeys,
keystrokes); keystrokes);
} }
final Set getFocusTraversalKeys_NoIDCheck(int id) { final Set<AWTKeyStroke> getFocusTraversalKeys_NoIDCheck(int id) {
// Okay to return Set directly because it is an unmodifiable view // Okay to return Set directly because it is an unmodifiable view
Set keystrokes = (focusTraversalKeys != null) Set<AWTKeyStroke> keystrokes = (focusTraversalKeys != null)
? focusTraversalKeys[id] ? focusTraversalKeys[id]
: null; : null;
...@@ -7686,7 +7680,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -7686,7 +7680,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
} }
Window window = getContainingWindow(); Window window = getContainingWindow();
if (window == null || !((Window)window).isFocusableWindow()) { if (window == null || !window.isFocusableWindow()) {
if (focusLog.isLoggable(PlatformLogger.FINEST)) { if (focusLog.isLoggable(PlatformLogger.FINEST)) {
focusLog.finest("Component doesn't have toplevel"); focusLog.finest("Component doesn't have toplevel");
} }
...@@ -8025,7 +8019,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -8025,7 +8019,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
popup.parent.remove(popup); popup.parent.remove(popup);
} }
if (popups == null) { if (popups == null) {
popups = new Vector(); popups = new Vector<PopupMenu>();
} }
popups.addElement(popup); popups.addElement(popup);
popup.parent = this; popup.parent = this;
...@@ -8044,6 +8038,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -8044,6 +8038,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
* @see #add(PopupMenu) * @see #add(PopupMenu)
* @since JDK1.1 * @since JDK1.1
*/ */
@SuppressWarnings("unchecked")
public void remove(MenuComponent popup) { public void remove(MenuComponent popup) {
synchronized (getTreeLock()) { synchronized (getTreeLock()) {
if (popups == null) { if (popups == null) {
...@@ -8556,15 +8551,15 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -8556,15 +8551,15 @@ public abstract class Component implements ImageObserver, MenuContainer,
// //
// Swing classes MUST be loaded by the bootstrap class loader, // Swing classes MUST be loaded by the bootstrap class loader,
// otherwise we don't consider them. // otherwise we don't consider them.
for (Class klass = Component.this.getClass(); klass != null; for (Class<?> klass = Component.this.getClass(); klass != null;
klass = klass.getSuperclass()) { klass = klass.getSuperclass()) {
if (klass.getPackage() == swingPackage && if (klass.getPackage() == swingPackage &&
klass.getClassLoader() == null) { klass.getClassLoader() == null) {
final Class swingClass = klass; final Class<?> swingClass = klass;
// Find the first override of the compWriteObjectNotify method // Find the first override of the compWriteObjectNotify method
Method[] methods = (Method[])AccessController.doPrivileged( Method[] methods = AccessController.doPrivileged(
new PrivilegedAction() { new PrivilegedAction<Method[]>() {
public Object run() { public Method[] run() {
return swingClass.getDeclaredMethods(); return swingClass.getDeclaredMethods();
} }
}); });
...@@ -8574,8 +8569,8 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -8574,8 +8569,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (method.getName().equals("compWriteObjectNotify")){ if (method.getName().equals("compWriteObjectNotify")){
// We found it, use doPrivileged to make it accessible // We found it, use doPrivileged to make it accessible
// to use. // to use.
AccessController.doPrivileged(new PrivilegedAction() { AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Object run() { public Void run() {
method.setAccessible(true); method.setAccessible(true);
return null; return null;
} }
...@@ -8804,7 +8799,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -8804,7 +8799,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (popups != null) { if (popups != null) {
int npopups = popups.size(); int npopups = popups.size();
for (int i = 0 ; i < npopups ; i++) { for (int i = 0 ; i < npopups ; i++) {
PopupMenu popup = (PopupMenu)popups.elementAt(i); PopupMenu popup = popups.elementAt(i);
popup.parent = this; popup.parent = this;
} }
} }
...@@ -9658,7 +9653,7 @@ public abstract class Component implements ImageObserver, MenuContainer, ...@@ -9658,7 +9653,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (obj == null) return false; if (obj == null) return false;
if (className == null) return false; if (className == null) return false;
Class cls = obj.getClass(); Class<?> cls = obj.getClass();
while (cls != null) { while (cls != null) {
if (cls.getName().equals(className)) { if (cls.getName().equals(className)) {
return true; return true;
......
...@@ -254,7 +254,7 @@ public class Font implements java.io.Serializable ...@@ -254,7 +254,7 @@ public class Font implements java.io.Serializable
* @serial * @serial
* @see #getAttributes() * @see #getAttributes()
*/ */
private Hashtable fRequestedAttributes; private Hashtable<Object, Object> fRequestedAttributes;
/* /*
* Constants to be used for logical font family names. * Constants to be used for logical font family names.
...@@ -446,6 +446,7 @@ public class Font implements java.io.Serializable ...@@ -446,6 +446,7 @@ public class Font implements java.io.Serializable
// We implement this functionality in a package-private method // We implement this functionality in a package-private method
// to insure that it cannot be overridden by client subclasses. // to insure that it cannot be overridden by client subclasses.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD! // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
@SuppressWarnings("deprecation")
final FontPeer getPeer_NoClientCode() { final FontPeer getPeer_NoClientCode() {
if(peer == null) { if(peer == null) {
Toolkit tk = Toolkit.getDefaultToolkit(); Toolkit tk = Toolkit.getDefaultToolkit();
...@@ -907,11 +908,11 @@ public class Font implements java.io.Serializable ...@@ -907,11 +908,11 @@ public class Font implements java.io.Serializable
break; break;
} }
if (tracker != null) { if (tracker != null) {
if (totalSize+bytesRead > tracker.MAX_FILE_SIZE) { if (totalSize+bytesRead > CreatedFontTracker.MAX_FILE_SIZE) {
throw new IOException("File too big."); throw new IOException("File too big.");
} }
if (totalSize+tracker.getNumBytes() > if (totalSize+tracker.getNumBytes() >
tracker.MAX_TOTAL_BYTES) CreatedFontTracker.MAX_TOTAL_BYTES)
{ {
throw new IOException("Total files too big."); throw new IOException("Total files too big.");
} }
...@@ -2126,11 +2127,11 @@ public class Font implements java.io.Serializable ...@@ -2126,11 +2127,11 @@ public class Font implements java.io.Serializable
return false; // REMIND always safe, but prevents caller optimize return false; // REMIND always safe, but prevents caller optimize
} }
private transient SoftReference flmref; private transient SoftReference<FontLineMetrics> flmref;
private FontLineMetrics defaultLineMetrics(FontRenderContext frc) { private FontLineMetrics defaultLineMetrics(FontRenderContext frc) {
FontLineMetrics flm = null; FontLineMetrics flm = null;
if (flmref == null if (flmref == null
|| (flm = (FontLineMetrics)flmref.get()) == null || (flm = flmref.get()) == null
|| !flm.frc.equals(frc)) { || !flm.frc.equals(frc)) {
/* The device transform in the frc is not used in obtaining line /* The device transform in the frc is not used in obtaining line
...@@ -2194,7 +2195,7 @@ public class Font implements java.io.Serializable ...@@ -2194,7 +2195,7 @@ public class Font implements java.io.Serializable
ssOffset, italicAngle); ssOffset, italicAngle);
flm = new FontLineMetrics(0, cm, frc); flm = new FontLineMetrics(0, cm, frc);
flmref = new SoftReference(flm); flmref = new SoftReference<FontLineMetrics>(flm);
} }
return (FontLineMetrics)flm.clone(); return (FontLineMetrics)flm.clone();
......
...@@ -706,9 +706,9 @@ public abstract class Toolkit { ...@@ -706,9 +706,9 @@ public abstract class Toolkit {
final Properties properties = new Properties(); final Properties properties = new Properties();
atNames = (String)java.security.AccessController.doPrivileged( atNames = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<String>() {
public Object run() { public String run() {
// Try loading the per-user accessibility properties file. // Try loading the per-user accessibility properties file.
try { try {
...@@ -798,7 +798,7 @@ public abstract class Toolkit { ...@@ -798,7 +798,7 @@ public abstract class Toolkit {
while (parser.hasMoreTokens()) { while (parser.hasMoreTokens()) {
atName = parser.nextToken(); atName = parser.nextToken();
try { try {
Class clazz; Class<?> clazz;
if (cl != null) { if (cl != null) {
clazz = cl.loadClass(atName); clazz = cl.loadClass(atName);
} else { } else {
...@@ -860,8 +860,8 @@ public abstract class Toolkit { ...@@ -860,8 +860,8 @@ public abstract class Toolkit {
java.lang.Compiler.disable(); java.lang.Compiler.disable();
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Void>() {
public Object run() { public Void run() {
String nm = null; String nm = null;
Class cls = null; Class cls = null;
try { try {
...@@ -1653,8 +1653,8 @@ public abstract class Toolkit { ...@@ -1653,8 +1653,8 @@ public abstract class Toolkit {
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<Void>() {
public Object run() { public Void run() {
try { try {
resources = resources =
ResourceBundle.getBundle("sun.awt.resources.awt", ResourceBundle.getBundle("sun.awt.resources.awt",
...@@ -1984,7 +1984,7 @@ public abstract class Toolkit { ...@@ -1984,7 +1984,7 @@ public abstract class Toolkit {
private int[] calls = new int[LONG_BITS]; private int[] calls = new int[LONG_BITS];
private static volatile long enabledOnToolkitMask; private static volatile long enabledOnToolkitMask;
private AWTEventListener eventListener = null; private AWTEventListener eventListener = null;
private WeakHashMap listener2SelectiveListener = new WeakHashMap(); private WeakHashMap<AWTEventListener, SelectiveAWTEventListener> listener2SelectiveListener = new WeakHashMap<>();
/* /*
* Extracts a "pure" AWTEventListener from a AWTEventListenerProxy, * Extracts a "pure" AWTEventListener from a AWTEventListenerProxy,
...@@ -2051,7 +2051,7 @@ public abstract class Toolkit { ...@@ -2051,7 +2051,7 @@ public abstract class Toolkit {
} }
synchronized (this) { synchronized (this) {
SelectiveAWTEventListener selectiveListener = SelectiveAWTEventListener selectiveListener =
(SelectiveAWTEventListener)listener2SelectiveListener.get(localL); listener2SelectiveListener.get(localL);
if (selectiveListener == null) { if (selectiveListener == null) {
// Create a new selectiveListener. // Create a new selectiveListener.
...@@ -2121,7 +2121,7 @@ public abstract class Toolkit { ...@@ -2121,7 +2121,7 @@ public abstract class Toolkit {
synchronized (this) { synchronized (this) {
SelectiveAWTEventListener selectiveListener = SelectiveAWTEventListener selectiveListener =
(SelectiveAWTEventListener)listener2SelectiveListener.get(localL); listener2SelectiveListener.get(localL);
if (selectiveListener != null) { if (selectiveListener != null) {
listener2SelectiveListener.remove(localL); listener2SelectiveListener.remove(localL);
...@@ -2244,7 +2244,7 @@ public abstract class Toolkit { ...@@ -2244,7 +2244,7 @@ public abstract class Toolkit {
synchronized (this) { synchronized (this) {
EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class); EventListener[] la = ToolkitEventMulticaster.getListeners(eventListener,AWTEventListener.class);
java.util.List list = new ArrayList(la.length); java.util.List<AWTEventListenerProxy> list = new ArrayList<>(la.length);
for (int i = 0; i < la.length; i++) { for (int i = 0; i < la.length; i++) {
SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i]; SelectiveAWTEventListener sael = (SelectiveAWTEventListener)la[i];
...@@ -2254,7 +2254,7 @@ public abstract class Toolkit { ...@@ -2254,7 +2254,7 @@ public abstract class Toolkit {
sael.getListener())); sael.getListener()));
} }
} }
return (AWTEventListener[])list.toArray(new AWTEventListener[0]); return list.toArray(new AWTEventListener[0]);
} }
} }
...@@ -2457,7 +2457,9 @@ public abstract class Toolkit { ...@@ -2457,7 +2457,9 @@ public abstract class Toolkit {
} }
} }
@SuppressWarnings("serial")
private static class DesktopPropertyChangeSupport extends PropertyChangeSupport { private static class DesktopPropertyChangeSupport extends PropertyChangeSupport {
private static final StringBuilder PROP_CHANGE_SUPPORT_KEY = private static final StringBuilder PROP_CHANGE_SUPPORT_KEY =
new StringBuilder("desktop property change support key"); new StringBuilder("desktop property change support key");
private final Object source; private final Object source;
......
...@@ -357,7 +357,7 @@ public abstract class ColorModel implements Transparency{ ...@@ -357,7 +357,7 @@ public abstract class ColorModel implements Transparency{
this.transparency = transparency; this.transparency = transparency;
} }
nBits = (int[]) bits.clone(); nBits = bits.clone();
this.pixel_bits = pixel_bits; this.pixel_bits = pixel_bits;
if (pixel_bits <= 0) { if (pixel_bits <= 0) {
throw new IllegalArgumentException("Number of pixel bits must "+ throw new IllegalArgumentException("Number of pixel bits must "+
...@@ -474,7 +474,7 @@ public abstract class ColorModel implements Transparency{ ...@@ -474,7 +474,7 @@ public abstract class ColorModel implements Transparency{
*/ */
public int[] getComponentSize() { public int[] getComponentSize() {
if (nBits != null) { if (nBits != null) {
return (int[]) nBits.clone(); return nBits.clone();
} }
return null; return null;
...@@ -1692,10 +1692,10 @@ public abstract class ColorModel implements Transparency{ ...@@ -1692,10 +1692,10 @@ public abstract class ColorModel implements Transparency{
static short[] s8Tol16 = null; // 8-bit non-linear sRGB to 16-bit linear LUT static short[] s8Tol16 = null; // 8-bit non-linear sRGB to 16-bit linear LUT
// Maps to hold LUTs for grayscale conversions // Maps to hold LUTs for grayscale conversions
static Map g8Tos8Map = null; // 8-bit gray values to 8-bit sRGB values static Map<ICC_ColorSpace, byte[]> g8Tos8Map = null; // 8-bit gray values to 8-bit sRGB values
static Map lg16Toog8Map = null; // 16-bit linear to 8-bit "other" gray static Map<ICC_ColorSpace, byte[]> lg16Toog8Map = null; // 16-bit linear to 8-bit "other" gray
static Map g16Tos8Map = null; // 16-bit gray values to 8-bit sRGB values static Map<ICC_ColorSpace, byte[]> g16Tos8Map = null; // 16-bit gray values to 8-bit sRGB values
static Map lg16Toog16Map = null; // 16-bit linear to 16-bit "other" gray static Map<ICC_ColorSpace, short[]> lg16Toog16Map = null; // 16-bit linear to 16-bit "other" gray
static boolean isLinearRGBspace(ColorSpace cs) { static boolean isLinearRGBspace(ColorSpace cs) {
// Note: CMM.LINEAR_RGBspace will be null if the linear // Note: CMM.LINEAR_RGBspace will be null if the linear
...@@ -1799,7 +1799,7 @@ public abstract class ColorModel implements Transparency{ ...@@ -1799,7 +1799,7 @@ public abstract class ColorModel implements Transparency{
return getLinearRGB8TosRGB8LUT(); return getLinearRGB8TosRGB8LUT();
} }
if (g8Tos8Map != null) { if (g8Tos8Map != null) {
byte[] g8Tos8LUT = (byte []) g8Tos8Map.get(grayCS); byte[] g8Tos8LUT = g8Tos8Map.get(grayCS);
if (g8Tos8LUT != null) { if (g8Tos8LUT != null) {
return g8Tos8LUT; return g8Tos8LUT;
} }
...@@ -1827,7 +1827,7 @@ public abstract class ColorModel implements Transparency{ ...@@ -1827,7 +1827,7 @@ public abstract class ColorModel implements Transparency{
g8Tos8LUT[i] = tmp[j]; g8Tos8LUT[i] = tmp[j];
} }
if (g8Tos8Map == null) { if (g8Tos8Map == null) {
g8Tos8Map = Collections.synchronizedMap(new WeakHashMap(2)); g8Tos8Map = Collections.synchronizedMap(new WeakHashMap<ICC_ColorSpace, byte[]>(2));
} }
g8Tos8Map.put(grayCS, g8Tos8LUT); g8Tos8Map.put(grayCS, g8Tos8LUT);
return g8Tos8LUT; return g8Tos8LUT;
...@@ -1840,7 +1840,7 @@ public abstract class ColorModel implements Transparency{ ...@@ -1840,7 +1840,7 @@ public abstract class ColorModel implements Transparency{
*/ */
static byte[] getLinearGray16ToOtherGray8LUT(ICC_ColorSpace grayCS) { static byte[] getLinearGray16ToOtherGray8LUT(ICC_ColorSpace grayCS) {
if (lg16Toog8Map != null) { if (lg16Toog8Map != null) {
byte[] lg16Toog8LUT = (byte []) lg16Toog8Map.get(grayCS); byte[] lg16Toog8LUT = lg16Toog8Map.get(grayCS);
if (lg16Toog8LUT != null) { if (lg16Toog8LUT != null) {
return lg16Toog8LUT; return lg16Toog8LUT;
} }
...@@ -1866,7 +1866,7 @@ public abstract class ColorModel implements Transparency{ ...@@ -1866,7 +1866,7 @@ public abstract class ColorModel implements Transparency{
(byte) (((float) (tmp[i] & 0xffff)) * (1.0f /257.0f) + 0.5f); (byte) (((float) (tmp[i] & 0xffff)) * (1.0f /257.0f) + 0.5f);
} }
if (lg16Toog8Map == null) { if (lg16Toog8Map == null) {
lg16Toog8Map = Collections.synchronizedMap(new WeakHashMap(2)); lg16Toog8Map = Collections.synchronizedMap(new WeakHashMap<ICC_ColorSpace, byte[]>(2));
} }
lg16Toog8Map.put(grayCS, lg16Toog8LUT); lg16Toog8Map.put(grayCS, lg16Toog8LUT);
return lg16Toog8LUT; return lg16Toog8LUT;
...@@ -1884,7 +1884,7 @@ public abstract class ColorModel implements Transparency{ ...@@ -1884,7 +1884,7 @@ public abstract class ColorModel implements Transparency{
return getLinearRGB16TosRGB8LUT(); return getLinearRGB16TosRGB8LUT();
} }
if (g16Tos8Map != null) { if (g16Tos8Map != null) {
byte[] g16Tos8LUT = (byte []) g16Tos8Map.get(grayCS); byte[] g16Tos8LUT = g16Tos8Map.get(grayCS);
if (g16Tos8LUT != null) { if (g16Tos8LUT != null) {
return g16Tos8LUT; return g16Tos8LUT;
} }
...@@ -1916,7 +1916,7 @@ public abstract class ColorModel implements Transparency{ ...@@ -1916,7 +1916,7 @@ public abstract class ColorModel implements Transparency{
(byte) (((float) (tmp[j] & 0xffff)) * (1.0f /257.0f) + 0.5f); (byte) (((float) (tmp[j] & 0xffff)) * (1.0f /257.0f) + 0.5f);
} }
if (g16Tos8Map == null) { if (g16Tos8Map == null) {
g16Tos8Map = Collections.synchronizedMap(new WeakHashMap(2)); g16Tos8Map = Collections.synchronizedMap(new WeakHashMap<ICC_ColorSpace, byte[]>(2));
} }
g16Tos8Map.put(grayCS, g16Tos8LUT); g16Tos8Map.put(grayCS, g16Tos8LUT);
return g16Tos8LUT; return g16Tos8LUT;
...@@ -1929,7 +1929,7 @@ public abstract class ColorModel implements Transparency{ ...@@ -1929,7 +1929,7 @@ public abstract class ColorModel implements Transparency{
*/ */
static short[] getLinearGray16ToOtherGray16LUT(ICC_ColorSpace grayCS) { static short[] getLinearGray16ToOtherGray16LUT(ICC_ColorSpace grayCS) {
if (lg16Toog16Map != null) { if (lg16Toog16Map != null) {
short[] lg16Toog16LUT = (short []) lg16Toog16Map.get(grayCS); short[] lg16Toog16LUT = lg16Toog16Map.get(grayCS);
if (lg16Toog16LUT != null) { if (lg16Toog16LUT != null) {
return lg16Toog16LUT; return lg16Toog16LUT;
} }
...@@ -1950,7 +1950,7 @@ public abstract class ColorModel implements Transparency{ ...@@ -1950,7 +1950,7 @@ public abstract class ColorModel implements Transparency{
transformList); transformList);
short[] lg16Toog16LUT = t.colorConvert(tmp, null); short[] lg16Toog16LUT = t.colorConvert(tmp, null);
if (lg16Toog16Map == null) { if (lg16Toog16Map == null) {
lg16Toog16Map = Collections.synchronizedMap(new WeakHashMap(2)); lg16Toog16Map = Collections.synchronizedMap(new WeakHashMap<ICC_ColorSpace, short[]>(2));
} }
lg16Toog16Map.put(grayCS, lg16Toog16LUT); lg16Toog16Map.put(grayCS, lg16Toog16LUT);
return lg16Toog16LUT; return lg16Toog16LUT;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册