8039642: Fix raw and unchecked warnings in sun.awt.*

Reviewed-by: darcy, prr, flar
This commit is contained in:
Henry Jen 2014-04-28 19:05:49 -07:00
parent c7f7685c50
commit cb91afdb8c
72 changed files with 452 additions and 437 deletions

View File

@ -66,7 +66,7 @@ public class Menu extends MenuItem implements MenuContainer, Accessible {
AWTAccessor.setMenuAccessor(
new AWTAccessor.MenuAccessor() {
public Vector<MenuComponent> getItems(Menu menu) {
public Vector<MenuItem> getItems(Menu menu) {
return menu.items;
}
});
@ -78,7 +78,7 @@ public class Menu extends MenuItem implements MenuContainer, Accessible {
* @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 @@ public class Menu extends MenuItem implements MenuContainer, Accessible {
* be called on the toolkit thread.
*/
final MenuItem getItemImpl(int index) {
return (MenuItem)items.elementAt(index);
return items.elementAt(index);
}
/**
@ -544,7 +544,7 @@ public class Menu extends MenuItem implements MenuContainer, Accessible {
// 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;
}
}

View File

@ -621,7 +621,7 @@ public final class AWTAccessor {
/**
* Returns menus
*/
Vector getMenus(MenuBar menuBar);
Vector<Menu> getMenus(MenuBar menuBar);
}
/**
@ -663,7 +663,7 @@ public final class AWTAccessor {
/**
* Returns vector of the items that are part of the Menu
*/
Vector getItems(Menu menu);
Vector<MenuItem> getItems(Menu menu);
}
/**

View File

@ -890,6 +890,7 @@ public final class AppContext {
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();

View File

@ -64,7 +64,7 @@ public abstract class FontConfiguration {
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 @@ public abstract class FontConfiguration {
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 @@ public abstract class FontConfiguration {
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 @@ public abstract class FontConfiguration {
/* 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 @@ public abstract class FontConfiguration {
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 @@ public abstract class FontConfiguration {
}
}
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 @@ public abstract class FontConfiguration {
}
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 @@ public abstract class FontConfiguration {
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 @@ public abstract class FontConfiguration {
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 @@ public abstract class FontConfiguration {
//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 @@ public abstract class FontConfiguration {
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])) {

View File

@ -214,7 +214,8 @@ public class HToolkit extends SunToolkit
throw new HeadlessException();
}
public Map mapInputMethodHighlight(InputMethodHighlight highlight)
public Map<java.awt.font.TextAttribute, ?> mapInputMethodHighlight(
InputMethodHighlight highlight)
throws HeadlessException {
throw new HeadlessException();
}

View File

@ -29,6 +29,7 @@ import java.awt.*;
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 @@ public class HeadlessToolkit extends Toolkit
throw new HeadlessException();
}
public Map mapInputMethodHighlight(InputMethodHighlight highlight)
public Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight)
throws HeadlessException {
throw new HeadlessException();
}

View File

@ -143,7 +143,7 @@ public abstract class PlatformFont implements FontPeer {
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 @@ public abstract class PlatformFont implements FontPeer {
}
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 @@ public abstract class PlatformFont implements FontPeer {
}
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;
}

View File

@ -1915,6 +1915,7 @@ public abstract class SunToolkit extends Toolkit
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 abstract class SunToolkit extends Toolkit
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;

View File

@ -324,7 +324,7 @@ public abstract class DataTransferer {
return false;
}
Class rep_class = flavor.getRepresentationClass();
Class<?> rep_class = flavor.getRepresentationClass();
if (flavor.isRepresentationClassReader() ||
String.class.equals(rep_class) ||
@ -696,7 +696,7 @@ public abstract class DataTransferer {
* 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 @@ search:
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 @@ search:
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 @@ search:
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 @@ search:
* 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 @@ search:
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 @@ search:
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 @@ search:
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 @@ search:
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 @@ search:
String mimeType)
throws IOException {
Iterator writerIterator = ImageIO.getImageWritersByMIMEType(mimeType);
Iterator<ImageWriter> writerIterator =
ImageIO.getImageWritersByMIMEType(mimeType);
ImageTypeSpecifier typeSpecifier =
new ImageTypeSpecifier(renderedImage);
@ -1986,7 +1989,7 @@ search:
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 @@ search:
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 @@ search:
}
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 @@ search:
} 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 @@ search:
* 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 @@ search:
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

View File

@ -78,7 +78,7 @@ public abstract class SunClipboard extends Clipboard
* 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 @@ public abstract class SunClipboard extends Clipboard
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 @@ public abstract class SunClipboard extends Clipboard
* this clipboard
*/
public void checkChange(long[] formats) {
Set prevDataFlavors = currentDataFlavors;
Set<DataFlavor> prevDataFlavors = currentDataFlavors;
currentDataFlavors = formatArrayAsDataFlavorSet(formats);
if (Objects.equals(prevDataFlavors, currentDataFlavors)) {

View File

@ -111,9 +111,9 @@ final class ClassLoaderObjectOutputStream extends ObjectOutputStream {
}
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 @@ final class ClassLoaderObjectOutputStream extends ObjectOutputStream {
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 @@ final class ClassLoaderObjectOutputStream extends ObjectOutputStream {
}
Map<Set<String>, ClassLoader> getClassLoaderMap() {
return new HashMap(map);
return new HashMap<>(map);
}
}
@ -191,9 +191,9 @@ final class ClassLoaderObjectInputStream extends ObjectInputStream {
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()) {

View File

@ -146,7 +146,7 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer
}
protected abstract void startDrag(Transferable trans,
long[] formats, Map formatMap);
long[] formats, Map<Long, DataFlavor> formatMap);
/**
* set cursor

View File

@ -252,11 +252,11 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
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 @@ public abstract class SunDropTargetContextPeer implements DropTargetContextPeer,
// 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();

View File

@ -152,36 +152,36 @@ public abstract class AreaOp {
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 @@ public abstract class AreaOp {
}
};
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 @@ public abstract class AreaOp {
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 @@ public abstract class AreaOp {
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 @@ public abstract class AreaOp {
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 @@ public abstract class AreaOp {
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 @@ public abstract class AreaOp {
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;

View File

@ -77,14 +77,14 @@ public abstract class Crossings {
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 @@ public abstract class Crossings {
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 @@ public abstract class Crossings {
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 @@ public abstract class Crossings {
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;
}

View File

@ -38,11 +38,11 @@ public abstract class Curve {
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 abstract class Curve {
}
}
public static void insertQuad(Vector curves,
public static void insertQuad(Vector<Curve> curves,
double x0, double y0,
double coords[])
{
@ -82,7 +82,7 @@ public abstract class Curve {
}
}
public static void insertCubic(Vector curves,
public static void insertCubic(Vector<Curve> curves,
double x0, double y0,
double coords[])
{

View File

@ -47,7 +47,7 @@ final class Order2 extends Curve {
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 @@ final class Order2 extends Curve {
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,

View File

@ -53,7 +53,7 @@ final class Order3 extends Curve {
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 @@ final class Order3 extends Curve {
}
}
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,

View File

@ -51,7 +51,7 @@ public class BufImgSurfaceData extends SurfaceData {
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;

View File

@ -61,7 +61,7 @@ public class GifImageDecoder extends ImageDecoder {
int trans_pixel = -1;
IndexColorModel global_model;
Hashtable props = new Hashtable();
Hashtable<String, Object> props = new Hashtable<>();
byte[] saved_image;
IndexColorModel saved_model;

View File

@ -83,7 +83,7 @@ public abstract class ImageDecoder {
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 @@ public abstract class ImageDecoder {
source.doneDecoding(this);
close();
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
new java.security.PrivilegedAction<Object>() {
public Object run() {
feeder.interrupt();
return null;

View File

@ -152,7 +152,7 @@ class ImageFetcher extends Thread {
info.numWaiting--;
}
}
src = (ImageFetchable) info.waitList.elementAt(0);
src = info.waitList.elementAt(0);
info.waitList.removeElement(src);
}
return src;
@ -303,26 +303,25 @@ class ImageFetcher extends Thread {
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 @@ class FetcherInfo {
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. */

View File

@ -185,7 +185,7 @@ public class ImageRepresentation extends ImageWatched implements ImageConsumer
protected BufferedImage createImage(ColorModel cm,
WritableRaster raster,
boolean isRasterPremultiplied,
Hashtable properties)
Hashtable<?,?> properties)
{
BufferedImage bi =
new BufferedImage(cm, raster, isRasterPremultiplied, null);

View File

@ -61,7 +61,7 @@ public class ImagingLib {
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 @@ public class ImagingLib {
}
private static int getNativeOpIndex(Class opClass) {
private static int getNativeOpIndex(Class<?> opClass) {
//
// Search for this class in cached list of
// classes supplying native acceleration

View File

@ -47,8 +47,8 @@ public class JPEGImageDecoder extends ImageDecoder {
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 @@ public class JPEGImageDecoder extends ImageDecoder {
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);

View File

@ -40,15 +40,15 @@ public class OffScreenImageSource implements ImageProducer {
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();

View File

@ -68,7 +68,7 @@ public class PNGImageDecoder extends ImageDecoder
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 @@ public class PNGImageDecoder extends ImageDecoder
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) {

View File

@ -79,7 +79,7 @@ public class ToolkitImage extends Image {
private int width = -1;
private int height = -1;
private Hashtable properties;
private Hashtable<?, ?> properties;
private int availinfo;
@ -254,9 +254,9 @@ public class ToolkitImage extends Image {
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);

View File

@ -127,14 +127,14 @@ public abstract class ShellFolder extends File {
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 @@ public abstract class ShellFolder extends File {
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 @@ public abstract class ShellFolder extends File {
/**
* 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 @@ public abstract class ShellFolder extends File {
} 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;
}

View File

@ -38,7 +38,7 @@ public class ShellFolderColumnInfo {
*/
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 class ShellFolderColumnInfo {
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 class ShellFolderColumnInfo {
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 @@ public class ShellFolderColumnInfo {
this.sortOrder = sortOrder;
}
public Comparator getComparator() {
public Comparator<?> getComparator() {
return comparator;
}
public void setComparator(Comparator comparator) {
public void setComparator(Comparator<?> comparator) {
this.comparator = comparator;
}

View File

@ -285,6 +285,7 @@ public class IdentityArrayList<E> extends AbstractList<E>
* 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 class IdentityArrayList<E> extends AbstractList<E>
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 class IdentityArrayList<E> extends AbstractList<E>
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 @@ public class IdentityArrayList<E> extends AbstractList<E>
rangeCheck(index);
modCount++;
@SuppressWarnings("unchecked")
E oldValue = (E) elementData[index];
int numMoved = size - index - 1;

View File

@ -280,7 +280,9 @@ public class IdentityLinkedList<E>
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 class IdentityLinkedList<E>
*/
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 class IdentityLinkedList<E>
*/
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 @@ public class IdentityLinkedList<E>
}
/** 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 @@ public class IdentityLinkedList<E>
* 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(

View File

@ -207,8 +207,9 @@ public abstract class InfoWindow extends Window {
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;
}

View File

@ -55,10 +55,10 @@ public class ListHelper implements XScrollbarClient {
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 @@ public class ListHelper implements XScrollbarClient {
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 @@ public class ListHelper implements XScrollbarClient {
/* 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 class ListHelper implements XScrollbarClient {
}
public String getItem(int index) {
return (String) items.get(index);
return items.get(index);
}
/**********************************************************************/
@ -576,9 +576,9 @@ public class ListHelper implements XScrollbarClient {
}
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;
}

View File

@ -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 @@ class MotifDnDDragSourceProtocol extends XDragSourceProtocol
}
protected void initializeDragImpl(int actions, Transferable contents,
Map formatMap, long[] formats)
Map<Long, DataFlavor> formatMap, long[] formats)
throws InvalidDnDOperationException,
IllegalArgumentException, XException {

View File

@ -43,13 +43,12 @@ class Native {
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 @@ class Native {
* 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 @@ class Native {
* 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());
}
}
/**

View File

@ -98,7 +98,7 @@ class XAWTXSettings extends XSettings implements XMSelectionListener {
* 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 @@ class XAWTXSettings extends XSettings implements XMSelectionListener {
}
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 @@ class XAWTXSettings extends XSettings implements XMSelectionListener {
});
}
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 @@ class XAWTXSettings extends XSettings implements XMSelectionListener {
return null;
}
Map settings = null;
Map<String, Object> settings = null;
try {
WindowPropertyGetter getter =
new WindowPropertyGetter(owner, xSettingsPropertyAtom, 0, MAX_LENGTH,

View File

@ -157,7 +157,7 @@ class XAtomList {
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()) {

View File

@ -40,7 +40,7 @@ class XAwtState {
* 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 @@ class XAwtState {
return;
}
if (component != getComponentMouseEntered()) {
componentMouseEnteredRef = new WeakReference(component);
componentMouseEnteredRef = new WeakReference<>(component);
}
} finally {
XToolkit.awtUnlock();
@ -63,7 +63,7 @@ class XAwtState {
if (componentMouseEnteredRef == null) {
return null;
}
return (Component)componentMouseEnteredRef.get();
return componentMouseEnteredRef.get();
} finally {
XToolkit.awtUnlock();
}
@ -83,7 +83,7 @@ class XAwtState {
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 @@ class XAwtState {
return;
}
if (grabWindow != getGrabWindow()) {
grabWindowRef = new WeakReference(grabWindow);
grabWindowRef = new WeakReference<>(grabWindow);
}
} finally {
XToolkit.awtUnlock();
@ -125,7 +125,7 @@ class XAwtState {
if (grabWindowRef == null) {
return null;
}
XBaseWindow xbw = (XBaseWindow)grabWindowRef.get();
XBaseWindow xbw = grabWindowRef.get();
if( xbw != null && xbw.isDisposed() ) {
xbw = null;
grabWindowRef = null;

View File

@ -231,7 +231,7 @@ abstract public class XBaseMenuWindow extends XWindow {
*/
void instantPreInit(XCreateWindowParams params) {
super.instantPreInit(params);
items = new ArrayList();
items = new ArrayList<>();
}
/************************************************
@ -367,10 +367,10 @@ abstract public class XBaseMenuWindow extends XWindow {
* 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]);

View File

@ -236,8 +236,8 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
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 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
}
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 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
}
}
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();

View File

@ -30,7 +30,7 @@ import java.util.Iterator;
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 class XCreateWindowParams extends HashMap {
}
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();

View File

@ -49,6 +49,7 @@ import java.util.LinkedHashSet;
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 @@ public class XDataTransferer extends DataTransferer {
// 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);
}

View File

@ -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 @@ class XDnDDragSourceProtocol extends XDragSourceProtocol {
* @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();

View File

@ -36,8 +36,8 @@ import java.util.List;
* @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 @@ final class XDragAndDropProtocols {
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 @@ final class XDragAndDropProtocols {
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 @@ final class XDragAndDropProtocols {
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 @@ final class XDragAndDropProtocols {
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 @@ final class XDragAndDropProtocols {
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;
}

View File

@ -29,6 +29,7 @@ import java.awt.Component;
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 @@ public final class XDragSourceContextPeer
}
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 @@ public final class XDragSourceContextPeer
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 @@ public final class XDragSourceContextPeer
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 @@ public final class XDragSourceContextPeer
}
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 @@ public final class XDragSourceContextPeer
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;

View File

@ -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 @@ abstract class XDragSourceProtocol {
* @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 @@ abstract class XDragSourceProtocol {
/* 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;
/**

View File

@ -89,12 +89,12 @@ final class XDropTargetContextPeer extends SunDropTargetContextPeer {
/* 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 @@ final class XDropTargetContextPeer extends SunDropTargetContextPeer {
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 @@ final class XDropTargetContextPeer extends SunDropTargetContextPeer {
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 @@ final class XDropTargetContextPeer extends SunDropTargetContextPeer {
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;

View File

@ -79,12 +79,11 @@ final class XDropTargetEventProcessor {
}
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;

View File

@ -295,7 +295,8 @@ abstract class XDropTargetProtocol {
}
/* 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 @@ abstract class XDropTargetProtocol {
protected final EmbedderRegistryEntry getEmbedderRegistryEntry(long embedder) {
synchronized (this) {
return
(EmbedderRegistryEntry)embedderRegistry.get(Long.valueOf(embedder));
return embedderRegistry.get(Long.valueOf(embedder));
}
}

View File

@ -141,10 +141,10 @@ final class XDropTargetRegistry {
}
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 @@ final class XDropTargetRegistry {
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 @@ final class XDropTargetRegistry {
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 @@ final class XDropTargetRegistry {
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 @@ final class XDropTargetRegistry {
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 @@ final class XDropTargetRegistry {
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 @@ final class XDropTargetRegistry {
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 @@ final class XDropTargetRegistry {
XlibWrapper.XGrabServer(XToolkit.getDisplay());
try {
while (dropTargetProtocols.hasNext()) {
XDropTargetProtocol dropTargetProtocol =
(XDropTargetProtocol)dropTargetProtocols.next();
XDropTargetProtocol dropTargetProtocol = dropTargetProtocols.next();
dropTargetProtocol.unregisterEmbedderDropSite(embedder);
}
@ -470,14 +465,14 @@ final class XDropTargetRegistry {
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 @@ final class XDropTargetRegistry {
}
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 @@ final class XDropTargetRegistry {
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 @@ final class XDropTargetRegistry {
}
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 @@ final class XDropTargetRegistry {
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);
}

View File

@ -32,7 +32,7 @@ import java.lang.reflect.*;
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() {
}

View File

@ -146,9 +146,9 @@ class XFileDialogPeer extends XDialogPeer implements FileDialogPeer, ActionListe
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");
}
});

View File

@ -70,7 +70,7 @@ class XListPeer extends XComponentPeer implements ListPeer, XScrollbarClient {
ListPainter painter;
// TODO: ick - Vector?
Vector items;
Vector<String> items;
boolean multipleSelections;
int active = NONE;
@ -139,7 +139,7 @@ class XListPeer extends XComponentPeer implements ListPeer, XScrollbarClient {
super.preInit(params);
// Stuff that must be initialized before layout() is called
items = new Vector();
items = new Vector<>();
createVerScrollbar();
createHorScrollbar();
@ -281,7 +281,7 @@ class XListPeer extends XComponentPeer implements ListPeer, XScrollbarClient {
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 @@ class XListPeer extends XComponentPeer implements ListPeer, XScrollbarClient {
*/
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 @@ class XListPeer extends XComponentPeer implements ListPeer, XScrollbarClient {
( 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 @@ class XListPeer extends XComponentPeer implements ListPeer, XScrollbarClient {
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 @@ class XListPeer extends XComponentPeer implements ListPeer, XScrollbarClient {
*/
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 @@ class XListPeer extends XComponentPeer implements ListPeer, XScrollbarClient {
} 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

View File

@ -60,7 +60,7 @@ public class XMSelection {
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 @@ public class XMSelection {
static XAtom XA_MANAGER;
static HashMap selectionMap;
static HashMap<Long, XMSelection> selectionMap;
static {
long display = XToolkit.getDisplay();
@ -90,7 +90,7 @@ public class XMSelection {
initScreen(display,screen);
}
selectionMap = new HashMap();
selectionMap = new HashMap<>();
}
static void initScreen(long display, final int screen) {
@ -227,7 +227,7 @@ public class XMSelection {
static XMSelection getInstance(long selection) {
return (XMSelection) selectionMap.get(Long.valueOf(selection));
return selectionMap.get(Long.valueOf(selection));
}
@ -259,7 +259,7 @@ public class XMSelection {
public synchronized void addSelectionListener(XMSelectionListener listener) {
if (listeners == null) {
listeners = new Vector();
listeners = new Vector<>();
}
listeners.add(listener);
}
@ -270,7 +270,7 @@ public class XMSelection {
}
}
synchronized Collection getListeners() {
synchronized Collection<XMSelectionListener> getListeners() {
return listeners;
}
@ -310,9 +310,9 @@ public class XMSelection {
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 @@ public class XMSelection {
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 @@ public class XMSelection {
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);
}
}

View File

@ -195,10 +195,10 @@ public class XMenuBarPeer extends XBaseMenuWindow implements MenuBarPeer {
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);

View File

@ -143,7 +143,7 @@ public class XMenuPeer extends XMenuItemPeer implements MenuPeer {
* Access to target's fields
*
************************************************/
Vector getTargetItems() {
Vector<MenuItem> getTargetItems() {
return AWTAccessor.getMenuAccessor().getItems((Menu)getTarget());
}

View File

@ -164,7 +164,7 @@ public class XMenuWindow extends XBaseMenuWindow {
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 @@ public class XMenuWindow extends XBaseMenuWindow {
* Reads vector of items from target
* This function is overriden in XPopupMenuPeer
*/
Vector getMenuTargetItems() {
Vector<MenuItem> getMenuTargetItems() {
return menuPeer.getTargetItems();
}

View File

@ -134,7 +134,7 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer {
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 @@ public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer {
return AWTAccessor.getMenuItemAccessor().isEnabled(popupMenuTarget);
}
Vector getMenuTargetItems() {
Vector<MenuItem> getMenuTargetItems() {
if (popupMenuTarget == null) {
return null;
}

View File

@ -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 @@ public final class XSelection {
/* 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 @@ public final class XSelection {
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();

View File

@ -36,6 +36,7 @@ import java.awt.dnd.DragGestureRecognizer;
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
return XDragSourceContextPeer.createDragSourceContextPeer(dge);
}
@SuppressWarnings("unchecked")
public <T extends DragGestureRecognizer> T
createDragGestureRecognizer(Class<T> recognizerClass,
DragSource ds,
@ -1147,7 +1149,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
* <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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
if (timeoutTasks == null || timeoutTasks.isEmpty()) {
return -1L;
}
return (Long)timeoutTasks.firstKey();
return timeoutTasks.firstKey();
} finally {
awtUnlock();
}
@ -1918,13 +1914,13 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
if (timeoutTasks.isEmpty()) {
break;
}
time = (Long)timeoutTasks.firstKey();
time = timeoutTasks.firstKey();
}
}

View File

@ -85,7 +85,7 @@ public class XTrayIconPeer implements TrayIconPeer,
// 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;

View File

@ -1072,6 +1072,7 @@ final class XWM
* 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 @@ final class XWM
}
}
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:

View File

@ -59,7 +59,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
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 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
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 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
clickCount++;
} else {
clickCount = 1;
lastWindowRef = new WeakReference(this);
lastWindowRef = new WeakReference<>(this);
lastButton = lbutton;
lastX = x;
lastY = y;
@ -820,7 +820,7 @@ public class XWindow extends XBaseWindow implements X11ComponentPeer {
*/
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() &&

View File

@ -950,7 +950,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
// 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) {

View File

@ -47,7 +47,7 @@ public abstract class X11CustomCursor extends CustomCursor {
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 @@ public abstract class X11CustomCursor extends CustomCursor {
count = ct;
}
public int compareTo(Object cc) {
return ((CCount)cc).count - count;
public int compareTo(CCount cc) {
return cc.count - count;
}
}

View File

@ -59,7 +59,7 @@ public class X11FontManager extends SunFontManager {
* 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 @@ public class X11FontManager extends SunFontManager {
* 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 @@ public class X11FontManager extends SunFontManager {
* 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 @@ public class X11FontManager extends SunFontManager {
* 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 @@ public class X11FontManager extends SunFontManager {
* 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 @@ public class X11FontManager extends SunFontManager {
fileName = null;
}
if (fileName != null) {
xVal = new Vector();
xVal = new Vector<>();
xVal.add(platName);
xlfdMap.put(fileName, xVal);
}
@ -211,7 +211,7 @@ public class X11FontManager extends SunFontManager {
}
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 @@ public class X11FontManager extends SunFontManager {
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 @@ public class X11FontManager extends SunFontManager {
}
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 @@ public class X11FontManager extends SunFontManager {
@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 @@ public class X11FontManager extends SunFontManager {
}
} else {
int len = nativeNames.size();
return (String[])nativeNames.toArray(new String[len]);
return nativeNames.toArray(new String[len]);
}
}
@ -366,7 +366,7 @@ public class X11FontManager extends SunFontManager {
}
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 @@ public class X11FontManager extends SunFontManager {
* 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 @@ public class X11FontManager extends SunFontManager {
}
fontNameMap.put(fontID, fullPath);
if (xVal == null) {
xVal = new Vector();
xVal = new Vector<>();
xlfdMap.put (fullPath, xVal);
}
xVal.add(fontPart);
@ -447,8 +447,8 @@ public class X11FontManager extends SunFontManager {
* 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 @@ public class X11FontManager extends SunFontManager {
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 @@ public class X11FontManager extends SunFontManager {
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);
}

View File

@ -56,7 +56,7 @@ public class X11GraphicsDevice
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 @@ public class X11GraphicsDevice
GraphicsConfiguration[] configs;
GraphicsConfiguration defaultConfig;
HashSet doubleBufferVisuals;
HashSet<Integer> doubleBufferVisuals;
/**
* Returns all of the graphics
@ -159,7 +159,7 @@ public class X11GraphicsDevice
boolean dbeSupported = isDBESupported();
if (dbeSupported && doubleBufferVisuals == null) {
doubleBufferVisuals = new HashSet();
doubleBufferVisuals = new HashSet<>();
getDoubleBufferVisuals(screen);
}
for ( ; i < num; i++) {
@ -249,7 +249,7 @@ public class X11GraphicsDevice
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));

View File

@ -72,7 +72,7 @@ public class X11GraphicsEnvironment
static {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
new java.security.PrivilegedAction<Object>() {
public Object run() {
System.loadLibrary("awt");
@ -254,12 +254,12 @@ public class X11GraphicsEnvironment
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 @@ public class X11GraphicsEnvironment
}
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])) {

View File

@ -100,7 +100,7 @@ public abstract class X11InputMethod extends InputMethodAdapter {
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 @@ public abstract class X11InputMethod extends InputMethodAdapter {
// 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 @@ public abstract class X11InputMethod extends InputMethodAdapter {
/**
* @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) {

View File

@ -52,7 +52,7 @@ public class XSettings {
* 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 @@ public class XSettings {
private int nsettings = 0;
private boolean isValid;
private HashMap updatedSettings;
private HashMap<String, Object> updatedSettings;
/**
@ -113,7 +113,7 @@ public class XSettings {
idx = 8;
nsettings = getINT32();
updatedSettings = new HashMap();
updatedSettings = new HashMap<>();
isValid = true;
}
@ -213,7 +213,7 @@ public class XSettings {
/**
* Update settings.
*/
public Map update() {
public Map<String, Object> update() {
if (!isValid) {
return null;
}

View File

@ -67,7 +67,7 @@ public class MFontConfiguration extends FontConfiguration {
* the fontconfig files.
*/
protected void initReorderMap() {
reorderMap = new HashMap();
reorderMap = new HashMap<>();
if (osName == null) { /* null means SunOS */
initReorderMapForSolaris();
} else {
@ -240,7 +240,7 @@ public class MFontConfiguration extends FontConfiguration {
return "sun.awt.Symbol";
}
}
String encoding = (String) encodingMap.get(xlfdEncoding);
String encoding = encodingMap.get(xlfdEncoding);
if (encoding == null) {
encoding = "default";
}
@ -288,7 +288,7 @@ public class MFontConfiguration extends FontConfiguration {
/* 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