提交 34f8e42d 编写于 作者: D denis

7117011: Reduce number of warnings in sun/awt/windows and sun/awt/datatransfer

Reviewed-by: art
上级 05c45bb5
......@@ -649,8 +649,9 @@ public abstract class DataTransferer {
* The map keys are sorted according to the native formats preference
* order.
*/
public SortedMap getFormatsForTransferable(Transferable contents,
FlavorTable map) {
public SortedMap<Long,DataFlavor> getFormatsForTransferable(
Transferable contents, FlavorTable map)
{
DataFlavor[] flavors = contents.getTransferDataFlavors();
if (flavors == null) {
return new TreeMap();
......@@ -686,9 +687,13 @@ public abstract class DataTransferer {
* DataFlavors and data formats
* @throws NullPointerException if flavors or map is <code>null</code>
*/
public SortedMap getFormatsForFlavors(DataFlavor[] flavors, FlavorTable map) {
Map formatMap = new HashMap(flavors.length);
Map textPlainMap = new HashMap(flavors.length);
public SortedMap <Long, DataFlavor> getFormatsForFlavors(
DataFlavor[] flavors, FlavorTable map)
{
Map <Long,DataFlavor> formatMap =
new HashMap <> (flavors.length);
Map <Long,DataFlavor> textPlainMap =
new HashMap <> (flavors.length);
// Maps formats to indices that will be used to sort the formats
// according to the preference order.
// Larger index value corresponds to the more preferable format.
......
......@@ -52,6 +52,7 @@ import java.util.SortedMap;
import sun.awt.SunToolkit;
import sun.awt.datatransfer.DataTransferer;
import java.awt.datatransfer.DataFlavor;
/**
* <p>
......@@ -126,9 +127,9 @@ public abstract class SunDragSourceContextPeer implements DragSourceContextPeer
dragImageOffset = p;
Transferable transferable = getDragSourceContext().getTransferable();
SortedMap formatMap = DataTransferer.getInstance().getFormatsForTransferable
(transferable, DataTransferer.adaptFlavorMap
(getTrigger().getDragSource().getFlavorMap()));
SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().
getFormatsForTransferable(transferable, DataTransferer.adaptFlavorMap
(getTrigger().getDragSource().getFlavorMap()));
long[] formats = DataTransferer.getInstance().
keysToLongArray(formatMap);
startDrag(transferable, formats, formatMap);
......
......@@ -26,6 +26,7 @@
package sun.awt.X11;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.DataFlavor;
import java.util.SortedMap;
import java.io.IOException;
import java.security.AccessController;
......@@ -83,7 +84,8 @@ public final class XClipboard extends SunClipboard implements OwnershipListener
}
protected synchronized void setContentsNative(Transferable contents) {
SortedMap formatMap = DataTransferer.getInstance().getFormatsForTransferable
SortedMap<Long,DataFlavor> formatMap =
DataTransferer.getInstance().getFormatsForTransferable
(contents, DataTransferer.adaptFlavorMap(flavorMap));
long[] formats = DataTransferer.keysToLongArray(formatMap);
......
......@@ -40,6 +40,7 @@ import sun.java2d.DestSurfaceProvider;
import sun.java2d.InvalidPipeException;
import sun.java2d.Surface;
import sun.java2d.pipe.RenderQueue;
import sun.java2d.pipe.BufferedContext;
import sun.java2d.pipe.hw.AccelGraphicsConfig;
import sun.java2d.pipe.hw.AccelSurface;
import sun.security.action.GetPropertyAction;
......@@ -310,7 +311,7 @@ public abstract class TranslucentWindowPainter {
RenderQueue rq = as.getContext().getRenderQueue();
rq.lock();
try {
as.getContext().validateContext(as);
BufferedContext.validateContext(as);
rq.flushAndInvokeNow(new Runnable() {
public void run() {
long psdops = as.getNativeOps();
......
......@@ -37,7 +37,7 @@ import java.awt.Component;
*/
public class WBufferStrategy {
private static native void initIDs(Class componentClass);
private static native void initIDs(Class <?> componentClass);
static {
initIDs(Component.class);
......
......@@ -84,6 +84,7 @@ class WChoicePeer extends WComponentPeer implements ChoicePeer {
native void create(WComponentPeer parent);
@SuppressWarnings("deprecation")
void initialize() {
Choice opt = (Choice)target;
int itemCount = opt.getItemCount();
......@@ -116,6 +117,7 @@ class WChoicePeer extends WComponentPeer implements ChoicePeer {
super.initialize();
}
@SuppressWarnings("deprecation")
protected void disposeImpl() {
// TODO: we should somehow reset the listener when the choice
// is moved to another toplevel without destroying its peer.
......
......@@ -71,17 +71,14 @@ public class WClipboard extends SunClipboard {
// Get all of the target formats into which the Transferable can be
// translated. Then, for each format, translate the data and post
// it to the Clipboard.
Map formatMap = WDataTransferer.getInstance().
Map <Long, DataFlavor> formatMap = WDataTransferer.getInstance().
getFormatsForTransferable(contents, flavorMap);
openClipboard(this);
try {
for (Iterator iter = formatMap.keySet().iterator();
iter.hasNext(); ) {
Long lFormat = (Long)iter.next();
long format = lFormat.longValue();
DataFlavor flavor = (DataFlavor)formatMap.get(lFormat);
for (Long format : formatMap.keySet()) {
DataFlavor flavor = formatMap.get(format);
try {
byte[] bytes = WDataTransferer.getInstance().
......
......@@ -222,7 +222,7 @@ public abstract class WComponentPeer extends WObjectPeer
updateWindow();
// make sure paint events are transferred to main event queue
// for coalescing
WToolkit.getWToolkit().flushPendingEvents();
SunToolkit.flushPendingEvents();
// paint the damaged area
paintArea.paint(target, shouldClearRectBeforePaint());
}
......@@ -320,6 +320,7 @@ public abstract class WComponentPeer extends WObjectPeer
native void nativeHandleEvent(AWTEvent e);
@SuppressWarnings("fallthrough")
public void handleEvent(AWTEvent e) {
int id = e.getID();
......@@ -549,6 +550,7 @@ public abstract class WComponentPeer extends WObjectPeer
// fallback default font object
final static Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
@SuppressWarnings("deprecation")
public Graphics getGraphics() {
if (isDisposed()) {
return null;
......@@ -656,6 +658,7 @@ public abstract class WComponentPeer extends WObjectPeer
}
// TODO: consider moving it to KeyboardFocusManagerPeerImpl
@SuppressWarnings("deprecation")
public boolean requestFocus(Component lightweightChild, boolean temporary,
boolean focusedWindowChangeAllowed, long time,
CausedFocusEvent.Cause cause)
......@@ -1058,6 +1061,7 @@ public abstract class WComponentPeer extends WObjectPeer
// in the browser on Vista when DWM is enabled.
// @return true if the toplevel container is not an EmbeddedFrame or
// if this EmbeddedFrame is acceleration capable, false otherwise
@SuppressWarnings("deprecation")
private static final boolean isContainingTopLevelAccelCapable(Component c) {
while (c != null && !(c instanceof WEmbeddedFrame)) {
c = c.getParent();
......@@ -1072,6 +1076,7 @@ public abstract class WComponentPeer extends WObjectPeer
* Applies the shape to the native component window.
* @since 1.7
*/
@SuppressWarnings("deprecation")
public void applyShape(Region shape) {
if (shapeLog.isLoggable(PlatformLogger.FINER)) {
shapeLog.finer(
......
......@@ -107,13 +107,15 @@ public class WDataTransferer extends DataTransferer {
"DIBV5"
};
private static final Map predefinedClipboardNameMap;
private static final Map <String, Long> predefinedClipboardNameMap;
static {
Map tempMap = new HashMap(predefinedClipboardNames.length, 1.0f);
Map <String,Long> tempMap =
new HashMap <> (predefinedClipboardNames.length, 1.0f);
for (int i = 1; i < predefinedClipboardNames.length; i++) {
tempMap.put(predefinedClipboardNames[i], Long.valueOf(i));
}
predefinedClipboardNameMap = Collections.synchronizedMap(tempMap);
predefinedClipboardNameMap =
Collections.synchronizedMap(tempMap);
}
/**
......@@ -135,7 +137,7 @@ public class WDataTransferer extends DataTransferer {
public static final long CF_FILEGROUPDESCRIPTORA = registerClipboardFormat("FileGroupDescriptor");
//CF_FILECONTENTS supported as mandatory associated clipboard
private static final Long L_CF_LOCALE = (Long)
private static final Long L_CF_LOCALE =
predefinedClipboardNameMap.get(predefinedClipboardNames[CF_LOCALE]);
private static final DirectColorModel directColorModel =
......@@ -168,8 +170,11 @@ public class WDataTransferer extends DataTransferer {
return transferer;
}
public SortedMap getFormatsForFlavors(DataFlavor[] flavors, FlavorTable map) {
SortedMap retval = super.getFormatsForFlavors(flavors, map);
public SortedMap <Long, DataFlavor> getFormatsForFlavors(
DataFlavor[] flavors, FlavorTable map)
{
SortedMap <Long, DataFlavor> retval =
super.getFormatsForFlavors(flavors, map);
// The Win32 native code does not support exporting LOCALE data, nor
// should it.
......@@ -266,7 +271,7 @@ public class WDataTransferer extends DataTransferer {
}
protected Long getFormatForNativeAsLong(String str) {
Long format = (Long)predefinedClipboardNameMap.get(str);
Long format = predefinedClipboardNameMap.get(str);
if (format == null) {
format = Long.valueOf(registerClipboardFormat(str));
}
......
......@@ -238,6 +238,7 @@ class WDesktopProperties {
* Called by WToolkit when Windows settings change-- we (re)load properties and
* set new values.
*/
@SuppressWarnings("unchecked")
synchronized Map<String, Object> getProperties() {
ThemeReader.flush();
......
......@@ -87,6 +87,7 @@ class WDialogPeer extends WWindowPeer implements DialogPeer {
}
}
@SuppressWarnings("deprecation")
public void hide() {
Dialog dlg = (Dialog)target;
if (dlg.getModalityType() != Dialog.ModalityType.MODELESS) {
......
......@@ -27,14 +27,12 @@ package sun.awt.windows;
import sun.awt.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.peer.ComponentPeer;
import java.util.*;
import java.awt.color.*;
import java.awt.image.*;
import sun.awt.image.ByteInterleavedRaster;
import sun.security.action.GetPropertyAction;
import java.lang.reflect.*;
import java.security.PrivilegedAction;
import java.security.AccessController;
public class WEmbeddedFrame extends EmbeddedFrame {
......@@ -52,8 +50,8 @@ public class WEmbeddedFrame extends EmbeddedFrame {
private static int pScale = 0;
private static final int MAX_BAND_SIZE = (1024*30);
private static String printScale = (String) java.security.AccessController
.doPrivileged(new GetPropertyAction("sun.java2d.print.pluginscalefactor"));
private static String printScale = AccessController.doPrivileged(
new GetPropertyAction("sun.java2d.print.pluginscalefactor"));
public WEmbeddedFrame() {
this((long)0);
......@@ -75,6 +73,7 @@ public class WEmbeddedFrame extends EmbeddedFrame {
}
}
@SuppressWarnings("deprecation")
public void addNotify() {
if (getPeer() == null) {
WToolkit toolkit = (WToolkit)Toolkit.getDefaultToolkit();
......@@ -134,8 +133,8 @@ public class WEmbeddedFrame extends EmbeddedFrame {
bandHeight = Math.min(MAX_BAND_SIZE/bandWidth, frameHeight);
imgWid = (int)(bandWidth * xscale);
imgHgt = (int)(bandHeight * yscale);
imgWid = bandWidth * xscale;
imgHgt = bandHeight * yscale;
bandImage = new BufferedImage(imgWid, imgHgt,
BufferedImage.TYPE_3BYTE_BGR);
}
......@@ -159,7 +158,7 @@ public class WEmbeddedFrame extends EmbeddedFrame {
if ((bandTop+bandHeight) > frameHeight) {
// last band
currBandHeight = frameHeight - bandTop;
currImgHeight = (int)(currBandHeight*yscale);
currImgHeight = currBandHeight*yscale;
// multiply by 3 because the image is a 3 byte BGR
imageOffset = imgWid*(imgHgt-currImgHeight)*3;
......@@ -179,9 +178,9 @@ public class WEmbeddedFrame extends EmbeddedFrame {
if (printScale == null) {
// if no system property is specified,
// check for environment setting
printScale = (String) java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
printScale = AccessController.doPrivileged(
new PrivilegedAction<String>() {
public String run() {
return System.getenv("JAVA2D_PLUGIN_PRINT_SCALE");
}
}
......@@ -226,6 +225,7 @@ public class WEmbeddedFrame extends EmbeddedFrame {
public void activateEmbeddingTopLevel() {
}
@SuppressWarnings("deprecation")
public void synthesizeWindowActivation(final boolean doActivate) {
if (!doActivate || EventQueue.isDispatchThread()) {
((WEmbeddedFramePeer)getPeer()).synthesizeWmActivate(doActivate);
......
......@@ -167,7 +167,7 @@ public class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
WToolkit.executeOnEventHandlerThread(fileDialog, new Runnable() {
public void run() {
fileDialog.hide();
fileDialog.setVisible(false);
}
});
} // handleSelected()
......@@ -182,16 +182,16 @@ public class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
WToolkit.executeOnEventHandlerThread(fileDialog, new Runnable() {
public void run() {
fileDialog.hide();
fileDialog.setVisible(false);
}
});
} // handleCancel()
//This whole static block is a part of 4152317 fix
static {
String filterString = (String) AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
String filterString = AccessController.doPrivileged(
new PrivilegedAction<String>() {
public String run() {
try {
ResourceBundle rb = ResourceBundle.getBundle("sun.awt.windows.awtLocalization");
return rb.getString("allFiles");
......
......@@ -24,25 +24,12 @@
*/
package sun.awt.windows;
import java.util.Vector;
import java.awt.*;
import java.awt.peer.*;
import java.awt.image.ImageObserver;
import java.awt.image.Raster;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import sun.awt.image.ImageRepresentation;
import sun.awt.image.IntegerComponentRaster;
import sun.awt.image.ToolkitImage;
import sun.awt.im.*;
import sun.awt.Win32GraphicsDevice;
import sun.awt.AWTAccessor;
import sun.awt.im.InputMethodManager;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
class WFramePeer extends WWindowPeer implements FramePeer {
......@@ -71,9 +58,9 @@ class WFramePeer extends WWindowPeer implements FramePeer {
private native void clearMaximizedBounds();
private static final boolean keepOnMinimize = "true".equals(
(String)java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction(
"sun.awt.keepWorkingSetOnMinimize")));
AccessController.doPrivileged(
new GetPropertyAction(
"sun.awt.keepWorkingSetOnMinimize")));
public void setMaximizedBounds(Rectangle b) {
if (b == null) {
......
......@@ -82,12 +82,12 @@ public class WInputMethod extends InputMethodAdapter
private final static boolean COMMIT_INPUT = true;
private final static boolean DISCARD_INPUT = false;
private static Map[] highlightStyles;
private static Map<TextAttribute,Object> [] highlightStyles;
// Initialize highlight mapping table
static {
Map styles[] = new Map[4];
HashMap map;
Map<TextAttribute,Object> styles[] = new Map[4];
HashMap<TextAttribute,Object> map;
// UNSELECTED_RAW_TEXT_HIGHLIGHT
map = new HashMap(1);
......@@ -410,7 +410,7 @@ public class WInputMethod extends InputMethodAdapter
/**
* @see java.awt.Toolkit#mapInputMethodHighlight
*/
static Map mapInputMethodHighlight(InputMethodHighlight highlight) {
static Map<TextAttribute,?> mapInputMethodHighlight(InputMethodHighlight highlight) {
int index;
int state = highlight.getState();
if (state == InputMethodHighlight.RAW_TEXT) {
......
......@@ -158,9 +158,9 @@ class WMenuItemPeer extends WObjectPeer implements MenuItemPeer {
private static Font defaultMenuFont;
static {
defaultMenuFont = (Font) AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
defaultMenuFont = AccessController.doPrivileged(
new PrivilegedAction <Font> () {
public Font run() {
try {
ResourceBundle rb = ResourceBundle.getBundle("sun.awt.windows.awtLocalization");
return Font.decode(rb.getString("menuFont"));
......
......@@ -55,6 +55,7 @@ public class WPageDialog extends WPrintDialog {
this.painter = painter;
}
@SuppressWarnings("deprecation")
public void addNotify() {
synchronized(getTreeLock()) {
Container parent = getParent();
......
......@@ -49,7 +49,7 @@ public class WPageDialogPeer extends WPrintDialogPeer {
// but if it is we need to trap it so the thread does
// not hide is called and the thread doesn't hang.
}
((WPrintDialog)target).hide();
((WPrintDialog)target).setVisible(false);
}
}).start();
}
......
......@@ -53,6 +53,7 @@ public class WPrintDialog extends Dialog {
// Use native code to circumvent access restrictions on Component.peer
protected native void setPeer(ComponentPeer peer);
@SuppressWarnings("deprecation")
public void addNotify() {
synchronized(getTreeLock()) {
Container parent = getParent();
......
......@@ -73,7 +73,7 @@ public class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
// but if it is we need to trap it so the thread does
// not hide is called and the thread doesn't hang.
}
((WPrintDialog)target).hide();
((WPrintDialog)target).setVisible(false);
}
}).start();
}
......
......@@ -74,7 +74,7 @@ public class WToolkit extends SunToolkit implements Runnable {
WClipboard clipboard;
// cache of font peers
private Hashtable cacheFontPeer;
private Hashtable<String,FontPeer> cacheFontPeer;
// Windows properties
private WDesktopProperties wprops;
......@@ -110,10 +110,10 @@ public class WToolkit extends SunToolkit implements Runnable {
log.fine("Win version: " + getWindowsVersion());
}
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction()
AccessController.doPrivileged(
new PrivilegedAction <Void> ()
{
public Object run() {
public Void run() {
String browserProp = System.getProperty("browser");
if (browserProp != null && browserProp.equals("sun.plugin")) {
disableCustomPalette();
......@@ -261,8 +261,8 @@ public class WToolkit extends SunToolkit implements Runnable {
}
private final void registerShutdownHook() {
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
ThreadGroup currentTG =
Thread.currentThread().getThreadGroup();
ThreadGroup parentTG = currentTG.getParent();
......@@ -399,6 +399,7 @@ public class WToolkit extends SunToolkit implements Runnable {
return peer;
}
@SuppressWarnings("deprecation")
public void disableBackgroundErase(Canvas canvas) {
WCanvasPeer peer = (WCanvasPeer)canvas.getPeer();
if (peer == null) {
......@@ -592,7 +593,7 @@ public class WToolkit extends SunToolkit implements Runnable {
FontPeer retval = null;
String lcName = name.toLowerCase();
if (null != cacheFontPeer) {
retval = (FontPeer)cacheFontPeer.get(lcName + style);
retval = cacheFontPeer.get(lcName + style);
if (null != retval) {
return retval;
}
......@@ -600,7 +601,7 @@ public class WToolkit extends SunToolkit implements Runnable {
retval = new WFontPeer(name, style);
if (retval != null) {
if (null == cacheFontPeer) {
cacheFontPeer = new Hashtable(5, (float)0.9);
cacheFontPeer = new Hashtable<>(5, 0.9f);
}
if (null != cacheFontPeer) {
cacheFontPeer.put(lcName + style, retval);
......@@ -698,7 +699,9 @@ public class WToolkit extends SunToolkit implements Runnable {
/**
* Returns a style map for the input method highlight.
*/
public Map mapInputMethodHighlight(InputMethodHighlight highlight) {
public Map<java.awt.font.TextAttribute,?> mapInputMethodHighlight(
InputMethodHighlight highlight)
{
return WInputMethod.mapInputMethodHighlight(highlight);
}
......@@ -968,12 +971,14 @@ public class WToolkit extends SunToolkit implements Runnable {
return !Win32GraphicsEnvironment.isDWMCompositionEnabled();
}
@SuppressWarnings("deprecation")
public void grab(Window w) {
if (w.getPeer() != null) {
((WWindowPeer)w.getPeer()).grab();
}
}
@SuppressWarnings("deprecation")
public void ungrab(Window w) {
if (w.getPeer() != null) {
((WWindowPeer)w.getPeer()).ungrab();
......
......@@ -92,7 +92,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
}
// WComponentPeer overrides
@SuppressWarnings("unchecked")
protected void disposeImpl() {
AppContext appContext = SunToolkit.targetToAppContext(target);
synchronized (appContext) {
......@@ -378,6 +378,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
return modalBlocker != null;
}
@SuppressWarnings("deprecation")
public void setModalBlocked(Dialog dialog, boolean blocked) {
synchronized (((Component)getTarget()).getTreeLock()) // State lock should always be after awtLock
{
......@@ -417,6 +418,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
* The list is sorted by the time of activation, so the latest
* active window is always at the end.
*/
@SuppressWarnings("unchecked")
public static long[] getActiveWindowHandles() {
AppContext appContext = AppContext.getAppContext();
synchronized (appContext) {
......@@ -571,6 +573,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
super.print(g);
}
@SuppressWarnings("deprecation")
private void replaceSurfaceDataRecursively(Component c) {
if (c instanceof Container) {
for (Component child : ((Container)c).getComponents()) {
......@@ -691,13 +694,13 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
// its shape only. To restore the correct visual appearance
// of the window (i.e. w/ the correct shape) we have to reset
// the shape.
Shape shape = ((Window)target).getShape();
Shape shape = target.getShape();
if (shape != null) {
((Window)target).setShape(shape);
target.setShape(shape);
}
}
if (((Window)target).isVisible()) {
if (target.isVisible()) {
updateWindow(true);
}
}
......@@ -730,6 +733,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
* then the method registers ActiveWindowListener, GuiDisposedListener listeners;
* it executes the initilialization only once per AppContext.
*/
@SuppressWarnings("unchecked")
private static void initActiveWindowsTracking(Window w) {
AppContext appContext = AppContext.getAppContext();
synchronized (appContext) {
......@@ -774,6 +778,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
* updates the list of active windows per AppContext, so the latest active
* window is always at the end of the list. The list is stored in AppContext.
*/
@SuppressWarnings( value = {"deprecation", "unchecked"})
private static class ActiveWindowListener implements PropertyChangeListener {
public void propertyChange(PropertyChangeEvent e) {
Window w = (Window)e.getNewValue();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册