--- a/jdk/src/share/classes/java/awt/CheckboxMenuItem.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/CheckboxMenuItem.java Wed Mar 06 20:10:04 2013 +0400
@@ -277,7 +277,7 @@
* @since 1.4
*/
public synchronized ItemListener[] getItemListeners() {
- return (ItemListener[])(getListeners(ItemListener.class));
+ return getListeners(ItemListener.class);
}
/**
--- a/jdk/src/share/classes/java/awt/Cursor.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/Cursor.java Wed Mar 06 20:10:04 2013 +0400
@@ -163,11 +163,11 @@
* hashtable, filesystem dir prefix, filename, and properties for custom cursors support
*/
- private static final Hashtable systemCustomCursors = new Hashtable(1);
+ private static final Hashtable<String,Cursor> systemCustomCursors = new Hashtable<>(1);
private static final String systemCustomCursorDirPrefix = initCursorDir();
private static String initCursorDir() {
- String jhome = (String) java.security.AccessController.doPrivileged(
+ String jhome = java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("java.home"));
return jhome +
File.separator + "lib" + File.separator + "images" +
@@ -298,7 +298,7 @@
static public Cursor getSystemCustomCursor(final String name)
throws AWTException, HeadlessException {
GraphicsEnvironment.checkHeadless();
- Cursor cursor = (Cursor)systemCustomCursors.get(name);
+ Cursor cursor = systemCustomCursors.get(name);
if (cursor == null) {
synchronized(systemCustomCursors) {
@@ -319,11 +319,11 @@
final String fileName =
systemCustomCursorProperties.getProperty(key);
- String localized = (String)systemCustomCursorProperties.getProperty(prefix + DotNameSuffix);
+ String localized = systemCustomCursorProperties.getProperty(prefix + DotNameSuffix);
if (localized == null) localized = name;
- String hotspot = (String)systemCustomCursorProperties.getProperty(prefix + DotHotspotSuffix);
+ String hotspot = systemCustomCursorProperties.getProperty(prefix + DotHotspotSuffix);
if (hotspot == null)
throw new AWTException("no hotspot property defined for cursor: " + name);
@@ -348,9 +348,9 @@
final int fy = y;
final String flocalized = localized;
- cursor = (Cursor) java.security.AccessController.doPrivileged(
- new java.security.PrivilegedExceptionAction() {
- public Object run() throws Exception {
+ cursor = java.security.AccessController.<Cursor>doPrivileged(
+ new java.security.PrivilegedExceptionAction<Cursor>() {
+ public Cursor run() throws Exception {
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image = toolkit.getImage(
systemCustomCursorDirPrefix + fileName);
@@ -447,8 +447,8 @@
systemCustomCursorProperties = new Properties();
try {
- AccessController.doPrivileged(
- new java.security.PrivilegedExceptionAction() {
+ AccessController.<Object>doPrivileged(
+ new java.security.PrivilegedExceptionAction<Object>() {
public Object run() throws Exception {
FileInputStream fis = null;
try {
--- a/jdk/src/share/classes/java/awt/EventQueue.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/EventQueue.java Wed Mar 06 20:10:04 2013 +0400
@@ -171,7 +171,7 @@
* The modifiers field of the current event, if the current event is an
* InputEvent or ActionEvent.
*/
- private WeakReference currentEvent;
+ private WeakReference<AWTEvent> currentEvent;
/*
* Non-zero if a thread is waiting in getNextEvent(int) for an event of
@@ -809,7 +809,7 @@
pushPopLock.lock();
try {
return (Thread.currentThread() == dispatchThread)
- ? ((AWTEvent)currentEvent.get())
+ ? currentEvent.get()
: null;
} finally {
pushPopLock.unlock();
@@ -1167,7 +1167,7 @@
return;
}
- currentEvent = new WeakReference(e);
+ currentEvent = new WeakReference<>(e);
// This series of 'instanceof' checks should be replaced with a
// polymorphic type (for example, an interface which declares a
--- a/jdk/src/share/classes/java/awt/Menu.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/Menu.java Wed Mar 06 20:10:04 2013 +0400
@@ -66,7 +66,7 @@
AWTAccessor.setMenuAccessor(
new AWTAccessor.MenuAccessor() {
- public Vector getItems(Menu menu) {
+ public Vector<MenuComponent> getItems(Menu menu) {
return menu.items;
}
});
@@ -78,7 +78,7 @@
* @serial
* @see #countItems()
*/
- Vector items = new Vector();
+ Vector<MenuComponent> items = new Vector<>();
/**
* This field indicates whether the menu has the
@@ -313,7 +313,7 @@
}
int nitems = getItemCount();
- Vector tempItems = new Vector();
+ Vector<MenuItem> tempItems = new Vector<>();
/* Remove the item at index, nitems-index times
storing them in a temporary vector in the
@@ -330,7 +330,7 @@
already in the correct order in the temp vector.
*/
for (int i = 0; i < tempItems.size() ; i++) {
- add((MenuItem)tempItems.elementAt(i));
+ add(tempItems.elementAt(i));
}
}
}
@@ -379,7 +379,7 @@
}
int nitems = getItemCount();
- Vector tempItems = new Vector();
+ Vector<MenuItem> tempItems = new Vector<>();
/* Remove the item at index, nitems-index times
storing them in a temporary vector in the
@@ -396,7 +396,7 @@
already in the correct order in the temp vector.
*/
for (int i = 0; i < tempItems.size() ; i++) {
- add((MenuItem)tempItems.elementAt(i));
+ add(tempItems.elementAt(i));
}
}
}
@@ -475,13 +475,13 @@
return null;
}
- synchronized Enumeration shortcuts() {
- Vector shortcuts = new Vector();
+ synchronized Enumeration<MenuShortcut> shortcuts() {
+ Vector<MenuShortcut> shortcuts = new Vector<>();
int nitems = getItemCount();
for (int i = 0 ; i < nitems ; i++) {
MenuItem mi = getItem(i);
if (mi instanceof Menu) {
- Enumeration e = ((Menu)mi).shortcuts();
+ Enumeration<MenuShortcut> e = ((Menu)mi).shortcuts();
while (e.hasMoreElements()) {
shortcuts.addElement(e.nextElement());
}
--- a/jdk/src/share/classes/java/awt/MenuBar.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/MenuBar.java Wed Mar 06 20:10:04 2013 +0400
@@ -81,7 +81,7 @@
return menuBar.helpMenu;
}
- public Vector getMenus(MenuBar menuBar) {
+ public Vector<Menu> getMenus(MenuBar menuBar) {
return menuBar.menus;
}
});
@@ -94,7 +94,7 @@
* @serial
* @see #countMenus()
*/
- Vector menus = new Vector();
+ Vector<Menu> menus = new Vector<>();
/**
* This menu is a special menu dedicated to
@@ -309,7 +309,7 @@
* be called on the toolkit thread.
*/
final Menu getMenuImpl(int i) {
- return (Menu)menus.elementAt(i);
+ return menus.elementAt(i);
}
/**
@@ -321,10 +321,10 @@
* @since JDK1.1
*/
public synchronized Enumeration<MenuShortcut> shortcuts() {
- Vector shortcuts = new Vector();
+ Vector<MenuShortcut> shortcuts = new Vector<>();
int nmenus = getMenuCount();
for (int i = 0 ; i < nmenus ; i++) {
- Enumeration e = getMenu(i).shortcuts();
+ Enumeration<MenuShortcut> e = getMenu(i).shortcuts();
while (e.hasMoreElements()) {
shortcuts.addElement(e.nextElement());
}
@@ -438,7 +438,7 @@
// HeadlessException will be thrown from MenuComponent's readObject
s.defaultReadObject();
for (int i = 0; i < menus.size(); i++) {
- Menu m = (Menu)menus.elementAt(i);
+ Menu m = menus.elementAt(i);
m.parent = this;
}
}
--- a/jdk/src/share/classes/java/awt/MenuComponent.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/MenuComponent.java Wed Mar 06 20:10:04 2013 +0400
@@ -290,7 +290,7 @@
public void setFont(Font f) {
font = f;
//Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
- MenuComponentPeer peer = (MenuComponentPeer)this.peer;
+ MenuComponentPeer peer = this.peer;
if (peer != null) {
peer.setFont(f);
}
@@ -303,7 +303,7 @@
*/
public void removeNotify() {
synchronized (getTreeLock()) {
- MenuComponentPeer p = (MenuComponentPeer)this.peer;
+ MenuComponentPeer p = this.peer;
if (p != null) {
Toolkit.getEventQueue().removeSourceEvents(this, true);
this.peer = null;
--- a/jdk/src/share/classes/java/awt/MenuItem.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/MenuItem.java Wed Mar 06 20:10:04 2013 +0400
@@ -564,7 +564,7 @@
* @since 1.4
*/
public synchronized ActionListener[] getActionListeners() {
- return (ActionListener[])(getListeners(ActionListener.class));
+ return getListeners(ActionListener.class);
}
/**
--- a/jdk/src/share/classes/java/awt/RenderingHints.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/RenderingHints.java Wed Mar 06 20:10:04 2013 +0400
@@ -92,7 +92,7 @@
* {@code equals()} method.
*/
public abstract static class Key {
- private static HashMap identitymap = new HashMap(17);
+ private static HashMap<Object,Object> identitymap = new HashMap<>(17);
private String getIdentity() {
// Note that the identity string is dependent on 3 variables:
@@ -138,7 +138,7 @@
}
// Note: Use a weak reference to avoid holding on to extra
// objects and classes after they should be unloaded.
- identitymap.put(identity, new WeakReference(k));
+ identitymap.put(identity, new WeakReference<Key>(k));
}
private int privatekey;
@@ -195,7 +195,7 @@
}
}
- HashMap hintmap = new HashMap(7);
+ HashMap<Object,Object> hintmap = new HashMap<>(7);
/**
* Antialiasing hint key.
@@ -1267,12 +1267,13 @@
* object.
* @return a clone of this instance.
*/
+ @SuppressWarnings("unchecked")
public Object clone() {
RenderingHints rh;
try {
rh = (RenderingHints) super.clone();
if (hintmap != null) {
- rh.hintmap = (HashMap) hintmap.clone();
+ rh.hintmap = (HashMap<Object,Object>) hintmap.clone();
}
} catch (CloneNotSupportedException e) {
// this shouldn't happen, since we are Cloneable
--- a/jdk/src/share/classes/java/awt/datatransfer/Clipboard.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/datatransfer/Clipboard.java Wed Mar 06 20:10:04 2013 +0400
@@ -71,7 +71,7 @@
*
* @since 1.5
*/
- private Set currentDataFlavors;
+ private Set<DataFlavor> currentDataFlavors;
/**
* Creates a clipboard object.
@@ -313,7 +313,7 @@
if (flavorListeners == null) {
return;
}
- Set prevDataFlavors = currentDataFlavors;
+ Set<DataFlavor> prevDataFlavors = currentDataFlavors;
currentDataFlavors = getAvailableDataFlavorSet();
if (prevDataFlavors.equals(currentDataFlavors)) {
return;
@@ -339,8 +339,8 @@
*
* @since 1.5
*/
- private Set getAvailableDataFlavorSet() {
- Set set = new HashSet();
+ private Set<DataFlavor> getAvailableDataFlavorSet() {
+ Set<DataFlavor> set = new HashSet<>();
Transferable contents = getContents(null);
if (contents != null) {
DataFlavor[] flavors = contents.getTransferDataFlavors();
--- a/jdk/src/share/classes/java/awt/dnd/DragGestureEvent.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/dnd/DragGestureEvent.java Wed Mar 06 20:10:04 2013 +0400
@@ -165,7 +165,7 @@
* <P>
* @return an Iterator for the events comprising the gesture
*/
-
+ @SuppressWarnings("unchecked")
public Iterator<InputEvent> iterator() { return events.iterator(); }
/**
@@ -184,7 +184,7 @@
* <P>
* @return an array of the events comprising the gesture
*/
-
+ @SuppressWarnings("unchecked")
public Object[] toArray(Object[] array) { return events.toArray(array); }
/**
@@ -333,7 +333,6 @@
component = (Component)f.get("component", null);
origin = (Point)f.get("origin", null);
action = f.get("action", 0);
-
// Pre-1.4 support. 'events' was previously non-transient
try {
events = (List)f.get("events", null);
@@ -351,7 +350,7 @@
/*
* fields
*/
-
+ @SuppressWarnings("rawtypes")
private transient List events;
/**
--- a/jdk/src/share/classes/java/awt/dnd/DragGestureRecognizer.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/dnd/DragGestureRecognizer.java Wed Mar 06 20:10:04 2013 +0400
@@ -297,7 +297,7 @@
* @return the initial event that triggered the drag gesture
*/
- public InputEvent getTriggerEvent() { return events.isEmpty() ? null : (InputEvent)events.get(0); }
+ public InputEvent getTriggerEvent() { return events.isEmpty() ? null : events.get(0); }
/**
* Reset the Recognizer, if its currently recognizing a gesture, ignore
--- a/jdk/src/share/classes/java/awt/dnd/DragSource.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/dnd/DragSource.java Wed Mar 06 20:10:04 2013 +0400
@@ -600,7 +600,7 @@
* @since 1.4
*/
public DragSourceListener[] getDragSourceListeners() {
- return (DragSourceListener[])getListeners(DragSourceListener.class);
+ return getListeners(DragSourceListener.class);
}
/**
@@ -660,8 +660,7 @@
* @since 1.4
*/
public DragSourceMotionListener[] getDragSourceMotionListeners() {
- return (DragSourceMotionListener[])
- getListeners(DragSourceMotionListener.class);
+ return getListeners(DragSourceMotionListener.class);
}
/**
@@ -896,8 +895,8 @@
* @since 1.5
*/
public static int getDragThreshold() {
- int ts = ((Integer)AccessController.doPrivileged(
- new GetIntegerAction("awt.dnd.drag.threshold", 0))).intValue();
+ int ts = AccessController.doPrivileged(
+ new GetIntegerAction("awt.dnd.drag.threshold", 0)).intValue();
if (ts > 0) {
return ts;
} else {
--- a/jdk/src/share/classes/java/awt/dnd/InvalidDnDOperationException.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/dnd/InvalidDnDOperationException.java Wed Mar 06 20:10:04 2013 +0400
@@ -36,6 +36,8 @@
public class InvalidDnDOperationException extends IllegalStateException {
+ private static final long serialVersionUID = 5156676500247816278L;
+
static private String dft_msg = "The operation requested cannot be performed by the DnD system since it is not in the appropriate state";
/**
--- a/jdk/src/share/classes/java/awt/geom/AffineTransform.java Wed Mar 06 19:42:26 2013 +0400
+++ b/jdk/src/share/classes/java/awt/geom/AffineTransform.java Wed Mar 06 20:10:04 2013 +0400
@@ -876,6 +876,7 @@
* they have not been cached.
* @see #getType
*/
+ @SuppressWarnings("fallthrough")
private void calculateType() {
int ret = TYPE_IDENTITY;
boolean sgn0, sgn1;
@@ -1038,6 +1039,7 @@
* @see #TYPE_UNIFORM_SCALE
* @since 1.2
*/
+ @SuppressWarnings("fallthrough")
public double getDeterminant() {
switch (state) {
default:
@@ -1250,6 +1252,7 @@
default:
stateError();
/* NOTREACHED */
+ return;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
m02 = tx * m00 + ty * m01 + m02;
m12 = tx * m10 + ty * m11 + m12;
@@ -1631,6 +1634,7 @@
* Y axis direction
* @since 1.2
*/
+ @SuppressWarnings("fallthrough")
public void scale(double sx, double sy) {
int state = this.state;
switch (state) {
@@ -1705,6 +1709,7 @@
default:
stateError();
/* NOTREACHED */
+ return;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
case (APPLY_SHEAR | APPLY_SCALE):
double M0, M1;
@@ -2224,6 +2229,7 @@
* @see #preConcatenate
* @since 1.2
*/
+ @SuppressWarnings("fallthrough")
public void concatenate(AffineTransform Tx) {
double M0, M1;
double T00, T01, T10, T11;
@@ -2432,6 +2438,7 @@
* @see #concatenate
* @since 1.2
*/
+ @SuppressWarnings("fallthrough")
public void preConcatenate(AffineTransform Tx) {
double M0, M1;
double T00, T01, T10, T11;
@@ -2655,6 +2662,7 @@
default:
stateError();
/* NOTREACHED */
+ return null;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
det = m00 * m11 - m01 * m10;
if (Math.abs(det) <= Double.MIN_VALUE) {
@@ -2751,6 +2759,7 @@
default:
stateError();
/* NOTREACHED */
+ return;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
M00 = m00; M01 = m01; M02 = m02;
M10 = m10; M11 = m11; M12 = m12;
@@ -2885,6 +2894,7 @@
default:
stateError();
/* NOTREACHED */
+ return null;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
ptDst.setLocation(x * m00 + y * m01 + m02,
x * m10 + y * m11 + m12);
@@ -2968,6 +2978,7 @@
default:
stateError();
/* NOTREACHED */
+ return;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
dst.setLocation(x * m00 + y * m01 + m02,
x * m10 + y * m11 + m12);
@@ -3043,6 +3054,7 @@
default:
stateError();
/* NOTREACHED */
+ return;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
M00 = m00; M01 = m01; M02 = m02;
M10 = m10; M11 = m11; M12 = m12;
@@ -3157,6 +3169,7 @@
default:
stateError();
/* NOTREACHED */
+ return;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
M00 = m00; M01 = m01; M02 = m02;
M10 = m10; M11 = m11; M12 = m12;
@@ -3252,6 +3265,7 @@
default:
stateError();
/* NOTREACHED */
+ return;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
M00 = m00; M01 = m01; M02 = m02;
M10 = m10; M11 = m11; M12 = m12;
@@ -3347,6 +3361,7 @@
default:
stateError();
/* NOTREACHED */
+ return;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
M00 = m00; M01 = m01; M02 = m02;
M10 = m10; M11 = m11; M12 = m12;
@@ -3436,6 +3451,7 @@
* inverted.
* @since 1.2
*/
+ @SuppressWarnings("fallthrough")
public Point2D inverseTransform(Point2D ptSrc, Point2D ptDst)
throws NoninvertibleTransformException
{
@@ -3547,6 +3563,7 @@
default:
stateError();
/* NOTREACHED */
+ return;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
M00 = m00; M01 = m01; M02 = m02;
M10 = m10; M11 = m11; M12 = m12;
@@ -3679,6 +3696,7 @@
default:
stateError();
/* NOTREACHED */
+ return null;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
case (APPLY_SHEAR | APPLY_SCALE):
ptDst.setLocation(x * m00 + y * m01, x * m10 + y * m11);
@@ -3754,6 +3772,7 @@
default:
stateError();
/* NOTREACHED */
+ return;
case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE):
case (APPLY_SHEAR | APPLY_SCALE):
M00 = m00; M01 = m01;