8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by: darcy, prr, flar
--- a/jdk/src/share/classes/java/awt/Menu.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/java/awt/Menu.java Mon Apr 28 19:05:49 2014 -0700
@@ -66,7 +66,7 @@
AWTAccessor.setMenuAccessor(
new AWTAccessor.MenuAccessor() {
- public Vector<MenuComponent> getItems(Menu menu) {
+ public Vector<MenuItem> getItems(Menu menu) {
return menu.items;
}
});
@@ -78,7 +78,7 @@
* @serial
* @see #countItems()
*/
- Vector<MenuComponent> items = new Vector<>();
+ Vector<MenuItem> items = new Vector<>();
/**
* This field indicates whether the menu has the
@@ -252,7 +252,7 @@
* be called on the toolkit thread.
*/
final MenuItem getItemImpl(int index) {
- return (MenuItem)items.elementAt(index);
+ return items.elementAt(index);
}
/**
@@ -544,7 +544,7 @@
// HeadlessException will be thrown from MenuComponent's readObject
s.defaultReadObject();
for(int i = 0; i < items.size(); i++) {
- MenuItem item = (MenuItem)items.elementAt(i);
+ MenuItem item = items.elementAt(i);
item.parent = this;
}
}
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java Mon Apr 28 19:05:49 2014 -0700
@@ -621,7 +621,7 @@
/**
* Returns menus
*/
- Vector getMenus(MenuBar menuBar);
+ Vector<Menu> getMenus(MenuBar menuBar);
}
/**
@@ -663,7 +663,7 @@
/**
* Returns vector of the items that are part of the Menu
*/
- Vector getItems(Menu menu);
+ Vector<MenuItem> getItems(Menu menu);
}
/**
--- a/jdk/src/share/classes/sun/awt/AppContext.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/AppContext.java Mon Apr 28 19:05:49 2014 -0700
@@ -890,6 +890,7 @@
Supplier<T> supplier) {
final AppContext appContext = AppContext.getAppContext();
+ @SuppressWarnings("unchecked")
SoftReference<T> ref = (SoftReference<T>) appContext.get(key);
if (ref != null) {
final T object = ref.get();
--- a/jdk/src/share/classes/sun/awt/FontConfiguration.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/FontConfiguration.java Mon Apr 28 19:05:49 2014 -0700
@@ -64,7 +64,7 @@
protected static String osName;
protected static String encoding; // canonical name of default nio charset
protected static Locale startupLocale = null;
- protected static Hashtable localeMap = null;
+ protected static Hashtable<String, String> localeMap = null;
private static FontConfiguration fontConfig;
private static PlatformLogger logger;
protected static boolean isProperties = true;
@@ -159,15 +159,15 @@
short fontNameID = compFontNameIDs[0][0][0];
short fileNameID = getComponentFileID(fontNameID);
final String fileName = mapFileName(getComponentFileName(fileNameID));
- Boolean exists = (Boolean)java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
+ Boolean exists = java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction<Boolean>() {
+ public Boolean run() {
try {
File f = new File(fileName);
return Boolean.valueOf(f.exists());
}
catch (Exception e) {
- return false;
+ return Boolean.FALSE;
}
}
});
@@ -534,11 +534,11 @@
private short remapLocaleMap(int fontIndex, int styleIndex, short scriptID, short fontID) {
String scriptName = getString(table_scriptIDs[scriptID]);
- String value = (String)localeMap.get(scriptName);
+ String value = localeMap.get(scriptName);
if (value == null) {
String fontName = fontNames[fontIndex];
String styleName = styleNames[styleIndex];
- value = (String)localeMap.get(fontName + "." + styleName + "." + scriptName);
+ value = localeMap.get(fontName + "." + styleName + "." + scriptName);
}
if (value == null) {
return fontID;
@@ -746,7 +746,7 @@
/* Mappings from file encoding to font config name for font supporting
* the corresponding language. This is filled in by initReorderMap()
*/
- protected HashMap reorderMap = null;
+ protected HashMap<String, Object> reorderMap = null;
/* Platform-specific mappings */
protected abstract void initReorderMap();
@@ -777,7 +777,7 @@
if (fontConfig.reorderMap == null) {
fontConfig.initReorderMap();
}
- HashMap reorderMap = fontConfig.reorderMap;
+ HashMap<String, Object> reorderMap = fontConfig.reorderMap;
/* Find the most specific mapping */
String language = startupLocale.getLanguage();
@@ -817,9 +817,9 @@
}
}
- private static Vector splitSequence(String sequence) {
+ private static Vector<String> splitSequence(String sequence) {
//String.split would be more convenient, but incurs big performance penalty
- Vector parts = new Vector();
+ Vector<String> parts = new Vector<>();
int start = 0;
int end;
while ((end = sequence.indexOf(',', start)) >= 0) {
@@ -833,14 +833,14 @@
}
protected String[] split(String sequence) {
- Vector v = splitSequence(sequence);
- return (String[])v.toArray(new String[0]);
+ Vector<String> v = splitSequence(sequence);
+ return v.toArray(new String[0]);
}
////////////////////////////////////////////////////////////////////////
// Methods for extracting information from the fontconfig data for AWT//
////////////////////////////////////////////////////////////////////////
- private Hashtable charsetRegistry = new Hashtable(5);
+ private Hashtable<String, Charset> charsetRegistry = new Hashtable<>(5);
/**
* Returns FontDescriptors describing the physical fonts used for the
@@ -932,9 +932,9 @@
Charset fc = null;
if (charsetName.equals("default")) {
- fc = (Charset) charsetRegistry.get(fontName);
+ fc = charsetRegistry.get(fontName);
} else {
- fc = (Charset) charsetRegistry.get(charsetName);
+ fc = charsetRegistry.get(charsetName);
}
if (fc != null) {
return fc.newEncoder();
@@ -943,8 +943,8 @@
if (!charsetName.startsWith("sun.awt.") && !charsetName.equals("default")) {
fc = Charset.forName(charsetName);
} else {
- Class fcc = (Class) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ Class<?> fcc = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
+ public Class<?> run() {
try {
return Class.forName(charsetName, true,
ClassLoader.getSystemClassLoader());
@@ -1377,9 +1377,9 @@
//This method will only be called during build time, do we
//need do PrivilegedAction?
- String osName = (String)java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
+ String osName = java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction<String>() {
+ public String run() {
return System.getProperty("os.name");
}
});
@@ -2139,7 +2139,7 @@
boolean has1252 = false;
//get the scriptID list
- String[] ss = (String[])splitSequence(value).toArray(EMPTY_STRING_ARRAY);
+ String[] ss = splitSequence(value).toArray(EMPTY_STRING_ARRAY);
short [] sa = new short[ss.length];
for (int i = 0; i < ss.length; i++) {
if ("alphabetic/default".equals(ss[i])) {
--- a/jdk/src/share/classes/sun/awt/HToolkit.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/HToolkit.java Mon Apr 28 19:05:49 2014 -0700
@@ -214,7 +214,8 @@
throw new HeadlessException();
}
- public Map mapInputMethodHighlight(InputMethodHighlight highlight)
+ public Map<java.awt.font.TextAttribute, ?> mapInputMethodHighlight(
+ InputMethodHighlight highlight)
throws HeadlessException {
throw new HeadlessException();
}
--- a/jdk/src/share/classes/sun/awt/HeadlessToolkit.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/HeadlessToolkit.java Mon Apr 28 19:05:49 2014 -0700
@@ -29,6 +29,7 @@
import java.awt.dnd.*;
import java.awt.dnd.peer.DragSourceContextPeer;
import java.awt.event.*;
+import java.awt.font.TextAttribute;
import java.awt.im.InputMethodHighlight;
import java.awt.image.*;
import java.awt.datatransfer.Clipboard;
@@ -224,7 +225,7 @@
throw new HeadlessException();
}
- public Map mapInputMethodHighlight(InputMethodHighlight highlight)
+ public Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight)
throws HeadlessException {
throw new HeadlessException();
}
--- a/jdk/src/share/classes/sun/awt/PlatformFont.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/PlatformFont.java Mon Apr 28 19:05:49 2014 -0700
@@ -143,7 +143,7 @@
if (len < 1) {
return new CharsetString[0];
}
- Vector mcs = null;
+ Vector<CharsetString> mcs = null;
char[] tmpStr = new char[len];
char tmpChar = defaultChar;
boolean encoded = false;
@@ -198,7 +198,7 @@
}
if (currentFont != fd){
if (mcs == null) {
- mcs = new Vector(3);
+ mcs = new Vector<>(3);
}
mcs.addElement(new CharsetString(tmpStr, lastIndex,
i-lastIndex, currentFont));
@@ -209,16 +209,13 @@
}
CharsetString[] result;
CharsetString cs = new CharsetString(tmpStr, lastIndex,
- len-lastIndex, currentFont);
+ len-lastIndex, currentFont);
if (mcs == null) {
result = new CharsetString[1];
result[0] = cs;
} else {
mcs.addElement(cs);
- result = new CharsetString[mcs.size()];
- for (int i = 0; i < mcs.size(); i++){
- result[i] = (CharsetString)mcs.elementAt(i);
- }
+ result = mcs.toArray(new CharsetString[mcs.size()]);
}
return result;
}
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java Mon Apr 28 19:05:49 2014 -0700
@@ -1915,6 +1915,7 @@
public synchronized void setWindowDeactivationTime(Window w, long time) {
AppContext ctx = getAppContext(w);
+ @SuppressWarnings("unchecked")
WeakHashMap<Window, Long> map = (WeakHashMap<Window, Long>)ctx.get(DEACTIVATION_TIMES_MAP_KEY);
if (map == null) {
map = new WeakHashMap<Window, Long>();
@@ -1925,6 +1926,7 @@
public synchronized long getWindowDeactivationTime(Window w) {
AppContext ctx = getAppContext(w);
+ @SuppressWarnings("unchecked")
WeakHashMap<Window, Long> map = (WeakHashMap<Window, Long>)ctx.get(DEACTIVATION_TIMES_MAP_KEY);
if (map == null) {
return -1;
--- a/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/datatransfer/DataTransferer.java Mon Apr 28 19:05:49 2014 -0700
@@ -324,7 +324,7 @@
return false;
}
- Class rep_class = flavor.getRepresentationClass();
+ Class<?> rep_class = flavor.getRepresentationClass();
if (flavor.isRepresentationClassReader() ||
String.class.equals(rep_class) ||
@@ -696,7 +696,7 @@
* DataFlavors and data formats
* @throws NullPointerException if formats or map is <code>null</code>
*/
- public Set getFlavorsForFormatsAsSet(long[] formats, FlavorTable map) {
+ public Set<DataFlavor> getFlavorsForFormatsAsSet(long[] formats, FlavorTable map) {
Set<DataFlavor> flavorSet = new HashSet<>(formats.length);
for (long format : formats) {
@@ -1085,7 +1085,7 @@
throw new IOException("data translation failed");
}
- final List list = (List)obj;
+ final List<?> list = (List<?>)obj;
final ProtectionDomain userProtectionDomain = getUserProtectionDomain(contents);
@@ -1113,7 +1113,7 @@
if (targetCharset == null) {
targetCharset = "UTF-8";
}
- final List list = (List)obj;
+ final List<?> list = (List<?>)obj;
final ProtectionDomain userProtectionDomain = getUserProtectionDomain(contents);
final ArrayList<String> fileList = castToFiles(list, userProtectionDomain);
final ArrayList<String> uriList = new ArrayList<>(fileList.size());
@@ -1258,7 +1258,7 @@
return true;
}
- private ArrayList<String> castToFiles(final List files,
+ private ArrayList<String> castToFiles(final List<?> files,
final ProtectionDomain userProtectionDomain) throws IOException {
try {
return AccessController.doPrivileged((PrivilegedExceptionAction<ArrayList<String>>) () -> {
@@ -1636,7 +1636,7 @@
* instance of the Class as its sole parameter.
*/
private Object constructFlavoredObject(Object arg, DataFlavor flavor,
- Class clazz)
+ Class<?> clazz)
throws IOException
{
final Class<?> dfrc = flavor.getRepresentationClass();
@@ -1644,19 +1644,19 @@
if (clazz.equals(dfrc)) {
return arg; // simple case
} else {
- Constructor[] constructors;
+ Constructor<?>[] constructors;
try {
constructors = AccessController.doPrivileged(
- (PrivilegedAction<Constructor[]>) dfrc::getConstructors);
+ (PrivilegedAction<Constructor<?>[]>) dfrc::getConstructors);
} catch (SecurityException se) {
throw new IOException(se.getMessage());
}
- Constructor constructor = Stream.of(constructors)
+ Constructor<?> constructor = Stream.of(constructors)
.filter(c -> Modifier.isPublic(c.getModifiers()))
.filter(c -> {
- Class[] ptypes = c.getParameterTypes();
+ Class<?>[] ptypes = c.getParameterTypes();
return ptypes != null
&& ptypes.length == 1
&& clazz.equals(ptypes[0]);
@@ -1865,7 +1865,8 @@
byte[] bytes, String mimeType) throws IOException
{
- Iterator readerIterator = ImageIO.getImageReadersByMIMEType(mimeType);
+ Iterator<ImageReader> readerIterator =
+ ImageIO.getImageReadersByMIMEType(mimeType);
if (!readerIterator.hasNext()) {
throw new IOException("No registered service provider can decode " +
@@ -1875,7 +1876,7 @@
IOException ioe = null;
while (readerIterator.hasNext()) {
- ImageReader imageReader = (ImageReader)readerIterator.next();
+ ImageReader imageReader = readerIterator.next();
try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes)) {
try (ImageInputStream imageInputStream = ImageIO.createImageInputStream(bais)) {
ImageReadParam param = imageReader.getDefaultReadParam();
@@ -1918,7 +1919,8 @@
throws IOException {
IOException originalIOE = null;
- Iterator writerIterator = ImageIO.getImageWritersByMIMEType(mimeType);
+ Iterator<ImageWriter> writerIterator =
+ ImageIO.getImageWritersByMIMEType(mimeType);
if (!writerIterator.hasNext()) {
throw new IOException("No registered service provider can encode " +
@@ -1977,7 +1979,8 @@
String mimeType)
throws IOException {
- Iterator writerIterator = ImageIO.getImageWritersByMIMEType(mimeType);
+ Iterator<ImageWriter> writerIterator =
+ ImageIO.getImageWritersByMIMEType(mimeType);
ImageTypeSpecifier typeSpecifier =
new ImageTypeSpecifier(renderedImage);
@@ -1986,7 +1989,7 @@
IOException ioe = null;
while (writerIterator.hasNext()) {
- ImageWriter imageWriter = (ImageWriter)writerIterator.next();
+ ImageWriter imageWriter = writerIterator.next();
ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider();
if (!writerSpi.canEncodeImage(typeSpecifier)) {
@@ -2070,7 +2073,7 @@
public byte[] convertData(final Object source,
final Transferable contents,
final long format,
- final Map formatMap,
+ final Map<Long, DataFlavor> formatMap,
final boolean isToolkitThread)
throws IOException
{
@@ -2093,7 +2096,7 @@
}
byte[] data = null;
try {
- DataFlavor flavor = (DataFlavor)formatMap.get(format);
+ DataFlavor flavor = formatMap.get(format);
if (flavor != null) {
data = translateTransferable(contents, flavor, format);
}
@@ -2134,7 +2137,7 @@
} finally {
getToolkitThreadBlockedHandler().unlock();
} else {
- DataFlavor flavor = (DataFlavor)formatMap.get(format);
+ DataFlavor flavor = formatMap.get(format);
if (flavor != null) {
ret = translateTransferable(contents, flavor, format);
}
@@ -2183,7 +2186,7 @@
* Helper function to convert a Set of DataFlavors to a sorted array.
* The array will be sorted according to <code>DataFlavorComparator</code>.
*/
- public static DataFlavor[] setToSortedDataFlavorArray(Set flavorsSet) {
+ public static DataFlavor[] setToSortedDataFlavorArray(Set<DataFlavor> flavorsSet) {
DataFlavor[] flavors = new DataFlavor[flavorsSet.size()];
flavorsSet.toArray(flavors);
final Comparator<DataFlavor> comparator =
@@ -2544,12 +2547,12 @@
String primaryType1 = flavor1.getPrimaryType();
String subType1 = flavor1.getSubType();
String mimeType1 = primaryType1 + "/" + subType1;
- Class class1 = flavor1.getRepresentationClass();
+ Class<?> class1 = flavor1.getRepresentationClass();
String primaryType2 = flavor2.getPrimaryType();
String subType2 = flavor2.getSubType();
String mimeType2 = primaryType2 + "/" + subType2;
- Class class2 = flavor2.getRepresentationClass();
+ Class<?> class2 = flavor2.getRepresentationClass();
if (flavor1.isFlavorTextType() && flavor2.isFlavorTextType()) {
// First, compare MIME types
--- a/jdk/src/share/classes/sun/awt/datatransfer/SunClipboard.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/datatransfer/SunClipboard.java Mon Apr 28 19:05:49 2014 -0700
@@ -78,7 +78,7 @@
* this clipboard. It is used for tracking changes
* of <code>DataFlavor</code>s available on this clipboard.
*/
- private volatile Set currentDataFlavors;
+ private volatile Set<DataFlavor> currentDataFlavors;
public SunClipboard(String name) {
@@ -338,7 +338,7 @@
protected abstract byte[] getClipboardData(long format) throws IOException;
- private static Set formatArrayAsDataFlavorSet(long[] formats) {
+ private static Set<DataFlavor> formatArrayAsDataFlavorSet(long[] formats) {
return (formats == null) ? null :
DataTransferer.getInstance().
getFlavorsForFormatsAsSet(formats, getDefaultFlavorTable());
@@ -417,7 +417,7 @@
* this clipboard
*/
public void checkChange(long[] formats) {
- Set prevDataFlavors = currentDataFlavors;
+ Set<DataFlavor> prevDataFlavors = currentDataFlavors;
currentDataFlavors = formatArrayAsDataFlavorSet(formats);
if (Objects.equals(prevDataFlavors, currentDataFlavors)) {
--- a/jdk/src/share/classes/sun/awt/datatransfer/TransferableProxy.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/datatransfer/TransferableProxy.java Mon Apr 28 19:05:49 2014 -0700
@@ -111,9 +111,9 @@
}
protected void annotateClass(final Class<?> cl) throws IOException {
- ClassLoader classLoader =
- (ClassLoader)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ ClassLoader classLoader = AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
return cl.getClassLoader();
}
});
@@ -124,14 +124,14 @@
map.put(s, classLoader);
}
protected void annotateProxyClass(final Class<?> cl) throws IOException {
- ClassLoader classLoader =
- (ClassLoader)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ ClassLoader classLoader = AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
return cl.getClassLoader();
}
});
- Class[] interfaces = cl.getInterfaces();
+ Class<?>[] interfaces = cl.getInterfaces();
Set<String> s = new HashSet<String>(interfaces.length);
for (int i = 0; i < interfaces.length; i++) {
s.add(interfaces[i].getName());
@@ -141,7 +141,7 @@
}
Map<Set<String>, ClassLoader> getClassLoaderMap() {
- return new HashMap(map);
+ return new HashMap<>(map);
}
}
@@ -191,9 +191,9 @@
boolean hasNonPublicInterface = false;
// define proxy in class loader of non-public interface(s), if any
- Class[] classObjs = new Class[interfaces.length];
+ Class<?>[] classObjs = new Class<?>[interfaces.length];
for (int i = 0; i < interfaces.length; i++) {
- Class cl = Class.forName(interfaces[i], false, classLoader);
+ Class<?> cl = Class.forName(interfaces[i], false, classLoader);
if ((cl.getModifiers() & Modifier.PUBLIC) == 0) {
if (hasNonPublicInterface) {
if (nonPublicLoader != cl.getClassLoader()) {
--- a/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/dnd/SunDragSourceContextPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -146,7 +146,7 @@
}
protected abstract void startDrag(Transferable trans,
- long[] formats, Map formatMap);
+ long[] formats, Map<Long, DataFlavor> formatMap);
/**
* set cursor
--- a/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/dnd/SunDropTargetContextPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -252,11 +252,11 @@
throw new InvalidDnDOperationException("No drop current");
}
- Map flavorMap = DataTransferer.getInstance().getFlavorsForFormats
- (currentT, DataTransferer.adaptFlavorMap
+ Map<DataFlavor, Long> flavorMap = DataTransferer.getInstance()
+ .getFlavorsForFormats(currentT, DataTransferer.adaptFlavorMap
(currentDT.getFlavorMap()));
- lFormat = (Long)flavorMap.get(df);
+ lFormat = flavorMap.get(df);
if (lFormat == null) {
throw new UnsupportedFlavorException(df);
}
@@ -745,7 +745,7 @@
// dispatcher state fields
private int returnValue = 0;
// set of events to be dispatched by this dispatcher
- private final HashSet eventSet = new HashSet(3);
+ private final HashSet<SunDropTargetEvent> eventSet = new HashSet<>(3);
static final ToolkitThreadBlockedHandler handler =
DataTransferer.getInstance().getToolkitThreadBlockedHandler();
--- a/jdk/src/share/classes/sun/awt/geom/AreaOp.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/geom/AreaOp.java Mon Apr 28 19:05:49 2014 -0700
@@ -152,36 +152,36 @@
public abstract int getState();
- public Vector calculate(Vector left, Vector right) {
- Vector edges = new Vector();
+ public Vector<Curve> calculate(Vector<Curve> left, Vector<Curve> right) {
+ Vector<Edge> edges = new Vector<>();
addEdges(edges, left, AreaOp.CTAG_LEFT);
addEdges(edges, right, AreaOp.CTAG_RIGHT);
- edges = pruneEdges(edges);
+ Vector<Curve> curves = pruneEdges(edges);
if (false) {
System.out.println("result: ");
- int numcurves = edges.size();
- Curve[] curvelist = (Curve[]) edges.toArray(new Curve[numcurves]);
+ int numcurves = curves.size();
+ Curve[] curvelist = curves.toArray(new Curve[numcurves]);
for (int i = 0; i < numcurves; i++) {
System.out.println("curvelist["+i+"] = "+curvelist[i]);
}
}
- return edges;
+ return curves;
}
- private static void addEdges(Vector edges, Vector curves, int curvetag) {
- Enumeration enum_ = curves.elements();
+ private static void addEdges(Vector<Edge> edges, Vector<Curve> curves, int curvetag) {
+ Enumeration<Curve> enum_ = curves.elements();
while (enum_.hasMoreElements()) {
- Curve c = (Curve) enum_.nextElement();
+ Curve c = enum_.nextElement();
if (c.getOrder() > 0) {
edges.add(new Edge(c, curvetag));
}
}
}
- private static Comparator YXTopComparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- Curve c1 = ((Edge) o1).getCurve();
- Curve c2 = ((Edge) o2).getCurve();
+ private static Comparator<Edge> YXTopComparator = new Comparator<Edge>() {
+ public int compare(Edge o1, Edge o2) {
+ Curve c1 = o1.getCurve();
+ Curve c2 = o2.getCurve();
double v1, v2;
if ((v1 = c1.getYTop()) == (v2 = c2.getYTop())) {
if ((v1 = c1.getXTop()) == (v2 = c2.getXTop())) {
@@ -195,12 +195,13 @@
}
};
- private Vector pruneEdges(Vector edges) {
+ private Vector<Curve> pruneEdges(Vector<Edge> edges) {
int numedges = edges.size();
if (numedges < 2) {
- return edges;
+ // empty vector is expected with less than 2 edges
+ return new Vector<>();
}
- Edge[] edgelist = (Edge[]) edges.toArray(new Edge[numedges]);
+ Edge[] edgelist = edges.toArray(new Edge[numedges]);
Arrays.sort(edgelist, YXTopComparator);
if (false) {
System.out.println("pruning: ");
@@ -214,9 +215,9 @@
int cur = 0;
int next = 0;
double yrange[] = new double[2];
- Vector subcurves = new Vector();
- Vector chains = new Vector();
- Vector links = new Vector();
+ Vector<CurveLink> subcurves = new Vector<>();
+ Vector<ChainEnd> chains = new Vector<>();
+ Vector<CurveLink> links = new Vector<>();
// Active edges are between left (inclusive) and right (exclusive)
while (left < numedges) {
double y = yrange[0];
@@ -385,7 +386,7 @@
if (false) {
System.out.println("new links:");
for (int i = 0; i < links.size(); i++) {
- CurveLink link = (CurveLink) links.elementAt(i);
+ CurveLink link = links.elementAt(i);
System.out.println(" "+link.getSubCurve());
}
}
@@ -396,10 +397,10 @@
yrange[0] = yend;
}
finalizeSubCurves(subcurves, chains);
- Vector ret = new Vector();
- Enumeration enum_ = subcurves.elements();
+ Vector<Curve> ret = new Vector<>();
+ Enumeration<CurveLink> enum_ = subcurves.elements();
while (enum_.hasMoreElements()) {
- CurveLink link = (CurveLink) enum_.nextElement();
+ CurveLink link = enum_.nextElement();
ret.add(link.getMoveto());
CurveLink nextlink = link;
while ((nextlink = nextlink.getNext()) != null) {
@@ -413,7 +414,8 @@
return ret;
}
- public static void finalizeSubCurves(Vector subcurves, Vector chains) {
+ public static void finalizeSubCurves(Vector<CurveLink> subcurves,
+ Vector<ChainEnd> chains) {
int numchains = chains.size();
if (numchains == 0) {
return;
@@ -437,9 +439,9 @@
private static CurveLink[] EmptyLinkList = new CurveLink[2];
private static ChainEnd[] EmptyChainList = new ChainEnd[2];
- public static void resolveLinks(Vector subcurves,
- Vector chains,
- Vector links)
+ public static void resolveLinks(Vector<CurveLink> subcurves,
+ Vector<ChainEnd> chains,
+ Vector<CurveLink> links)
{
int numlinks = links.size();
CurveLink[] linklist;
--- a/jdk/src/share/classes/sun/awt/geom/Crossings.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/geom/Crossings.java Mon Apr 28 19:05:49 2014 -0700
@@ -77,14 +77,14 @@
public abstract boolean covers(double ystart, double yend);
- public static Crossings findCrossings(Vector curves,
+ public static Crossings findCrossings(Vector<? extends Curve> curves,
double xlo, double ylo,
double xhi, double yhi)
{
Crossings cross = new EvenOdd(xlo, ylo, xhi, yhi);
- Enumeration enum_ = curves.elements();
+ Enumeration<? extends Curve> enum_ = curves.elements();
while (enum_.hasMoreElements()) {
- Curve c = (Curve) enum_.nextElement();
+ Curve c = enum_.nextElement();
if (c.accumulateCrossings(cross)) {
return null;
}
@@ -237,7 +237,7 @@
return false;
}
- private Vector tmp = new Vector();
+ private Vector<Curve> tmp = new Vector<>();
public boolean accumulateQuad(double x0, double y0, double coords[]) {
if (y0 < ylo && coords[1] < ylo && coords[3] < ylo) {
@@ -258,9 +258,9 @@
return false;
}
Curve.insertQuad(tmp, x0, y0, coords);
- Enumeration enum_ = tmp.elements();
+ Enumeration<Curve> enum_ = tmp.elements();
while (enum_.hasMoreElements()) {
- Curve c = (Curve) enum_.nextElement();
+ Curve c = enum_.nextElement();
if (c.accumulateCrossings(this)) {
return true;
}
@@ -296,9 +296,9 @@
return false;
}
Curve.insertCubic(tmp, x0, y0, coords);
- Enumeration enum_ = tmp.elements();
+ Enumeration<Curve> enum_ = tmp.elements();
while (enum_.hasMoreElements()) {
- Curve c = (Curve) enum_.nextElement();
+ Curve c = enum_.nextElement();
if (c.accumulateCrossings(this)) {
return true;
}
--- a/jdk/src/share/classes/sun/awt/geom/Curve.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/geom/Curve.java Mon Apr 28 19:05:49 2014 -0700
@@ -38,11 +38,11 @@
protected int direction;
- public static void insertMove(Vector curves, double x, double y) {
+ public static void insertMove(Vector<Curve> curves, double x, double y) {
curves.add(new Order0(x, y));
}
- public static void insertLine(Vector curves,
+ public static void insertLine(Vector<Curve> curves,
double x0, double y0,
double x1, double y1)
{
@@ -59,7 +59,7 @@
}
}
- public static void insertQuad(Vector curves,
+ public static void insertQuad(Vector<Curve> curves,
double x0, double y0,
double coords[])
{
@@ -82,7 +82,7 @@
}
}
- public static void insertCubic(Vector curves,
+ public static void insertCubic(Vector<Curve> curves,
double x0, double y0,
double coords[])
{
--- a/jdk/src/share/classes/sun/awt/geom/Order2.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/geom/Order2.java Mon Apr 28 19:05:49 2014 -0700
@@ -47,7 +47,7 @@
private double ycoeff1;
private double ycoeff2;
- public static void insert(Vector curves, double tmp[],
+ public static void insert(Vector<Curve> curves, double tmp[],
double x0, double y0,
double cx0, double cy0,
double x1, double y1,
@@ -74,7 +74,7 @@
tmp[i1 + 4], tmp[i1 + 5], direction);
}
- public static void addInstance(Vector curves,
+ public static void addInstance(Vector<Curve> curves,
double x0, double y0,
double cx0, double cy0,
double x1, double y1,
--- a/jdk/src/share/classes/sun/awt/geom/Order3.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/geom/Order3.java Mon Apr 28 19:05:49 2014 -0700
@@ -53,7 +53,7 @@
private double ycoeff2;
private double ycoeff3;
- public static void insert(Vector curves, double tmp[],
+ public static void insert(Vector<Curve> curves, double tmp[],
double x0, double y0,
double cx0, double cy0,
double cx1, double cy1,
@@ -105,7 +105,7 @@
}
}
- public static void addInstance(Vector curves,
+ public static void addInstance(Vector<Curve> curves,
double x0, double y0,
double cx0, double cy0,
double cx1, double cy1,
--- a/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java Mon Apr 28 19:05:49 2014 -0700
@@ -51,7 +51,7 @@
private BufferedImageGraphicsConfig graphicsConfig;
RenderLoops solidloops;
- private static native void initIDs(Class ICM, Class ICMColorData);
+ private static native void initIDs(Class<?> ICM, Class<?> ICMColorData);
private static final int DCM_RGBX_RED_MASK = 0xff000000;
private static final int DCM_RGBX_GREEN_MASK = 0x00ff0000;
--- a/jdk/src/share/classes/sun/awt/image/GifImageDecoder.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/image/GifImageDecoder.java Mon Apr 28 19:05:49 2014 -0700
@@ -61,7 +61,7 @@
int trans_pixel = -1;
IndexColorModel global_model;
- Hashtable props = new Hashtable();
+ Hashtable<String, Object> props = new Hashtable<>();
byte[] saved_image;
IndexColorModel saved_model;
--- a/jdk/src/share/classes/sun/awt/image/ImageDecoder.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/image/ImageDecoder.java Mon Apr 28 19:05:49 2014 -0700
@@ -83,7 +83,7 @@
return count;
}
- protected int setProperties(Hashtable props) {
+ protected int setProperties(Hashtable<?,?> props) {
ImageConsumerQueue cq = null;
int count = 0;
while ((cq = nextConsumer(cq)) != null) {
@@ -164,7 +164,7 @@
source.doneDecoding(this);
close();
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
+ new java.security.PrivilegedAction<Object>() {
public Object run() {
feeder.interrupt();
return null;
--- a/jdk/src/share/classes/sun/awt/image/ImageFetcher.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/image/ImageFetcher.java Mon Apr 28 19:05:49 2014 -0700
@@ -152,7 +152,7 @@
info.numWaiting--;
}
}
- src = (ImageFetchable) info.waitList.elementAt(0);
+ src = info.waitList.elementAt(0);
info.waitList.removeElement(src);
}
return src;
@@ -303,26 +303,25 @@
final ThreadGroup fetcherGroup = fetcherThreadGroup;
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
- for (int i = 0; i < info.fetchers.length; i++) {
- if (info.fetchers[i] == null) {
- ImageFetcher f = new ImageFetcher(
- fetcherGroup, i);
- try {
- f.start();
- info.fetchers[i] = f;
- info.numFetchers++;
- break;
- } catch (Error e) {
+ new java.security.PrivilegedAction<Object>() {
+ public Object run() {
+ for (int i = 0; i < info.fetchers.length; i++) {
+ if (info.fetchers[i] == null) {
+ ImageFetcher f = new ImageFetcher(fetcherGroup, i);
+ try {
+ f.start();
+ info.fetchers[i] = f;
+ info.numFetchers++;
+ break;
+ } catch (Error e) {
+ }
}
+ }
+ return null;
}
- }
- return null;
- }
- });
- return;
- }
+ });
+ return;
+ }
}
@@ -337,13 +336,13 @@
Thread[] fetchers;
int numFetchers;
int numWaiting;
- Vector waitList;
+ Vector<ImageFetchable> waitList;
private FetcherInfo() {
fetchers = new Thread[MAX_NUM_FETCHERS_PER_APPCONTEXT];
numFetchers = 0;
numWaiting = 0;
- waitList = new Vector();
+ waitList = new Vector<>();
}
/* The key to put()/get() the FetcherInfo into/from the AppContext. */
--- a/jdk/src/share/classes/sun/awt/image/ImageRepresentation.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/image/ImageRepresentation.java Mon Apr 28 19:05:49 2014 -0700
@@ -185,7 +185,7 @@
protected BufferedImage createImage(ColorModel cm,
WritableRaster raster,
boolean isRasterPremultiplied,
- Hashtable properties)
+ Hashtable<?,?> properties)
{
BufferedImage bi =
new BufferedImage(cm, raster, isRasterPremultiplied, null);
--- a/jdk/src/share/classes/sun/awt/image/ImagingLib.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/image/ImagingLib.java Mon Apr 28 19:05:49 2014 -0700
@@ -61,7 +61,7 @@
private static final int AFFINE_OP = 1;
private static final int CONVOLVE_OP = 2;
- private static Class[] nativeOpClass = new Class[NUM_NATIVE_OPS];
+ private static Class<?>[] nativeOpClass = new Class<?>[NUM_NATIVE_OPS];
/**
* Returned value indicates whether the library initailization was
@@ -134,7 +134,7 @@
}
- private static int getNativeOpIndex(Class opClass) {
+ private static int getNativeOpIndex(Class<?> opClass) {
//
// Search for this class in cached list of
// classes supplying native acceleration
--- a/jdk/src/share/classes/sun/awt/image/JPEGImageDecoder.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/image/JPEGImageDecoder.java Mon Apr 28 19:05:49 2014 -0700
@@ -47,8 +47,8 @@
private static ColorModel ARGBcolormodel;
private static ColorModel Graycolormodel;
- private static final Class InputStreamClass = InputStream.class;
- private static native void initIDs(Class InputStreamClass);
+ private static final Class<?> InputStreamClass = InputStream.class;
+ private static native void initIDs(Class<?> InputStreamClass);
private ColorModel colormodel;
@@ -73,7 +73,7 @@
private native void readImage(InputStream is, byte buf[])
throws ImageFormatException, IOException;
- Hashtable props = new Hashtable();
+ Hashtable<String, Object> props = new Hashtable<>();
public JPEGImageDecoder(InputStreamImageSource src, InputStream is) {
super(src, is);
--- a/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java Mon Apr 28 19:05:49 2014 -0700
@@ -40,15 +40,15 @@
BufferedImage image;
int width;
int height;
- Hashtable properties;
+ Hashtable<?, ?> properties;
public OffScreenImageSource(BufferedImage image,
- Hashtable properties) {
+ Hashtable<?, ?> properties) {
this.image = image;
if (properties != null) {
this.properties = properties;
} else {
- this.properties = new Hashtable();
+ this.properties = new Hashtable<String, Object>();
}
width = image.getWidth();
height = image.getHeight();
--- a/jdk/src/share/classes/sun/awt/image/PNGImageDecoder.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/image/PNGImageDecoder.java Mon Apr 28 19:05:49 2014 -0700
@@ -68,7 +68,7 @@
private int filterMethod;
private int interlaceMethod;
private int gamma = 100000;
- private java.util.Hashtable properties;
+ private java.util.Hashtable<String, Object> properties;
/* this is not needed
ImageConsumer target;
*/
@@ -83,7 +83,7 @@
private void property(String key,Object value) {
if(value==null) return;
- if(properties==null) properties=new java.util.Hashtable();
+ if(properties==null) properties=new java.util.Hashtable<>();
properties.put(key,value);
}
private void property(String key,float value) {
--- a/jdk/src/share/classes/sun/awt/image/ToolkitImage.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/image/ToolkitImage.java Mon Apr 28 19:05:49 2014 -0700
@@ -79,7 +79,7 @@
private int width = -1;
private int height = -1;
- private Hashtable properties;
+ private Hashtable<?, ?> properties;
private int availinfo;
@@ -254,9 +254,9 @@
addInfo(ImageObserver.WIDTH | ImageObserver.HEIGHT);
}
- void setProperties(Hashtable props) {
+ void setProperties(Hashtable<?, ?> props) {
if (props == null) {
- props = new Hashtable();
+ props = new Hashtable<String, Object>();
}
properties = props;
addInfo(ImageObserver.PROPERTIES);
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolder.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolder.java Mon Apr 28 19:05:49 2014 -0700
@@ -127,14 +127,14 @@
File[] files = super.listFiles();
if (!includeHiddenFiles) {
- Vector v = new Vector();
+ Vector<File> v = new Vector<>();
int nameCount = (files == null) ? 0 : files.length;
for (int i = 0; i < nameCount; i++) {
if (!files[i].isHidden()) {
v.addElement(files[i]);
}
}
- files = (File[])v.toArray(new File[v.size()]);
+ files = v.toArray(new File[v.size()]);
}
return files;
@@ -208,7 +208,7 @@
static {
String managerClassName = (String)Toolkit.getDefaultToolkit().
getDesktopProperty("Shell.shellFolderManager");
- Class managerClass = null;
+ Class<?> managerClass = null;
try {
managerClass = ReflectUtil.forName(managerClassName);
// swallow the exceptions below and use default shell folder
@@ -554,7 +554,7 @@
/**
* Provides a default comparator for the default column set
*/
- private static final Comparator DEFAULT_COMPARATOR = new Comparator() {
+ private static final Comparator<Object> DEFAULT_COMPARATOR = new Comparator<Object>() {
public int compare(Object o1, Object o2) {
int gt;
@@ -565,7 +565,9 @@
} else if (o1 == null && o2 != null) {
gt = -1;
} else if (o1 instanceof Comparable) {
- gt = ((Comparable) o1).compareTo(o2);
+ @SuppressWarnings("unchecked")
+ Comparable<Object> o = (Comparable<Object>) o1;
+ gt = o.compareTo(o2);
} else {
gt = 0;
}
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolderColumnInfo.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolderColumnInfo.java Mon Apr 28 19:05:49 2014 -0700
@@ -38,7 +38,7 @@
*/
private Integer alignment;
private SortOrder sortOrder;
- private Comparator comparator;
+ private Comparator<?> comparator;
/**
* <code>false</code> (default) if the {@link comparator} expects folders as arguments,
* and <code>true</code> if folder's column values. The first option is used default for comparison
@@ -49,7 +49,7 @@
public ShellFolderColumnInfo(String title, Integer width,
Integer alignment, boolean visible,
- SortOrder sortOrder, Comparator comparator,
+ SortOrder sortOrder, Comparator<?> comparator,
boolean compareByColumn) {
this.title = title;
this.width = width;
@@ -62,7 +62,7 @@
public ShellFolderColumnInfo(String title, Integer width,
Integer alignment, boolean visible,
- SortOrder sortOrder, Comparator comparator) {
+ SortOrder sortOrder, Comparator<?> comparator) {
this(title, width, alignment, visible, sortOrder, comparator, false);
}
@@ -115,11 +115,11 @@
this.sortOrder = sortOrder;
}
- public Comparator getComparator() {
+ public Comparator<?> getComparator() {
return comparator;
}
- public void setComparator(Comparator comparator) {
+ public void setComparator(Comparator<?> comparator) {
this.comparator = comparator;
}
--- a/jdk/src/share/classes/sun/awt/util/IdentityArrayList.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/util/IdentityArrayList.java Mon Apr 28 19:05:49 2014 -0700
@@ -285,6 +285,7 @@
* this list
* @throws NullPointerException if the specified array is null
*/
+ @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
if (a.length < size)
// Make a new array of a's runtime type, but my contents:
@@ -307,7 +308,9 @@
public E get(int index) {
rangeCheck(index);
- return (E) elementData[index];
+ @SuppressWarnings("unchecked")
+ E rv = (E) elementData[index];
+ return rv;
}
/**
@@ -322,6 +325,7 @@
public E set(int index, E element) {
rangeCheck(index);
+ @SuppressWarnings("unchecked")
E oldValue = (E) elementData[index];
elementData[index] = element;
return oldValue;
@@ -371,6 +375,7 @@
rangeCheck(index);
modCount++;
+ @SuppressWarnings("unchecked")
E oldValue = (E) elementData[index];
int numMoved = size - index - 1;
--- a/jdk/src/share/classes/sun/awt/util/IdentityLinkedList.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/share/classes/sun/awt/util/IdentityLinkedList.java Mon Apr 28 19:05:49 2014 -0700
@@ -280,7 +280,9 @@
Entry<E> successor = (index==size ? header : entry(index));
Entry<E> predecessor = successor.previous;
for (int i=0; i<numNew; i++) {
- Entry<E> e = new Entry<E>((E)a[i], successor, predecessor);
+ @SuppressWarnings("unchecked")
+ E tmp = (E) a[i];
+ Entry<E> e = new Entry<E>(tmp, successor, predecessor);
predecessor.next = e;
predecessor = e;
}
@@ -396,7 +398,7 @@
*/
public int indexOf(Object o) {
int index = 0;
- for (Entry e = header.next; e != header; e = e.next) {
+ for (Entry<E> e = header.next; e != header; e = e.next) {
if (o == e.element) {
return index;
}
@@ -418,7 +420,7 @@
*/
public int lastIndexOf(Object o) {
int index = size;
- for (Entry e = header.previous; e != header; e = e.previous) {
+ for (Entry<E> e = header.previous; e != header; e = e.previous) {
index--;
if (o == e.element) {
return index;
@@ -787,7 +789,7 @@
}
/** Adapter to provide descending iterators via ListItr.previous */
- private class DescendingIterator implements Iterator {
+ private class DescendingIterator implements Iterator<E> {
final ListItr itr = new ListItr(size());
public boolean hasNext() {
return itr.hasPrevious();
@@ -860,6 +862,7 @@
* this list
* @throws NullPointerException if the specified array is null
*/
+ @SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
if (a.length < size)
a = (T[])java.lang.reflect.Array.newInstance(
--- a/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/InfoWindow.java Mon Apr 28 19:05:49 2014 -0700
@@ -207,8 +207,9 @@
textLabel.setText(tooltipString);
}
- Point pointer = (Point)AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ Point pointer = AccessController.doPrivileged(
+ new PrivilegedAction<Point>() {
+ public Point run() {
if (!isPointerOverTrayIcon(liveArguments.getBounds())) {
return null;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java Mon Apr 28 19:05:49 2014 -0700
@@ -55,10 +55,10 @@
private final int SCROLLBAR_WIDTH; // Width of a scrollbar
- private java.util.List items; // List of items
+ private java.util.List<String> items; // List of items
// TODO: maybe this would be better as a simple int[]
- private java.util.List selected; // List of selected items
+ private java.util.List<Integer> selected; // List of selected items
private boolean multiSelect; // Can multiple items be selected
// at once?
private int focusedIndex;
@@ -100,8 +100,8 @@
this.peer = peer;
this.colors = colors;
this.multiSelect = multiSelect;
- items = new ArrayList(initialSize);
- selected = new ArrayList(1);
+ items = new ArrayList<>(initialSize);
+ selected = new ArrayList<>(1);
selected.add(Integer.valueOf(-1));
this.maxVisItems = maxVisItems;
@@ -190,7 +190,7 @@
/* if called for multiselect, return -1 */
public int getSelectedIndex() {
if (!multiSelect) {
- Integer val = (Integer)selected.get(0);
+ Integer val = selected.get(0);
return val.intValue();
}
return -1;
@@ -217,7 +217,7 @@
}
public String getItem(int index) {
- return (String) items.get(index);
+ return items.get(index);
}
/**********************************************************************/
@@ -576,9 +576,9 @@
}
boolean isItemSelected(int index) {
- Iterator itr = selected.iterator();
+ Iterator<Integer> itr = selected.iterator();
while (itr.hasNext()) {
- Integer val = (Integer)itr.next();
+ Integer val = itr.next();
if (val.intValue() == index) {
return true;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/MotifDnDDragSourceProtocol.java Mon Apr 28 19:05:49 2014 -0700
@@ -26,6 +26,7 @@
package sun.awt.X11;
import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.DataFlavor;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.InvalidDnDOperationException;
@@ -65,7 +66,7 @@
}
protected void initializeDragImpl(int actions, Transferable contents,
- Map formatMap, long[] formats)
+ Map<Long, DataFlavor> formatMap, long[] formats)
throws InvalidDnDOperationException,
IllegalArgumentException, XException {
--- a/jdk/src/solaris/classes/sun/awt/X11/Native.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/Native.java Mon Apr 28 19:05:49 2014 -0700
@@ -43,13 +43,12 @@
static int dataModel;
static {
- String dataModelProp = (String)AccessController.
- doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return System.getProperty("sun.arch.data.model");
- }
- });
+ String dataModelProp = AccessController.doPrivileged(
+ new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty("sun.arch.data.model");
+ }
+ });
try {
dataModel = Integer.parseInt(dataModelProp);
} catch (Exception e) {
@@ -333,9 +332,9 @@
* Stores Java Vector of Longs into memory. Memory location is treated as array
* of native <code>long</code>s
*/
- static void putLong(long ptr, Vector arr) {
+ static void putLong(long ptr, Vector<Long> arr) {
for (int i = 0; i < arr.size(); i ++, ptr += getLongSize()) {
- putLong(ptr, ((Long)arr.elementAt(i)).longValue());
+ putLong(ptr, arr.elementAt(i).longValue());
}
}
@@ -343,9 +342,9 @@
* Stores Java Vector of Longs into memory. Memory location is treated as array
* of native <code>long</code>s. Array is stored in reverse order
*/
- static void putLongReverse(long ptr, Vector arr) {
+ static void putLongReverse(long ptr, Vector<Long> arr) {
for (int i = arr.size()-1; i >= 0; i--, ptr += getLongSize()) {
- putLong(ptr, ((Long)arr.elementAt(i)).longValue());
+ putLong(ptr, arr.elementAt(i).longValue());
}
}
/**
--- a/jdk/src/solaris/classes/sun/awt/X11/XAWTXSettings.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XAWTXSettings.java Mon Apr 28 19:05:49 2014 -0700
@@ -98,7 +98,7 @@
* should be "good enough" for most cases.
*/
- Map updatedSettings = null;
+ Map<String, Object> updatedSettings = null;
XToolkit.awtLock();
try {
long display = XToolkit.getDisplay();
@@ -112,7 +112,7 @@
}
private void updateXSettings(int screen, long owner) {
- final Map updatedSettings = getUpdatedSettings(owner);
+ final Map<String, Object> updatedSettings = getUpdatedSettings(owner);
// this method is called under awt lock and usually on toolkit thread
// but parseXSettings() causes public code execution, so we need to transfer
// this to EDT
@@ -123,7 +123,7 @@
});
}
- private Map getUpdatedSettings(final long owner) {
+ private Map<String, Object> getUpdatedSettings(final long owner) {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("owner =" + owner);
}
@@ -131,7 +131,7 @@
return null;
}
- Map settings = null;
+ Map<String, Object> settings = null;
try {
WindowPropertyGetter getter =
new WindowPropertyGetter(owner, xSettingsPropertyAtom, 0, MAX_LENGTH,
--- a/jdk/src/solaris/classes/sun/awt/X11/XAtomList.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XAtomList.java Mon Apr 28 19:05:49 2014 -0700
@@ -157,7 +157,7 @@
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("[");
- Iterator iter = atoms.iterator();
+ Iterator<XAtom> iter = atoms.iterator();
while (iter.hasNext()) {
buf.append(iter.next().toString());
if (iter.hasNext()) {
--- a/jdk/src/solaris/classes/sun/awt/X11/XAwtState.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XAwtState.java Mon Apr 28 19:05:49 2014 -0700
@@ -40,7 +40,7 @@
* The mouse is over this component.
* If the component is not disabled, it received MOUSE_ENTERED but no MOUSE_EXITED.
*/
- private static WeakReference componentMouseEnteredRef = null;
+ private static WeakReference<Component> componentMouseEnteredRef = null;
static void setComponentMouseEntered(Component component) {
XToolkit.awtLock();
@@ -50,7 +50,7 @@
return;
}
if (component != getComponentMouseEntered()) {
- componentMouseEnteredRef = new WeakReference(component);
+ componentMouseEnteredRef = new WeakReference<>(component);
}
} finally {
XToolkit.awtUnlock();
@@ -63,7 +63,7 @@
if (componentMouseEnteredRef == null) {
return null;
}
- return (Component)componentMouseEnteredRef.get();
+ return componentMouseEnteredRef.get();
} finally {
XToolkit.awtUnlock();
}
@@ -83,7 +83,7 @@
return inManualGrab;
}
- private static WeakReference grabWindowRef = null;
+ private static WeakReference<XBaseWindow> grabWindowRef = null;
/**
* The X Active Grab overrides any other active grab by the same
@@ -112,7 +112,7 @@
return;
}
if (grabWindow != getGrabWindow()) {
- grabWindowRef = new WeakReference(grabWindow);
+ grabWindowRef = new WeakReference<>(grabWindow);
}
} finally {
XToolkit.awtUnlock();
@@ -125,7 +125,7 @@
if (grabWindowRef == null) {
return null;
}
- XBaseWindow xbw = (XBaseWindow)grabWindowRef.get();
+ XBaseWindow xbw = grabWindowRef.get();
if( xbw != null && xbw.isDisposed() ) {
xbw = null;
grabWindowRef = null;
--- a/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XBaseMenuWindow.java Mon Apr 28 19:05:49 2014 -0700
@@ -231,7 +231,7 @@
*/
void instantPreInit(XCreateWindowParams params) {
super.instantPreInit(params);
- items = new ArrayList();
+ items = new ArrayList<>();
}
/************************************************
@@ -367,10 +367,10 @@
* Clears items vector and loads specified vector
* @param items vector to be loaded
*/
- public void reloadItems(Vector items) {
+ public void reloadItems(Vector<? extends MenuItem> items) {
synchronized(getMenuTreeLock()) {
this.items.clear();
- MenuItem[] itemArray = (MenuItem[])items.toArray(new MenuItem[] {});
+ MenuItem[] itemArray = items.toArray(new MenuItem[] {});
int itemCnt = itemArray.length;
for(int i = 0; i < itemCnt; i++) {
addItem(itemArray[i]);
--- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -236,8 +236,8 @@
return false;
}
- private static Class seClass;
- private static Constructor seCtor;
+ private static Class<?> seClass;
+ private static Constructor<?> seCtor;
final static AWTEvent wrapInSequenced(AWTEvent event) {
try {
@@ -246,9 +246,11 @@
}
if (seCtor == null) {
- seCtor = (Constructor) AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws Exception {
- Constructor ctor = seClass.getConstructor(new Class[] { AWTEvent.class });
+ seCtor = AccessController.doPrivileged(new
+ PrivilegedExceptionAction<Constructor<?>>() {
+ public Constructor<?> run() throws Exception {
+ Constructor<?> ctor = seClass.getConstructor(
+ new Class<?>[] { AWTEvent.class });
ctor.setAccessible(true);
return ctor;
}
@@ -1322,7 +1324,7 @@
}
}
- private void addTree(Collection order, Set set, Container cont) {
+ private void addTree(Collection<Long> order, Set<Long> set, Container cont) {
for (int i = 0; i < cont.getComponentCount(); i++) {
Component comp = cont.getComponent(i);
ComponentPeer peer = comp.getPeer();
--- a/jdk/src/solaris/classes/sun/awt/X11/XCreateWindowParams.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XCreateWindowParams.java Mon Apr 28 19:05:49 2014 -0700
@@ -30,7 +30,7 @@
import java.util.Map;
@SuppressWarnings("serial") // JDK-implementation class
-public class XCreateWindowParams extends HashMap {
+public class XCreateWindowParams extends HashMap<Object, Object> {
public XCreateWindowParams() {
}
public XCreateWindowParams(Object[] map) {
@@ -82,9 +82,9 @@
}
public String toString() {
StringBuffer buf = new StringBuffer();
- Iterator eIter = entrySet().iterator();
+ Iterator<Map.Entry<Object, Object>> eIter = entrySet().iterator();
while (eIter.hasNext()) {
- Map.Entry entry = (Map.Entry)eIter.next();
+ Map.Entry<Object, Object> entry = eIter.next();
buf.append(entry.getKey() + ": " + entry.getValue() + "\n");
}
return buf.toString();
--- a/jdk/src/solaris/classes/sun/awt/X11/XDataTransferer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDataTransferer.java Mon Apr 28 19:05:49 2014 -0700
@@ -49,6 +49,7 @@
import java.util.List;
import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.ImageWriter;
import javax.imageio.spi.ImageWriterSpi;
@@ -333,7 +334,7 @@
// flavors to enable dynamic text native-to-flavor mapping generation.
// See SystemFlavorMap.getFlavorsForNative() for details.
if ("image".equals(primaryType)) {
- Iterator readers = ImageIO.getImageReadersByMIMEType(baseType);
+ Iterator<ImageReader> readers = ImageIO.getImageReadersByMIMEType(baseType);
if (readers.hasNext()) {
flavors.add(DataFlavor.imageFlavor);
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDnDDragSourceProtocol.java Mon Apr 28 19:05:49 2014 -0700
@@ -26,6 +26,7 @@
package sun.awt.X11;
import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.DataFlavor;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.InvalidDnDOperationException;
@@ -70,7 +71,7 @@
* @returns true if the initialized successfully.
*/
protected void initializeDragImpl(int actions, Transferable contents,
- Map formatMap, long[] formats)
+ Map<Long, DataFlavor> formatMap, long[] formats)
throws InvalidDnDOperationException,
IllegalArgumentException, XException {
assert XToolkit.isAWTLockHeldByCurrentThread();
--- a/jdk/src/solaris/classes/sun/awt/X11/XDragAndDropProtocols.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDragAndDropProtocols.java Mon Apr 28 19:05:49 2014 -0700
@@ -36,8 +36,8 @@
* @since 1.5
*/
final class XDragAndDropProtocols {
- private final static List dragProtocols;
- private final static List dropProtocols;
+ private final static List<XDragSourceProtocol> dragProtocols;
+ private final static List<XDropTargetProtocol> dropProtocols;
public static final String XDnD = "XDnD";
public static final String MotifDnD = "MotifDnD";
@@ -50,7 +50,7 @@
XDropTargetProtocolListener dropTargetProtocolListener =
XDropTargetContextPeer.getXDropTargetProtocolListener();
- List tDragSourceProtocols = new ArrayList();
+ List<XDragSourceProtocol> tDragSourceProtocols = new ArrayList<>();
XDragSourceProtocol xdndDragSourceProtocol =
XDnDDragSourceProtocol.createInstance(dragSourceProtocolListener);
tDragSourceProtocols.add(xdndDragSourceProtocol);
@@ -58,7 +58,7 @@
MotifDnDDragSourceProtocol.createInstance(dragSourceProtocolListener);
tDragSourceProtocols.add(motifdndDragSourceProtocol);
- List tDropTargetProtocols = new ArrayList();
+ List<XDropTargetProtocol> tDropTargetProtocols = new ArrayList<>();
XDropTargetProtocol xdndDropTargetProtocol =
XDnDDropTargetProtocol.createInstance(dropTargetProtocolListener);
tDropTargetProtocols.add(xdndDropTargetProtocol);
@@ -70,11 +70,11 @@
dropProtocols = Collections.unmodifiableList(tDropTargetProtocols);
}
- static Iterator getDragSourceProtocols() {
+ static Iterator<XDragSourceProtocol> getDragSourceProtocols() {
return dragProtocols.iterator();
}
- static Iterator getDropTargetProtocols() {
+ static Iterator<XDropTargetProtocol> getDropTargetProtocols() {
return dropProtocols.iterator();
}
@@ -88,10 +88,10 @@
return null;
}
- Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
+ Iterator<XDragSourceProtocol> dragProtocols =
+ XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
- XDragSourceProtocol dragProtocol =
- (XDragSourceProtocol)dragProtocols.next();
+ XDragSourceProtocol dragProtocol = dragProtocols.next();
if (dragProtocol.getProtocolName().equals(name)) {
return dragProtocol;
}
@@ -110,10 +110,10 @@
return null;
}
- Iterator dropProtocols = XDragAndDropProtocols.getDropTargetProtocols();
+ Iterator<XDropTargetProtocol> dropProtocols =
+ XDragAndDropProtocols.getDropTargetProtocols();
while (dropProtocols.hasNext()) {
- XDropTargetProtocol dropProtocol =
- (XDropTargetProtocol)dropProtocols.next();
+ XDropTargetProtocol dropProtocol = dropProtocols.next();
if (dropProtocol.getProtocolName().equals(name)) {
return dropProtocol;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDragSourceContextPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -29,6 +29,7 @@
import java.awt.Cursor;
import java.awt.Window;
+import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
@@ -110,7 +111,7 @@
}
protected void startDrag(Transferable transferable,
- long[] formats, Map formatMap) {
+ long[] formats, Map<Long, DataFlavor> formatMap) {
Component component = getTrigger().getComponent();
Component c = null;
XWindowPeer wpeer = null;
@@ -161,9 +162,10 @@
int dropActions = getDragSourceContext().getSourceActions();
- Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
+ Iterator<XDragSourceProtocol> dragProtocols =
+ XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
- XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next();
+ XDragSourceProtocol dragProtocol = dragProtocols.next();
try {
dragProtocol.initializeDrag(dropActions, transferable,
formatMap, formats);
@@ -313,9 +315,10 @@
dragDropFinished(false, DnDConstants.ACTION_NONE, xRoot, yRoot);
}
- Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
+ Iterator<XDragSourceProtocol> dragProtocols =
+ XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
- XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next();
+ XDragSourceProtocol dragProtocol = dragProtocols.next();
try {
dragProtocol.cleanup();
} catch (XException xe) {
@@ -418,9 +421,10 @@
}
if (clientWindow != 0) {
- Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
+ Iterator<XDragSourceProtocol> dragProtocols =
+ XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
- XDragSourceProtocol dragProtocol = (XDragSourceProtocol)dragProtocols.next();
+ XDragSourceProtocol dragProtocol = dragProtocols.next();
if (dragProtocol.attachTargetWindow(clientWindow, time)) {
protocol = dragProtocol;
break;
@@ -550,10 +554,10 @@
XClientMessageEvent xclient = ev.get_xclient();
- Iterator dragProtocols = XDragAndDropProtocols.getDragSourceProtocols();
+ Iterator<XDragSourceProtocol> dragProtocols =
+ XDragAndDropProtocols.getDragSourceProtocols();
while (dragProtocols.hasNext()) {
- XDragSourceProtocol dragProtocol =
- (XDragSourceProtocol)dragProtocols.next();
+ XDragSourceProtocol dragProtocol = dragProtocols.next();
if (dragProtocol.processProxyModeEvent(xclient,
getProxyModeSourceWindow())) {
return true;
--- a/jdk/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDragSourceProtocol.java Mon Apr 28 19:05:49 2014 -0700
@@ -26,6 +26,7 @@
package sun.awt.X11;
import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.DataFlavor;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.InvalidDnDOperationException;
@@ -84,7 +85,7 @@
* @throws XException if some X call failed.
*/
public final void initializeDrag(int actions, Transferable contents,
- Map formatMap, long[] formats)
+ Map<Long, DataFlavor> formatMap, long[] formats)
throws InvalidDnDOperationException,
IllegalArgumentException, XException {
XToolkit.awtLock();
@@ -110,7 +111,8 @@
/* The caller must hold AWT_LOCK. */
protected abstract void initializeDragImpl(int actions,
Transferable contents,
- Map formatMap, long[] formats)
+ Map<Long, DataFlavor> formatMap,
+ long[] formats)
throws InvalidDnDOperationException, IllegalArgumentException, XException;
/**
--- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetContextPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetContextPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -89,12 +89,12 @@
/* If the event was not consumed, send a response to the source. */
try {
if (ctxt != 0 && !e.isConsumed()) {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ dropTargetProtocols.next();
if (dropTargetProtocol.sendResponse(ctxt, e.getID(),
returnValue)) {
break;
@@ -116,12 +116,12 @@
if (ctxt != 0) {
try {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ dropTargetProtocols.next();
if (dropTargetProtocol.sendDropDone(ctxt, success,
dropAction)) {
break;
@@ -140,12 +140,12 @@
long ctxt = getNativeDragContext();
if (ctxt != 0) {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ dropTargetProtocols.next();
// getData throws IAE if ctxt is not for this protocol.
try {
return dropTargetProtocol.getData(ctxt, format);
@@ -221,12 +221,11 @@
public void forwardEventToEmbedded(long embedded, long ctxt,
int eventID) {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
if (dropTargetProtocol.forwardEventToEmbedded(embedded, ctxt,
eventID)) {
break;
--- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetEventProcessor.java Mon Apr 28 19:05:49 2014 -0700
@@ -79,12 +79,11 @@
}
if (protocol == null) {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
// Don't try to process it again with the current protocol.
if (dropTargetProtocol == curProtocol) {
continue;
--- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetProtocol.java Mon Apr 28 19:05:49 2014 -0700
@@ -295,7 +295,8 @@
}
/* Access to HashMap is synchronized on this XDropTargetProtocol instance. */
- private final HashMap embedderRegistry = new HashMap();
+ private final HashMap<Long, EmbedderRegistryEntry> embedderRegistry =
+ new HashMap<>();
protected final void putEmbedderRegistryEntry(long embedder,
boolean overriden,
@@ -310,8 +311,7 @@
protected final EmbedderRegistryEntry getEmbedderRegistryEntry(long embedder) {
synchronized (this) {
- return
- (EmbedderRegistryEntry)embedderRegistry.get(Long.valueOf(embedder));
+ return embedderRegistry.get(Long.valueOf(embedder));
}
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java Mon Apr 28 19:05:49 2014 -0700
@@ -141,10 +141,10 @@
}
public long[] getSites() {
long[] ret = new long[sites.size()];
- Iterator iter = sites.iterator();
+ Iterator<Long> iter = sites.iterator();
int index = 0;
while (iter.hasNext()) {
- Long l = (Long)iter.next();
+ Long l = iter.next();
ret[index++] = l.longValue();
}
return ret;
@@ -199,14 +199,13 @@
private EmbeddedDropSiteEntry registerEmbedderDropSite(long embedder) {
assert XToolkit.isAWTLockHeldByCurrentThread();
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
// The list of protocols supported by the embedder.
- List<XDropTargetProtocol> embedderProtocols = new ArrayList();
+ List<XDropTargetProtocol> embedderProtocols = new ArrayList<>();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
if (dropTargetProtocol.isProtocolSupported(embedder)) {
embedderProtocols.add(dropTargetProtocol);
}
@@ -262,7 +261,7 @@
private void registerProtocols(long embedder, boolean protocols,
List<XDropTargetProtocol> supportedProtocols) {
- Iterator dropTargetProtocols = null;
+ Iterator<XDropTargetProtocol> dropTargetProtocols = null;
/*
* By default, we register a drop site that supports all dnd
@@ -289,8 +288,7 @@
XlibWrapper.XGrabServer(XToolkit.getDisplay());
try {
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
if ((protocols == XEMBED_PROTOCOLS) ==
dropTargetProtocol.isXEmbedSupported()) {
dropTargetProtocol.registerEmbedderDropSite(embedder);
@@ -310,14 +308,13 @@
assert XToolkit.isAWTLockHeldByCurrentThread();
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
// The list of protocols supported by the embedder.
- List<XDropTargetProtocol> embedderProtocols = new ArrayList();
+ List<XDropTargetProtocol> embedderProtocols = new ArrayList<>();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
if (dropTargetProtocol.isProtocolSupported(embedder)) {
embedderProtocols.add(dropTargetProtocol);
}
@@ -361,8 +358,7 @@
XlibWrapper.XGrabServer(XToolkit.getDisplay());
try {
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
if (!isXEmbedServer || !dropTargetProtocol.isXEmbedSupported()) {
dropTargetProtocol.registerEmbedderDropSite(embedder);
}
@@ -376,7 +372,7 @@
EmbeddedDropSiteEntry entry) {
assert XToolkit.isAWTLockHeldByCurrentThread();
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
/* Grab server, since we are working with the window that belongs to
@@ -384,8 +380,7 @@
XlibWrapper.XGrabServer(XToolkit.getDisplay());
try {
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
dropTargetProtocol.unregisterEmbedderDropSite(embedder);
}
@@ -470,14 +465,14 @@
registerProtocols(toplevel, XEMBED_PROTOCOLS,
entry.getSupportedProtocols());
} else {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
// Register the embedded window as a plain drop site with
// all DnD protocols that are supported by XEmbed.
while (dropTargetProtocols.hasNext()) {
XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ dropTargetProtocols.next();
if (dropTargetProtocol.isXEmbedSupported()) {
dropTargetProtocol.registerEmbedderDropSite(window);
}
@@ -558,12 +553,12 @@
}
if (toplevel == window) {
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ dropTargetProtocols.next();
dropTargetProtocol.registerDropTarget(toplevel);
}
} else {
@@ -584,13 +579,13 @@
long toplevel = getToplevelWindow(window);
if (toplevel == window) {
- Iterator dropProtocols =
+ Iterator<XDropTargetProtocol> dropProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
removeDelayedRegistrationEntry(window);
while (dropProtocols.hasNext()) {
- XDropTargetProtocol dropProtocol = (XDropTargetProtocol)dropProtocols.next();
+ XDropTargetProtocol dropProtocol = dropProtocols.next();
dropProtocol.unregisterDropTarget(window);
}
} else {
@@ -615,12 +610,11 @@
}
registerEmbeddedDropSite(canvasWindow, clientWindow);
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
dropTargetProtocol.registerEmbeddedDropSite(clientWindow);
}
@@ -634,12 +628,11 @@
if (logger.isLoggable(PlatformLogger.Level.FINE)) {
logger.fine(" XEmbed drop site will be unregistered for " + Long.toHexString(clientWindow));
}
- Iterator dropTargetProtocols =
+ Iterator<XDropTargetProtocol> dropTargetProtocols =
XDragAndDropProtocols.getDropTargetProtocols();
while (dropTargetProtocols.hasNext()) {
- XDropTargetProtocol dropTargetProtocol =
- (XDropTargetProtocol)dropTargetProtocols.next();
+ XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
dropTargetProtocol.unregisterEmbeddedDropSite(clientWindow);
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java Mon Apr 28 19:05:49 2014 -0700
@@ -32,7 +32,7 @@
import sun.awt.AWTAccessor;
public class XEmbeddingContainer extends XEmbedHelper implements XEventDispatcher {
- HashMap children = new HashMap();
+ HashMap<Long, java.awt.peer.ComponentPeer> children = new HashMap<>();
XEmbeddingContainer() {
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XFileDialogPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -146,9 +146,9 @@
savedDir = target.getDirectory();
// Shouldn't save 'user.dir' to 'savedDir'
// since getDirectory() will be incorrect after handleCancel
- userDir = (String)AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
+ userDir = AccessController.doPrivileged(
+ new PrivilegedAction<String>() {
+ public String run() {
return System.getProperty("user.dir");
}
});
--- a/jdk/src/solaris/classes/sun/awt/X11/XListPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XListPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -70,7 +70,7 @@
ListPainter painter;
// TODO: ick - Vector?
- Vector items;
+ Vector<String> items;
boolean multipleSelections;
int active = NONE;
@@ -139,7 +139,7 @@
super.preInit(params);
// Stuff that must be initialized before layout() is called
- items = new Vector();
+ items = new Vector<>();
createVerScrollbar();
createHorScrollbar();
@@ -281,7 +281,7 @@
int m = 0;
int end = items.size();
for(int i = 0 ; i < end ; i++) {
- int l = fm.stringWidth(((String)items.elementAt(i)));
+ int l = fm.stringWidth(items.elementAt(i));
m = Math.max(m, l);
}
return m;
@@ -292,7 +292,7 @@
*/
int getItemWidth(int i) {
FontMetrics fm = getFontMetrics(getFont());
- return fm.stringWidth((String)items.elementAt(i));
+ return fm.stringWidth(items.elementAt(i));
}
/**
@@ -659,7 +659,7 @@
( clickCount % 2 == 0 ) ) {
postEvent(new ActionEvent(target,
ActionEvent.ACTION_PERFORMED,
- (String)items.elementAt(currentIndex),
+ items.elementAt(currentIndex),
mouseEvent.getWhen(),
mouseEvent.getModifiers())); // No ext mods
} else if (active == WINDOW) {
@@ -986,7 +986,7 @@
if (selected.length > 0) {
postEvent(new ActionEvent((List)target,
ActionEvent.ACTION_PERFORMED,
- (String)items.elementAt(getFocusIndex()),
+ items.elementAt(getFocusIndex()),
e.getWhen(),
e.getModifiers())); // ActionEvent doesn't have
// extended modifiers.
@@ -1343,7 +1343,7 @@
*/
public void clear() {
selected = new int[0];
- items = new Vector();
+ items = new Vector<>();
currentIndex = -1;
// Fixed 6291736: ITEM_STATE_CHANGED triggered after List.removeAll(), XToolkit
// We should update 'focusIndex' variable more carefully
@@ -1926,7 +1926,7 @@
} else {
g.setColor(getListForeground());
}
- String str = (String)items.elementAt(index);
+ String str = items.elementAt(index);
g.drawString(str, x - hsb.getValue(), y + fontAscent);
} else {
// Clear the remaining area around the item - focus area and the rest of border
--- a/jdk/src/solaris/classes/sun/awt/X11/XMSelection.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XMSelection.java Mon Apr 28 19:05:49 2014 -0700
@@ -60,7 +60,7 @@
String selectionName;
/* list of listeners to be called for events */
- Vector listeners;
+ Vector<XMSelectionListener> listeners;
/* X atom array (one per screen) for this selection */
XAtom atoms[];
@@ -75,7 +75,7 @@
static XAtom XA_MANAGER;
- static HashMap selectionMap;
+ static HashMap<Long, XMSelection> selectionMap;
static {
long display = XToolkit.getDisplay();
@@ -90,7 +90,7 @@
initScreen(display,screen);
}
- selectionMap = new HashMap();
+ selectionMap = new HashMap<>();
}
static void initScreen(long display, final int screen) {
@@ -227,7 +227,7 @@
static XMSelection getInstance(long selection) {
- return (XMSelection) selectionMap.get(Long.valueOf(selection));
+ return selectionMap.get(Long.valueOf(selection));
}
@@ -259,7 +259,7 @@
public synchronized void addSelectionListener(XMSelectionListener listener) {
if (listeners == null) {
- listeners = new Vector();
+ listeners = new Vector<>();
}
listeners.add(listener);
}
@@ -270,7 +270,7 @@
}
}
- synchronized Collection getListeners() {
+ synchronized Collection<XMSelectionListener> getListeners() {
return listeners;
}
@@ -310,9 +310,9 @@
log.fine("Selection Changed : Screen = " + screen + "Event =" + ev);
}
if (listeners != null) {
- Iterator iter = listeners.iterator();
+ Iterator<XMSelectionListener> iter = listeners.iterator();
while (iter.hasNext()) {
- XMSelectionListener disp = (XMSelectionListener) iter.next();
+ XMSelectionListener disp = iter.next();
disp.selectionChanged(screen, this, ev.get_window(), ev);
}
}
@@ -323,9 +323,9 @@
log.fine("Owner dead : Screen = " + screen + "Event =" + de);
}
if (listeners != null) {
- Iterator iter = listeners.iterator();
+ Iterator<XMSelectionListener> iter = listeners.iterator();
while (iter.hasNext()) {
- XMSelectionListener disp = (XMSelectionListener) iter.next();
+ XMSelectionListener disp = iter.next();
disp.ownerDeath(screen, this, de.get_window());
}
@@ -349,9 +349,9 @@
synchronized void dispatchOwnerChangedEvent(XEvent ev, int screen, long owner, long data, long timestamp) {
if (listeners != null) {
- Iterator iter = listeners.iterator();
+ Iterator<XMSelectionListener> iter = listeners.iterator();
while (iter.hasNext()) {
- XMSelectionListener disp = (XMSelectionListener) iter.next();
+ XMSelectionListener disp = iter.next();
disp.ownerChanged(screen,this, owner, data, timestamp);
}
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -195,10 +195,10 @@
void postInit(XCreateWindowParams params) {
super.postInit(params);
// Get menus from the target.
- Vector targetMenuVector = AWTAccessor.getMenuBarAccessor()
- .getMenus(menuBarTarget);
+ Vector<Menu> targetMenuVector = AWTAccessor.getMenuBarAccessor()
+ .getMenus(menuBarTarget);
Menu targetHelpMenu = AWTAccessor.getMenuBarAccessor()
- .getHelpMenu(menuBarTarget);
+ .getHelpMenu(menuBarTarget);
reloadItems(targetMenuVector);
if (targetHelpMenu != null) {
addHelpMenu(targetHelpMenu);
--- a/jdk/src/solaris/classes/sun/awt/X11/XMenuPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -143,7 +143,7 @@
* Access to target's fields
*
************************************************/
- Vector getTargetItems() {
+ Vector<MenuItem> getTargetItems() {
return AWTAccessor.getMenuAccessor().getItems((Menu)getTarget());
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XMenuWindow.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuWindow.java Mon Apr 28 19:05:49 2014 -0700
@@ -164,7 +164,7 @@
this.menuPeer = menuPeer;
this.target = menuPeer.getContainer().target;
// Get menus from the target.
- Vector targetItemVector = null;
+ Vector<MenuItem> targetItemVector = null;
targetItemVector = getMenuTargetItems();
reloadItems(targetItemVector);
}
@@ -356,7 +356,7 @@
* Reads vector of items from target
* This function is overriden in XPopupMenuPeer
*/
- Vector getMenuTargetItems() {
+ Vector<MenuItem> getMenuTargetItems() {
return menuPeer.getTargetItems();
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -134,7 +134,7 @@
public void show(Event e) {
target = (Component)e.target;
// Get menus from the target.
- Vector targetItemVector = getMenuTargetItems();
+ Vector<MenuItem> targetItemVector = getMenuTargetItems();
if (targetItemVector != null) {
reloadItems(targetItemVector);
//Fix for 6287092: JCK15a: api/java_awt/interactive/event/EventTests.html#EventTest0015 fails, mustang
@@ -188,7 +188,7 @@
return AWTAccessor.getMenuItemAccessor().isEnabled(popupMenuTarget);
}
- Vector getMenuTargetItems() {
+ Vector<MenuItem> getMenuTargetItems() {
if (popupMenuTarget == null) {
return null;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XSelection.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XSelection.java Mon Apr 28 19:05:49 2014 -0700
@@ -25,6 +25,7 @@
package sun.awt.X11;
+import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.io.ByteArrayOutputStream;
@@ -87,7 +88,7 @@
/* The contents supplied by the current owner. */
private Transferable contents = null;
/* The format-to-flavor map for the current owner. */
- private Map formatMap = null;
+ private Map<Long, DataFlavor> formatMap = null;
/* The formats supported by the current owner was set. */
private long[] formats = null;
/* The AppContext in which the current owner was set. */
@@ -134,7 +135,8 @@
return selectionAtom;
}
- public synchronized boolean setOwner(Transferable contents, Map formatMap,
+ public synchronized boolean setOwner(Transferable contents,
+ Map<Long, DataFlavor> formatMap,
long[] formats, long time)
{
long owner = XWindow.getXAWTRootWindow().getWindow();
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Mon Apr 28 19:05:49 2014 -0700
@@ -36,6 +36,7 @@
import java.awt.dnd.MouseDragGestureRecognizer;
import java.awt.dnd.InvalidDnDOperationException;
import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.font.TextAttribute;
import java.awt.im.InputMethodHighlight;
import java.awt.im.spi.InputMethodDescriptor;
import java.awt.image.ColorModel;
@@ -99,9 +100,9 @@
private FontConfigManager fcManager = new FontConfigManager();
static int arrowCursor;
- static TreeMap winMap = new TreeMap();
- static HashMap specialPeerMap = new HashMap();
- static HashMap winToDispatcher = new HashMap();
+ static TreeMap<Long, XBaseWindow> winMap = new TreeMap<>();
+ static HashMap<Object, Object> specialPeerMap = new HashMap<>();
+ static HashMap<Long, Collection<XEventDispatcher>> winToDispatcher = new HashMap<>();
private static long _display;
static UIDefaults uidefaults;
static X11GraphicsEnvironment localEnv;
@@ -358,16 +359,16 @@
}
static XBaseWindow windowToXWindow(long window) {
synchronized(winMap) {
- return (XBaseWindow) winMap.get(Long.valueOf(window));
+ return winMap.get(Long.valueOf(window));
}
}
static void addEventDispatcher(long window, XEventDispatcher dispatcher) {
synchronized(winToDispatcher) {
Long key = Long.valueOf(window);
- Collection dispatchers = (Collection)winToDispatcher.get(key);
+ Collection<XEventDispatcher> dispatchers = winToDispatcher.get(key);
if (dispatchers == null) {
- dispatchers = new Vector();
+ dispatchers = new Vector<>();
winToDispatcher.put(key, dispatchers);
}
dispatchers.add(dispatcher);
@@ -376,7 +377,7 @@
static void removeEventDispatcher(long window, XEventDispatcher dispatcher) {
synchronized(winToDispatcher) {
Long key = Long.valueOf(window);
- Collection dispatchers = (Collection)winToDispatcher.get(key);
+ Collection<XEventDispatcher> dispatchers = winToDispatcher.get(key);
if (dispatchers != null) {
dispatchers.remove(dispatcher);
}
@@ -493,18 +494,18 @@
}
XBaseWindow.dispatchToWindow(ev);
- Collection dispatchers = null;
+ Collection<XEventDispatcher> dispatchers = null;
synchronized(winToDispatcher) {
Long key = Long.valueOf(xany.get_window());
- dispatchers = (Collection)winToDispatcher.get(key);
+ dispatchers = winToDispatcher.get(key);
if (dispatchers != null) { // Clone it to avoid synchronization during dispatching
- dispatchers = new Vector(dispatchers);
+ dispatchers = new Vector<>(dispatchers);
}
}
if (dispatchers != null) {
- Iterator iter = dispatchers.iterator();
+ Iterator<XEventDispatcher> iter = dispatchers.iterator();
while (iter.hasNext()) {
- XEventDispatcher disp = (XEventDispatcher)iter.next();
+ XEventDispatcher disp = iter.next();
disp.dispatchEvent(ev);
}
}
@@ -764,7 +765,7 @@
Insets insets = new Insets(0, 0, 0, 0);
- java.util.List search = new LinkedList();
+ java.util.List<Object> search = new LinkedList<>();
search.add(root);
search.add(0);
while (!search.isEmpty())
@@ -929,6 +930,7 @@
return XDragSourceContextPeer.createDragSourceContextPeer(dge);
}
+ @SuppressWarnings("unchecked")
public <T extends DragGestureRecognizer> T
createDragGestureRecognizer(Class<T> recognizerClass,
DragSource ds,
@@ -1147,7 +1149,7 @@
return 2; // Black and white.
}
- public Map mapInputMethodHighlight(InputMethodHighlight highlight) {
+ public Map<TextAttribute, ?> mapInputMethodHighlight( InputMethodHighlight highlight) {
return XInputMethod.mapInputMethodHighlight(highlight);
}
@Override
@@ -1338,31 +1340,25 @@
static void dumpPeers() {
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine("Mapped windows:");
- Iterator iter = winMap.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- log.fine(entry.getKey() + "->" + entry.getValue());
- if (entry.getValue() instanceof XComponentPeer) {
- Component target = (Component)((XComponentPeer)entry.getValue()).getTarget();
+ winMap.forEach((k, v) -> {
+ log.fine(k + "->" + v);
+ if (v instanceof XComponentPeer) {
+ Component target = (Component)((XComponentPeer)v).getTarget();
log.fine("\ttarget: " + target);
}
- }
+ });
SunToolkit.dumpPeers(log);
log.fine("Mapped special peers:");
- iter = specialPeerMap.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- log.fine(entry.getKey() + "->" + entry.getValue());
- }
+ specialPeerMap.forEach((k, v) -> {
+ log.fine(k + "->" + v);
+ });
log.fine("Mapped dispatchers:");
- iter = winToDispatcher.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- log.fine(entry.getKey() + "->" + entry.getValue());
- }
+ winToDispatcher.forEach((k, v) -> {
+ log.fine(k + "->" + v);
+ });
}
}
@@ -1586,16 +1582,16 @@
* <code>loadXSettings</code>. It is called from the System EDT
* if triggered by an XSETTINGS change.
*/
- void parseXSettings(int screen_XXX_ignored,Map updatedSettings) {
+ void parseXSettings(int screen_XXX_ignored,Map<String, Object> updatedSettings) {
if (updatedSettings == null || updatedSettings.isEmpty()) {
return;
}
- Iterator i = updatedSettings.entrySet().iterator();
+ Iterator<Map.Entry<String, Object>> i = updatedSettings.entrySet().iterator();
while (i.hasNext()) {
- Map.Entry e = (Map.Entry)i.next();
- String name = (String)e.getKey();
+ Map.Entry<String, Object> e = i.next();
+ String name = e.getKey();
name = "gnome." + name;
setDesktopProperty(name, e.getValue());
@@ -1692,7 +1688,7 @@
long window = 0;
try{
// get any application window
- window = ((Long)(winMap.firstKey())).longValue();
+ window = winMap.firstKey().longValue();
}catch(NoSuchElementException nex) {
// get root window
window = getDefaultRootWindow();
@@ -1798,7 +1794,7 @@
}
- private static SortedMap timeoutTasks;
+ private static SortedMap<Long, java.util.List<Runnable>> timeoutTasks;
/**
* Removed the task from the list of waiting-to-be called tasks.
@@ -1819,10 +1815,10 @@
}
return;
}
- Collection values = timeoutTasks.values();
- Iterator iter = values.iterator();
+ Collection<java.util.List<Runnable>> values = timeoutTasks.values();
+ Iterator<java.util.List<Runnable>> iter = values.iterator();
while (iter.hasNext()) {
- java.util.List list = (java.util.List)iter.next();
+ java.util.List<Runnable> list = iter.next();
boolean removed = false;
if (list.contains(task)) {
list.remove(task);
@@ -1869,13 +1865,13 @@
}
if (timeoutTasks == null) {
- timeoutTasks = new TreeMap();
+ timeoutTasks = new TreeMap<>();
}
Long time = Long.valueOf(System.currentTimeMillis() + interval);
- java.util.List tasks = (java.util.List)timeoutTasks.get(time);
+ java.util.List<Runnable> tasks = timeoutTasks.get(time);
if (tasks == null) {
- tasks = new ArrayList(1);
+ tasks = new ArrayList<>(1);
timeoutTasks.put(time, tasks);
}
tasks.add(task);
@@ -1897,7 +1893,7 @@
if (timeoutTasks == null || timeoutTasks.isEmpty()) {
return -1L;
}
- return (Long)timeoutTasks.firstKey();
+ return timeoutTasks.firstKey();
} finally {
awtUnlock();
}
@@ -1918,13 +1914,13 @@
}
Long currentTime = Long.valueOf(System.currentTimeMillis());
- Long time = (Long)timeoutTasks.firstKey();
+ Long time = timeoutTasks.firstKey();
while (time.compareTo(currentTime) <= 0) {
- java.util.List tasks = (java.util.List)timeoutTasks.remove(time);
+ java.util.List<Runnable> tasks = timeoutTasks.remove(time);
- for (Iterator iter = tasks.iterator(); iter.hasNext();) {
- Runnable task = (Runnable)iter.next();
+ for (Iterator<Runnable> iter = tasks.iterator(); iter.hasNext();) {
+ Runnable task = iter.next();
if (timeoutTaskLog.isLoggable(PlatformLogger.Level.FINER)) {
timeoutTaskLog.finer("XToolkit.callTimeoutTasks(): current time={0}" +
@@ -1943,7 +1939,7 @@
if (timeoutTasks.isEmpty()) {
break;
}
- time = (Long)timeoutTasks.firstKey();
+ time = timeoutTasks.firstKey();
}
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -85,7 +85,7 @@
// Fix for 6317038: as EmbeddedFrame is instance of Frame, it is blocked
// by modal dialogs, but in the case of TrayIcon it shouldn't. So we
// set ModalExclusion property on it.
- AccessController.doPrivileged(new PrivilegedAction() {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
eframe.setModalExclusionType(Dialog.ModalExclusionType.TOOLKIT_EXCLUDE);
return null;
--- a/jdk/src/solaris/classes/sun/awt/X11/XWM.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWM.java Mon Apr 28 19:05:49 2014 -0700
@@ -1072,6 +1072,7 @@
* Returns all protocols supporting given protocol interface
*/
<T> Collection<T> getProtocols(Class<T> protocolInterface) {
+ @SuppressWarnings("unchecked")
Collection<T> res = (Collection<T>) protocolsMap.get(protocolInterface);
if (res != null) {
return res;
@@ -1322,9 +1323,9 @@
}
}
- HashMap storedInsets = new HashMap();
+ HashMap<Class<?>, Insets> storedInsets = new HashMap<>();
Insets guessInsets(XDecoratedPeer window) {
- Insets res = (Insets)storedInsets.get(window.getClass());
+ Insets res = storedInsets.get(window.getClass());
if (res == null) {
switch (WMID) {
case ENLIGHTEN_WM:
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindow.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindow.java Mon Apr 28 19:05:49 2014 -0700
@@ -59,7 +59,7 @@
static int lastX = 0, lastY = 0;
static long lastTime = 0;
static long lastButton = 0;
- static WeakReference lastWindowRef = null;
+ static WeakReference<XWindow> lastWindowRef = null;
static int clickCount = 0;
// used to check if we need to re-create surfaceData.
@@ -692,7 +692,7 @@
if (type == XConstants.ButtonPress) {
//Allow this mouse button to generate CLICK event on next ButtonRelease
mouseButtonClickAllowed |= XlibUtil.getButtonMask(lbutton);
- XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
+ XWindow lastWindow = (lastWindowRef != null) ? (lastWindowRef.get()):(null);
/*
multiclick checking
*/
@@ -705,7 +705,7 @@
clickCount++;
} else {
clickCount = 1;
- lastWindowRef = new WeakReference(this);
+ lastWindowRef = new WeakReference<>(this);
lastButton = lbutton;
lastX = x;
lastY = y;
@@ -820,7 +820,7 @@
*/
int x = xme.get_x();
int y = xme.get_y();
- XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
+ XWindow lastWindow = (lastWindowRef != null) ? (lastWindowRef.get()):(null);
if (!(lastWindow == this &&
(xme.get_time() - lastTime) < XToolkit.getMultiClickTime() &&
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Mon Apr 28 19:05:49 2014 -0700
@@ -950,7 +950,7 @@
// make new hash of toplevels of all windows from 'windows' hash.
// FIXME: do not call them "toplevel" as it is misleading.
//
- HashSet toplevels = new HashSet();
+ HashSet<Long> toplevels = new HashSet<>();
long topl = 0, mytopl = 0;
for (XWindowPeer xp : windows) {
--- a/jdk/src/solaris/classes/sun/awt/X11CustomCursor.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11CustomCursor.java Mon Apr 28 19:05:49 2014 -0700
@@ -47,7 +47,7 @@
protected void createNativeCursor(Image im, int[] pixels, int width, int height,
int xHotSpot, int yHotSpot) {
- class CCount implements Comparable {
+ class CCount implements Comparable<CCount> {
int color;
int count;
@@ -56,8 +56,8 @@
count = ct;
}
- public int compareTo(Object cc) {
- return ((CCount)cc).count - count;
+ public int compareTo(CCount cc) {
+ return cc.count - count;
}
}
--- a/jdk/src/solaris/classes/sun/awt/X11FontManager.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11FontManager.java Mon Apr 28 19:05:49 2014 -0700
@@ -59,7 +59,7 @@
* E.g., the -0-0-0-0-p-0- reported by X is -*-%d-*-*-p-*- in the font
* configuration files. We need to remove that part for comparisons.
*/
- private static Map fontNameMap = new HashMap();
+ private static Map<String, String> fontNameMap = new HashMap<>();
/*
* xlfdMap is a map from a platform path like
@@ -72,7 +72,7 @@
* the full XLFD string like :-
* "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0"
*/
- private static Map xlfdMap = new HashMap();
+ private static Map<String, Vector<String>> xlfdMap = new HashMap<>();
/* xFontDirsMap is also a map from a font ID to a font filepath.
* The difference from fontNameMap is just that it does not have
@@ -88,7 +88,7 @@
* X11 font directory, then precautions must be taken to include both
* directories.
*/
- private static Map xFontDirsMap;
+ private static Map<String, String> xFontDirsMap;
/*
* This is the set of font directories needed to be on the X font path
@@ -121,7 +121,7 @@
* of the singleton GE instance is already synchronised and that is
* the only code path that accesses this map.
*/
- private static HashMap registeredDirs = new HashMap();
+ private static HashMap<String, Object> registeredDirs = new HashMap<>();
/* Array of directories to be added to the X11 font path.
* Used by static method called from Toolkits which use X11 fonts.
@@ -183,7 +183,7 @@
* Add this XLFD (platform name) to the list of known
* ones for this file.
*/
- Vector xVal = (Vector) xlfdMap.get(fileName);
+ Vector<String> xVal = xlfdMap.get(fileName);
if (xVal == null) {
/* Try to be robust on Linux distros which move fonts
* around by verifying that the fileName represents a
@@ -194,7 +194,7 @@
fileName = null;
}
if (fileName != null) {
- xVal = new Vector();
+ xVal = new Vector<>();
xVal.add(platName);
xlfdMap.put(fileName, xVal);
}
@@ -211,7 +211,7 @@
}
if (fontID != null) {
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
/* On Linux check for the Lucida Oblique fonts */
if (fileName == null && FontUtilities.isLinux && !isOpenJDK()) {
if (oblmap == null) {
@@ -235,7 +235,7 @@
FontUtilities.getLogger()
.warning("** Finished registering all font paths");
}
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
}
if (fileName == null && !isHeadless()) {
/* Query X11 directly to see if this font is available
@@ -245,7 +245,7 @@
}
if (fileName == null) {
fontID = switchFontIDForName(platName);
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
}
if (fileName != null) {
fontNameMap.put(fontID, fileName);
@@ -257,8 +257,8 @@
@Override
protected String[] getNativeNames(String fontFileName,
String platformName) {
- Vector nativeNames;
- if ((nativeNames=(Vector)xlfdMap.get(fontFileName))==null) {
+ Vector<String> nativeNames;
+ if ((nativeNames=xlfdMap.get(fontFileName))==null) {
if (platformName == null) {
return null;
} else {
@@ -271,7 +271,7 @@
}
} else {
int len = nativeNames.size();
- return (String[])nativeNames.toArray(new String[len]);
+ return nativeNames.toArray(new String[len]);
}
}
@@ -366,7 +366,7 @@
}
String fontPart = st.sval.substring(breakPos+1);
String fontID = specificFontIDForName(fontPart);
- String sVal = (String) fontNameMap.get(fontID);
+ String sVal = fontNameMap.get(fontID);
if (FontUtilities.debugFonts()) {
PlatformLogger logger = FontUtilities.getLogger();
@@ -386,14 +386,14 @@
* wants to use the native rasteriser.
*/
if (xFontDirsMap == null) {
- xFontDirsMap = new HashMap();
+ xFontDirsMap = new HashMap<>();
}
xFontDirsMap.put(fontID, path);
fullPath = file.getCanonicalPath();
} catch (IOException e) {
fullPath = path + File.separator + fileName;
}
- Vector xVal = (Vector) xlfdMap.get(fullPath);
+ Vector<String> xVal = xlfdMap.get(fullPath);
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.info("fullPath=" + fullPath +
@@ -408,7 +408,7 @@
}
fontNameMap.put(fontID, fullPath);
if (xVal == null) {
- xVal = new Vector();
+ xVal = new Vector<>();
xlfdMap.put (fullPath, xVal);
}
xVal.add(fontPart);
@@ -447,8 +447,8 @@
* will typically not ever need to initialise it so it can be null.
*/
xFontDirsMap = null;
- xlfdMap = new HashMap(1);
- fontNameMap = new HashMap(1);
+ xlfdMap = new HashMap<>(1);
+ fontNameMap = new HashMap<>(1);
}
private String getObliqueLucidaFontID(String fontID) {
@@ -579,10 +579,10 @@
String fileName = null;
String fontID = specificFontIDForName(name);
if (fontID != null) {
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
if (fileName == null) {
fontID = switchFontIDForName(name);
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
}
if (fileName == null) {
fileName = getDefaultFontFile();
@@ -685,7 +685,7 @@
getPlatformFontPathFromFontConfig();
if (xFontDirsMap != null) {
String fontID = specificFontIDForName(platformName);
- String dirName = (String)xFontDirsMap.get(fontID);
+ String dirName = xFontDirsMap.get(fontID);
if (dirName != null) {
fontConfigDirs.add(dirName);
}
--- a/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java Mon Apr 28 19:05:49 2014 -0700
@@ -56,7 +56,7 @@
implements DisplayChangedListener
{
int screen;
- HashMap x11ProxyKeyMap = new HashMap();
+ HashMap<SurfaceType, Object> x11ProxyKeyMap = new HashMap<>();
private static AWTPermission fullScreenExclusivePermission;
private static Boolean xrandrExtSupported;
@@ -127,7 +127,7 @@
GraphicsConfiguration[] configs;
GraphicsConfiguration defaultConfig;
- HashSet doubleBufferVisuals;
+ HashSet<Integer> doubleBufferVisuals;
/**
* Returns all of the graphics
@@ -159,7 +159,7 @@
boolean dbeSupported = isDBESupported();
if (dbeSupported && doubleBufferVisuals == null) {
- doubleBufferVisuals = new HashSet();
+ doubleBufferVisuals = new HashSet<>();
getDoubleBufferVisuals(screen);
}
for ( ; i < num; i++) {
@@ -249,7 +249,7 @@
int depth = getConfigDepth(0, screen);
boolean doubleBuffer = false;
if (isDBESupported() && doubleBufferVisuals == null) {
- doubleBufferVisuals = new HashSet();
+ doubleBufferVisuals = new HashSet<>();
getDoubleBufferVisuals(screen);
doubleBuffer =
doubleBufferVisuals.contains(Integer.valueOf(visNum));
--- a/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java Mon Apr 28 19:05:49 2014 -0700
@@ -72,7 +72,7 @@
static {
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
+ new java.security.PrivilegedAction<Object>() {
public Object run() {
System.loadLibrary("awt");
@@ -254,12 +254,12 @@
return true;
}
- Boolean result = (Boolean)java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Object run() {
+ Boolean result = java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction<Boolean>() {
+ public Boolean run() {
InetAddress remAddr[] = null;
- Enumeration locals = null;
- Enumeration interfaces = null;
+ Enumeration<InetAddress> locals = null;
+ Enumeration<NetworkInterface> interfaces = null;
try {
interfaces = NetworkInterface.getNetworkInterfaces();
remAddr = InetAddress.getAllByName(hostName);
@@ -275,7 +275,7 @@
}
for (; interfaces.hasMoreElements();) {
- locals = ((NetworkInterface)interfaces.nextElement()).getInetAddresses();
+ locals = interfaces.nextElement().getInetAddresses();
for (; locals.hasMoreElements();) {
for (int i = 0; i < remAddr.length; i++) {
if (locals.nextElement().equals(remAddr[i])) {
--- a/jdk/src/solaris/classes/sun/awt/X11InputMethod.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11InputMethod.java Mon Apr 28 19:05:49 2014 -0700
@@ -100,7 +100,7 @@
private boolean isLastTemporary = false;
private boolean isActive = false;
private boolean isActiveClient = false;
- private static Map[] highlightStyles;
+ private static Map<TextAttribute, ?>[] highlightStyles;
private boolean disposed = false;
//reset the XIC if necessary
@@ -136,31 +136,29 @@
// Initialize highlight mapping table
static {
- Map styles[] = new Map[4];
- HashMap map;
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ Map<TextAttribute, ?> styles[] = new Map[4];
+ HashMap<TextAttribute, Object> map;
// UNSELECTED_RAW_TEXT_HIGHLIGHT
- map = new HashMap(1);
- map.put(TextAttribute.WEIGHT,
- TextAttribute.WEIGHT_BOLD);
+ map = new HashMap<>(1);
+ map.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
styles[0] = Collections.unmodifiableMap(map);
// SELECTED_RAW_TEXT_HIGHLIGHT
- map = new HashMap(1);
- map.put(TextAttribute.SWAP_COLORS,
- TextAttribute.SWAP_COLORS_ON);
+ map = new HashMap<>(1);
+ map.put(TextAttribute.SWAP_COLORS, TextAttribute.SWAP_COLORS_ON);
styles[1] = Collections.unmodifiableMap(map);
// UNSELECTED_CONVERTED_TEXT_HIGHLIGHT
- map = new HashMap(1);
+ map = new HashMap<>(1);
map.put(TextAttribute.INPUT_METHOD_UNDERLINE,
- TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
+ TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
styles[2] = Collections.unmodifiableMap(map);
// SELECTED_CONVERTED_TEXT_HIGHLIGHT
- map = new HashMap(1);
- map.put(TextAttribute.SWAP_COLORS,
- TextAttribute.SWAP_COLORS_ON);
+ map = new HashMap<>(1);
+ map.put(TextAttribute.SWAP_COLORS, TextAttribute.SWAP_COLORS_ON);
styles[3] = Collections.unmodifiableMap(map);
highlightStyles = styles;
@@ -433,7 +431,7 @@
/**
* @see java.awt.Toolkit#mapInputMethodHighlight
*/
- public static Map mapInputMethodHighlight(InputMethodHighlight highlight) {
+ public static Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight) {
int index;
int state = highlight.getState();
if (state == InputMethodHighlight.RAW_TEXT) {
--- a/jdk/src/solaris/classes/sun/awt/XSettings.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/XSettings.java Mon Apr 28 19:05:49 2014 -0700
@@ -52,7 +52,7 @@
* settings manager.
* @return a <code>Map</code> of changed settings.
*/
- public Map update(byte[] data) {
+ public Map<String, Object> update(byte[] data) {
return (new Update(data)).update();
}
@@ -79,7 +79,7 @@
private int nsettings = 0;
private boolean isValid;
- private HashMap updatedSettings;
+ private HashMap<String, Object> updatedSettings;
/**
@@ -113,7 +113,7 @@
idx = 8;
nsettings = getINT32();
- updatedSettings = new HashMap();
+ updatedSettings = new HashMap<>();
isValid = true;
}
@@ -213,7 +213,7 @@
/**
* Update settings.
*/
- public Map update() {
+ public Map<String, Object> update() {
if (!isValid) {
return null;
}
--- a/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java Mon Apr 28 11:03:52 2014 -0700
+++ b/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java Mon Apr 28 19:05:49 2014 -0700
@@ -67,7 +67,7 @@
* the fontconfig files.
*/
protected void initReorderMap() {
- reorderMap = new HashMap();
+ reorderMap = new HashMap<>();
if (osName == null) { /* null means SunOS */
initReorderMapForSolaris();
} else {
@@ -240,7 +240,7 @@
return "sun.awt.Symbol";
}
}
- String encoding = (String) encodingMap.get(xlfdEncoding);
+ String encoding = encodingMap.get(xlfdEncoding);
if (encoding == null) {
encoding = "default";
}
@@ -288,7 +288,7 @@
/* methods for table setup ***********************************************/
- private static HashMap encodingMap = new HashMap();
+ private static HashMap<String, String> encodingMap = new HashMap<>();
private void initTables() {
// encodingMap maps XLFD encoding component to