This commit is contained in:
Bradford Wetmore 2014-05-23 23:55:14 +00:00
commit 892219868a
291 changed files with 12127 additions and 1978 deletions

View File

@ -256,3 +256,4 @@ ab06ba2894313a47e4969ca37792ff119c49e711 jdk9-b10
47feccd164b7187a0147693a922ee47c6629643c jdk9-b11
83d9bc20973de232cae45b139fdff8a4549c130f jdk9-b12
c7c8002d02721e02131d104549ebeb8b379fb8d2 jdk9-b13
5c7a17a81afd0906b53ee31d95a3211c96ff6b25 jdk9-b14

View File

@ -111,20 +111,8 @@ else
ALL_META-INF_DIRS := $(ALL_META-INF_DIRS_share)
endif
ifndef OPENJDK
ALL_META-INF_DIRS += $(JDK_TOPDIR)/src/closed/share/classes/sun/java2d/cmm/kcms/META-INF
endif
SRC_SERVICES_FILES := $(wildcard $(addsuffix /services/*, $(ALL_META-INF_DIRS)))
ifdef OPENJDK
SRC_SERVICES_FILES := $(filter-out %sun/dc/META-INF/services/sun.java2d.pipe.RenderingEngine, $(SRC_SERVICES_FILES))
SRC_SERVICES_FILES := $(filter-out %sun/java2d/cmm/kcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider, $(SRC_SERVICES_FILES))
else
SRC_SERVICES_FILES := $(filter-out %sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine, $(SRC_SERVICES_FILES))
SRC_SERVICES_FILES := $(filter-out %sun/java2d/cmm/lcms/META-INF/services/sun.java2d.cmm.CMMServiceProvider, $(SRC_SERVICES_FILES))
endif
# The number of services files are relatively few. If the increase in numbers, then
# we have to use ListPathsSafelyNow here.
# Change $(JDK_TOPDIR)/src/.../META-INF/services/yyyy into $(JDK_OUTPUTDIR)/classes/META-INF/services/yyyy

View File

@ -318,7 +318,7 @@ ifeq ($(OPENJDK_TARGET_OS), aix)
endif
ifeq ($(OPENJDK_TARGET_OS), macosx)
LIBAWT_FILES += awt_LoadLibrary.c img_colors.c
LIBAWT_FILES += awt_LoadLibrary.c
LIBAWT_CFLAGS += -F/System/Library/Frameworks/JavaVM.framework/Frameworks
endif
@ -606,7 +606,6 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),)
debug_mem.c \
debug_trace.c \
debug_util.c \
awt_Plugin.c \
gnome_interface.c \
gtk2_interface.c \
swing_GTKEngine.c \
@ -657,17 +656,34 @@ endif
##########################################################################################
LIBLCMS_DIR := $(JDK_TOPDIR)/src/share/native/sun/java2d/cmm/lcms
ifeq ($(USE_EXTERNAL_LCMS), true)
# If we're using an external library, we'll just need the wrapper part.
# By including it explicitely, all other files will be excluded.
BUILD_LIBLCMS_INCLUDE_FILES := LCMS.c
BUILD_LIBLCMS_HEADERS :=
else
BUILD_LIBLCMS_INCLUDE_FILES :=
# If we're using the bundled library, we'll need to include it in the
# include path explicitly. Otherwise the system headers will be used.
BUILD_LIBLCMS_HEADERS := -I$(LIBLCMS_DIR)
endif
# TODO: Update awt lib path when awt is converted
$(eval $(call SetupNativeCompilation,BUILD_LIBLCMS, \
LIBRARY := lcms, \
OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
SRC := $(JDK_TOPDIR)/src/share/native/sun/java2d/cmm/lcms, \
SRC := $(LIBLCMS_DIR), \
INCLUDE_FILES := $(BUILD_LIBLCMS_INCLUDE_FILES), \
LANG := C, \
OPTIMIZATION := HIGHEST, \
CFLAGS := $(filter-out -xc99=%none, $(CFLAGS_JDKLIB)) \
$(SHARED_LIBRARY_FLAGS) \
-I$(JDK_TOPDIR)/src/share/native/sun/java2d \
-I$(JDK_TOPDIR)/src/share/native/sun/awt/debug, \
-I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
$(BUILD_LIBLCMS_HEADERS) \
$(LCMS_CFLAGS), \
CFLAGS_solaris := -xc99=no_lib, \
CFLAGS_windows := -DCMS_IS_WINDOWS_, \
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/liblcms/mapfile-vers, \
@ -675,10 +691,10 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBLCMS, \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_solaris := /usr/lib$(OPENJDK_TARGET_CPU_ISADIR)/libm.so.2, \
LDFLAGS_windows := $(WIN_AWT_LIB) $(WIN_JAVA_LIB), \
LDFLAGS_SUFFIX_solaris := -lawt -ljava -ljvm -lc, \
LDFLAGS_SUFFIX_macosx := $(LIBM) -lawt -ljava -ljvm, \
LDFLAGS_SUFFIX_linux := -lm -lawt -ljava -ljvm, \
LDFLAGS_SUFFIX_aix := -lm -lawt -ljava -ljvm,\
LDFLAGS_SUFFIX_solaris := -lawt -ljava -ljvm -lc $(LCMS_LIBS), \
LDFLAGS_SUFFIX_macosx := $(LIBM) -lawt -ljava -ljvm $(LCMS_LIBS), \
LDFLAGS_SUFFIX_linux := -lm -lawt -ljava -ljvm $(LCMS_LIBS), \
LDFLAGS_SUFFIX_aix := -lm -lawt -ljava -ljvm $(LCMS_LIBS),\
VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
RC_FLAGS := $(RC_FLAGS) \
-D "JDK_FNAME=lcms.dll" \

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -249,11 +249,6 @@ SUNWprivate_1.1 {
Java_sun_awt_motif_XsessionWMcommand;
Java_sun_awt_motif_XsessionWMcommand_New;
# Java Plugin
getAwtLockFunctions;
getAwtData;
getAwtDisplay;
# libfontmanager entry points
AWTIsHeadless;
AWTCountFonts;

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -173,13 +173,6 @@ SUNWprivate_1.1 {
Java_sun_awt_motif_XsessionWMcommand;
Java_sun_awt_motif_XsessionWMcommand_New;
# Java Plugin
# This is in awt_LoadLibrary.c and falls through to libmawt.
# Evidently plugin needs this for backward compatability.
getAwtLockFunctions;
getAwtData;
getAwtDisplay;
# libfontmanager entry points
AWTIsHeadless;
GrPrim_Sg2dGetCompInfo;

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -152,13 +152,6 @@ SUNWprivate_1.1 {
# Evidently CDE needs this for backward compatability.
Java_sun_awt_motif_XsessionWMcommand;
# Java Plugin
# This is in awt_LoadLibrary.c and falls through to libmawt.
# Evidently plugin needs this for backward compatability.
getAwtLockFunctions;
getAwtData;
getAwtDisplay;
# libfontmanager entry points
AWTIsHeadless;
GrPrim_Sg2dGetCompInfo;
@ -283,11 +276,6 @@ SUNWprivate_1.1 {
# CDE private entry point
Java_sun_awt_motif_XsessionWMcommand;
# Java Plugin
getAwtLockFunctions;
getAwtData;
getAwtDisplay;
# libfontmanager entry points
AWTIsHeadless;
AWTCountFonts;

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -449,12 +449,6 @@ SUNWprivate_1.1 {
awt_Lock;
awt_GetComponent;
# Java Plugin
# This is in awt_LoadLibrary.c and falls through to libmawt.
# Evidently plugin needs this for backward compatability.
getAwtLockFunctions;
getAwtData;
getAwtDisplay;
#XAWT entry point for CDE
Java_sun_awt_motif_XsessionWMcommand;
Java_sun_awt_motif_XsessionWMcommand_New;

View File

@ -31,10 +31,6 @@ SUNWprivate_1.1 {
Java_sun_awt_image_JPEGImageDecoder_initIDs;
Java_sun_awt_image_JPEGImageDecoder_readImage;
Java_sun_awt_image_codec_JPEGImageDecoderImpl_initDecoder;
Java_sun_awt_image_codec_JPEGImageDecoderImpl_readJPEGStream;
Java_sun_awt_image_codec_JPEGImageEncoderImpl_initEncoder;
Java_sun_awt_image_codec_JPEGImageEncoderImpl_writeJPEGStream;
Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initReaderIDs;
Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initJPEGImageReader;

View File

@ -239,6 +239,4 @@ FULL_JRE_INCLUDE_METAINF_SERVICES := \
META-INF/services/javax.sound.sampled.spi.AudioFileReader \
META-INF/services/javax.sound.sampled.spi.AudioFileWriter \
META-INF/services/javax.sound.sampled.spi.FormatConversionProvider \
META-INF/services/javax.sound.sampled.spi.MixerProvider \
META-INF/services/sun.java2d.cmm.PCMM \
META-INF/services/sun.java2d.pipe.RenderingEngine
META-INF/services/javax.sound.sampled.spi.MixerProvider

View File

@ -121,6 +121,10 @@ class AquaComboBoxPopup extends BasicComboPopup {
public void show() {
final int startItemCount = comboBox.getItemCount();
if (startItemCount == 0) {
return;
}
final Rectangle popupBounds = adjustPopupAndGetBounds();
if (popupBounds == null) return; // null means don't show

View File

@ -46,10 +46,8 @@ import com.apple.laf.AquaIcon.JRSUIControlSpec;
import com.apple.laf.AquaIcon.SystemIcon;
import com.apple.laf.AquaUtils.RecyclableObject;
import com.apple.laf.AquaUtils.RecyclableSingleton;
import java.util.Arrays;
import java.util.List;
import sun.awt.image.MultiResolutionBufferedImage;
import sun.awt.image.MultiResolutionImage;
import sun.awt.image.MultiResolutionCachedImage;
public class AquaImageFactory {
public static IconUIResource getConfirmImageIcon() {
@ -57,7 +55,7 @@ public class AquaImageFactory {
return new IconUIResource(new AquaIcon.CachingScalingIcon(kAlertIconSize, kAlertIconSize) {
Image createImage() {
return getThisApplicationsIcon(kAlertIconSize, kAlertIconSize);
return getGenericJavaIcon();
}
});
}
@ -83,24 +81,6 @@ public class AquaImageFactory {
return getAppIconCompositedOn(lockIcon);
}
static Image getThisApplicationsIcon(final int width, final int height) {
final String path = getPathToThisApplication();
if (path == null) {
return getGenericJavaIcon();
}
if (path.endsWith("/Home/bin")) {
return getGenericJavaIcon();
}
if (path.startsWith("/usr/bin")) {
return getGenericJavaIcon();
}
return AquaUtils.getCImageCreator().createImageOfFile(path, height, width);
}
static Image getGenericJavaIcon() {
return java.security.AccessController.doPrivileged(new PrivilegedAction<Image>() {
public Image run() {
@ -125,9 +105,9 @@ public class AquaImageFactory {
private static final int kAlertIconSize = 64;
static IconUIResource getAppIconCompositedOn(final Image background) {
if (background instanceof MultiResolutionBufferedImage) {
if (background instanceof MultiResolutionCachedImage) {
int width = background.getWidth(null);
Image mrIconImage = ((MultiResolutionBufferedImage) background).map(
Image mrIconImage = ((MultiResolutionCachedImage) background).map(
rv -> getAppIconImageCompositedOn(rv, rv.getWidth(null) / width));
return new IconUIResource(new ImageIcon(mrIconImage));
}
@ -144,7 +124,7 @@ public class AquaImageFactory {
final Icon smallAppIconScaled = new AquaIcon.CachingScalingIcon(
kAlertSubIconSize, kAlertSubIconSize) {
Image createImage() {
return getThisApplicationsIcon(kAlertSubIconSize, kAlertSubIconSize);
return getGenericJavaIcon();
}
};
@ -306,21 +286,7 @@ public class AquaImageFactory {
private static Image getNSIcon(String imageName) {
Image icon = Toolkit.getDefaultToolkit()
.getImage("NSImage://" + imageName);
if (icon instanceof MultiResolutionImage) {
return icon;
}
int w = icon.getWidth(null);
int h = icon.getHeight(null);
Dimension[] sizes = new Dimension[]{
new Dimension(w, h), new Dimension(2 * w, 2 * h)
};
return new MultiResolutionBufferedImage(icon, sizes, (width, height) ->
AquaUtils.getCImageCreator().createImageFromName(
imageName, width, height));
return icon;
}
public static class NineSliceMetrics {
@ -530,4 +496,4 @@ public class AquaImageFactory {
public static Color getSelectionInactiveForegroundColorUIResource() {
return new SystemColorProxy(LWCToolkit.getAppleColor(LWCToolkit.INACTIVE_SELECTION_FOREGROUND_COLOR));
}
}
}

View File

@ -174,11 +174,7 @@ abstract class AquaPainter <T extends JRSUIState> {
bounds, controlState);
Image img = cache.getImage(key);
if (img == null) {
Image baseImage = createImage(imgX, imgY, imgW, imgH, bounds,
control, controlState);
img = new MultiResolutionBufferedImage(baseImage,
img = new MultiResolutionCachedImage(imgW, imgH,
(rvWidth, rvHeight) -> createImage(imgX, imgY,
rvWidth, rvHeight, bounds, control, controlState));

View File

@ -48,7 +48,7 @@ import sun.security.action.GetPropertyAction;
import sun.swing.SwingUtilities2;
import com.apple.laf.AquaImageFactory.SlicedImageControl;
import sun.awt.image.MultiResolutionBufferedImage;
import sun.awt.image.MultiResolutionCachedImage;
final class AquaUtils {
@ -124,8 +124,8 @@ final class AquaUtils {
static Image generateLightenedImage(final Image image, final int percent) {
final GrayFilter filter = new GrayFilter(true, percent);
return (image instanceof MultiResolutionBufferedImage)
? ((MultiResolutionBufferedImage) image).map(
return (image instanceof MultiResolutionCachedImage)
? ((MultiResolutionCachedImage) image).map(
rv -> generateLightenedImage(rv, filter))
: generateLightenedImage(image, filter);
}

View File

@ -40,7 +40,7 @@ import javax.swing.plaf.FontUIResource;
import sun.awt.FontConfiguration;
import sun.awt.HeadlessToolkit;
import sun.misc.ThreadGroupUtils;
import sun.awt.util.ThreadGroupUtils;
import sun.lwawt.macosx.*;
public class CFontManager extends SunFontManager {

View File

@ -171,7 +171,9 @@ final class LWChoicePeer extends LWComponentPeer<Choice, JComboBox<String>>
SwingUtilities.invokeLater(() -> {
JPopupMenu popupMenu = getPopupMenu();
// Need to override the invoker for proper grab handling
if (popupMenu != null && popupMenu.getInvoker() != getTarget()) {
if (popupMenu != null
&& popupMenu.isShowing()
&& popupMenu.getInvoker() != getTarget()) {
// The popup is now visible with correct location
// Save it and restore after toggling visibility and changing invoker
Point loc = popupMenu.getLocationOnScreen();

View File

@ -63,8 +63,6 @@ import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.RepaintManager;
import sun.lwawt.macosx.CDropTarget;
import com.sun.java.swing.SwingUtilities3;
public abstract class LWComponentPeer<T extends Component, D extends JComponent>
@ -137,7 +135,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
private final Object dropTargetLock = new Object();
private int fNumDropTargets = 0;
private CDropTarget fDropTarget = null;
private PlatformDropTarget fDropTarget = null;
private final PlatformComponent platformComponent;
@ -1063,11 +1061,11 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
// if it's the first (or last) one for the component. Otherwise this call is a no-op.
if (++fNumDropTargets == 1) {
// Having a non-null drop target would be an error but let's check just in case:
if (fDropTarget != null)
System.err.println("CComponent.addDropTarget(): current drop target is non-null.");
if (fDropTarget != null) {
throw new IllegalStateException("Current drop target is not null");
}
// Create a new drop target:
fDropTarget = CDropTarget.createDropTarget(dt, target, this);
fDropTarget = LWToolkit.getLWToolkit().createDropTarget(dt, target, this);
}
}
}

View File

@ -28,6 +28,7 @@ package sun.lwawt;
import java.awt.*;
import java.awt.List;
import java.awt.datatransfer.*;
import java.awt.dnd.DropTarget;
import java.awt.image.*;
import java.awt.peer.*;
import java.security.*;
@ -35,7 +36,7 @@ import java.util.*;
import sun.awt.*;
import sun.print.*;
import sun.misc.ThreadGroupUtils;
import sun.awt.util.ThreadGroupUtils;
import static sun.lwawt.LWWindowPeer.PeerType;
@ -440,6 +441,10 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
protected abstract FileDialogPeer createFileDialogPeer(FileDialog target);
protected abstract PlatformDropTarget createDropTarget(DropTarget dropTarget,
Component component,
LWComponentPeer<?, ?> peer);
// ---- UTILITY METHODS ---- //
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -23,32 +23,12 @@
* questions.
*/
/*
* Fix 4221246: Export functions for Netscape to use to get AWT info
*/
package sun.lwawt;
#ifndef _AWT_PLUGIN_H_
#define _AWT_PLUGIN_H_
public interface PlatformDropTarget {
#include <jni.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
void getAwtLockFunctions(void (**AwtLock)(JNIEnv *),
void (**AwtUnlock)(JNIEnv *),
void (**AwtNoFlushUnlock)(JNIEnv *),
void *);
void getExtAwtData(Display *,
int32_t,
int32_t *, /* awt_depth */
Colormap *, /* awt_cmap */
Visual **, /* awt_visInfo.visual */
int32_t *, /* awt_num_colors */
void *);
void getAwtData(int32_t *, Colormap *, Visual **, int32_t *, void *);
Display *getAwtDisplay(void);
#endif /* _AWT_PLUGIN_H_ */
/**
* Release native dragging destination, if any
*/
void dispose();
}

View File

@ -31,6 +31,7 @@ import sun.awt.image.ImageRepresentation;
import java.io.*;
import java.net.URL;
import java.nio.charset.Charset;
import java.text.Normalizer;
import java.text.Normalizer.Form;
import java.util.*;
@ -126,7 +127,7 @@ public class CDataTransferer extends DataTransferer {
if (format == CF_URL && URL.class.equals(flavor.getRepresentationClass()))
{
String charset = getDefaultTextCharset();
String charset = Charset.defaultCharset().name();
if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) {
try {
charset = new String((byte[])transferable.getTransferData(javaTextEncodingFlavor), "UTF-8");

View File

@ -25,54 +25,37 @@
package sun.lwawt.macosx;
import java.awt.Component;
import java.awt.peer.ComponentPeer;
import sun.lwawt.LWComponentPeer;
import sun.lwawt.PlatformDropTarget;
import java.awt.*;
import java.awt.dnd.DropTarget;
import sun.lwawt.LWComponentPeer;
import sun.lwawt.PlatformWindow;
final class CDropTarget implements PlatformDropTarget {
private long fNativeDropTarget;
public final class CDropTarget {
Component fComponent;
ComponentPeer fPeer;
DropTarget fDropTarget;
private long fNativeDropTarget;
public static CDropTarget createDropTarget(DropTarget dropTarget, Component component, ComponentPeer peer) {
return new CDropTarget(dropTarget, component, peer);
}
private CDropTarget(DropTarget dropTarget, Component component, ComponentPeer peer) {
super();
fDropTarget = dropTarget;
fComponent = component;
fPeer = peer;
long nativePeer = CPlatformWindow.getNativeViewPtr(((LWComponentPeer) peer).getPlatformWindow());
CDropTarget(DropTarget dropTarget, Component component, LWComponentPeer<?, ?> peer) {
long nativePeer = CPlatformWindow.getNativeViewPtr(peer.getPlatformWindow());
if (nativePeer == 0L) return; // Unsupported for a window without a native view (plugin)
// Create native dragging destination:
fNativeDropTarget = this.createNativeDropTarget(dropTarget, component, peer, nativePeer);
fNativeDropTarget = createNativeDropTarget(dropTarget, component, nativePeer);
if (fNativeDropTarget == 0) {
throw new IllegalStateException("CDropTarget.createNativeDropTarget() failed.");
}
}
public DropTarget getDropTarget() {
return fDropTarget;
}
@Override
public void dispose() {
// Release native dragging destination, if any:
if (fNativeDropTarget != 0) {
this.releaseNativeDropTarget(fNativeDropTarget);
releaseNativeDropTarget(fNativeDropTarget);
fNativeDropTarget = 0;
}
}
protected native long createNativeDropTarget(DropTarget dropTarget, Component component, ComponentPeer peer, long nativePeer);
protected native long createNativeDropTarget(DropTarget dropTarget,
Component component,
long nativePeer);
protected native void releaseNativeDropTarget(long nativeDropTarget);
}

View File

@ -32,7 +32,7 @@ import java.awt.image.*;
import java.util.Arrays;
import java.util.List;
import sun.awt.image.MultiResolutionImage;
import sun.awt.image.MultiResolutionBufferedImage;
import sun.awt.image.MultiResolutionCachedImage;
import sun.awt.image.SunWritableRaster;
@ -62,41 +62,41 @@ public class CImage extends CFRetainedResource {
// This is used to create a CImage with an NSImage pointer. It MUST be a CFRetained
// NSImage, and the CImage takes ownership of the non-GC retain. If callers need the
// NSImage themselves, they MUST call retain on the NSImage themselves.
public BufferedImage createImageUsingNativeSize(final long image) {
public Image createImageUsingNativeSize(final long image) {
if (image == 0) return null;
final Dimension2D size = nativeGetNSImageSize(image);
return createBufferedImage(image, size.getWidth(), size.getHeight());
return createImage(image, size.getWidth(), size.getHeight());
}
// the width and height passed in as a parameter could differ than the width and the height of the NSImage (image), in that case, the image will be scaled
BufferedImage createBufferedImage(long image, double width, double height) {
Image createImage(long image, double width, double height) {
if (image == 0) throw new Error("Unable to instantiate CImage with null native image reference.");
return createImageWithSize(image, width, height);
}
public BufferedImage createImageWithSize(final long image, final double width, final double height) {
public Image createImageWithSize(final long image, final double width, final double height) {
final CImage img = new CImage(image);
img.resize(width, height);
return img.toImage();
}
// This is used to create a CImage that represents the icon of the given file.
public BufferedImage createImageOfFile(final String file, final int width, final int height) {
return createBufferedImage(nativeCreateNSImageOfFileFromLaunchServices(file), width, height);
public Image createImageOfFile(final String file, final int width, final int height) {
return createImage(nativeCreateNSImageOfFileFromLaunchServices(file), width, height);
}
public BufferedImage createImageFromFile(final String file, final double width, final double height) {
public Image createImageFromFile(final String file, final double width, final double height) {
final long image = nativeCreateNSImageFromFileContents(file);
nativeSetNSImageSize(image, width, height);
return createBufferedImage(image, width, height);
return createImage(image, width, height);
}
public BufferedImage createSystemImageFromSelector(final String iconSelector, final int width, final int height) {
return createBufferedImage(nativeCreateNSImageFromIconSelector(getSelectorAsInt(iconSelector)), width, height);
public Image createSystemImageFromSelector(final String iconSelector, final int width, final int height) {
return createImage(nativeCreateNSImageFromIconSelector(getSelectorAsInt(iconSelector)), width, height);
}
public Image createImageFromName(final String name, final int width, final int height) {
return createBufferedImage(nativeCreateNSImageFromImageName(name), width, height);
return createImage(nativeCreateNSImageFromImageName(name), width, height);
}
public Image createImageFromName(final String name) {
@ -232,7 +232,7 @@ public class CImage extends CFRetainedResource {
}
/** @return A MultiResolution image created from nsImagePtr, or null. */
private BufferedImage toImage() {
private Image toImage() {
if (ptr == 0) return null;
final Dimension2D size = nativeGetNSImageSize(ptr);
@ -243,11 +243,11 @@ public class CImage extends CFRetainedResource {
= nativeGetNSImageRepresentationSizes(ptr,
size.getWidth(), size.getHeight());
BufferedImage baseImage = toImage(w, h, w, h);
return sizes == null || sizes.length < 2 ? baseImage
: new MultiResolutionBufferedImage(baseImage, sizes,
(width, height) -> toImage(w, h, width, height));
return sizes == null || sizes.length < 2 ?
new MultiResolutionCachedImage(w, h, (width, height)
-> toImage(w, h, width, height))
: new MultiResolutionCachedImage(w, h, sizes, (width, height)
-> toImage(w, h, width, height));
}
private BufferedImage toImage(int srcWidth, int srcHeight, int dstWidth, int dstHeight) {

View File

@ -309,6 +309,10 @@ public final class CWarningWindow extends CPlatformWindow
@Override
public void dispose() {
cancelTasks();
SurfaceData surfaceData = contentView.getSurfaceData();
if (surfaceData != null) {
surfaceData.invalidate();
}
super.dispose();
}

View File

@ -611,19 +611,20 @@ public final class LWCToolkit extends LWToolkit {
}
/**
* Kicks an event over to the appropriate eventqueue and waits for it to
* Kicks an event over to the appropriate event queue and waits for it to
* finish To avoid deadlocking, we manually run the NSRunLoop while waiting
* Any selector invoked using ThreadUtilities performOnMainThread will be
* processed in doAWTRunLoop The InvocationEvent will call
* LWCToolkit.stopAWTRunLoop() when finished, which will stop our manual
* runloop Does not dispatch native events while in the loop
* run loop. Does not dispatch native events while in the loop
*/
public static void invokeAndWait(Runnable runnable, Component component)
throws InvocationTargetException {
final long mediator = createAWTRunLoopMediator();
Objects.requireNonNull(component, "Null component provided to invokeAndWait");
long mediator = createAWTRunLoopMediator();
InvocationEvent invocationEvent =
new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(),
new InvocationEvent(component,
runnable,
() -> {
if (mediator != 0) {
@ -632,49 +633,42 @@ public final class LWCToolkit extends LWToolkit {
},
true);
if (component != null) {
AppContext appContext = SunToolkit.targetToAppContext(component);
SunToolkit.postEvent(appContext, invocationEvent);
// 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
SunToolkit.flushPendingEvents(appContext);
} else {
// This should be the equivalent to EventQueue.invokeAndWait
((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
}
AppContext appContext = SunToolkit.targetToAppContext(component);
SunToolkit.postEvent(appContext, invocationEvent);
// 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
SunToolkit.flushPendingEvents(appContext);
doAWTRunLoop(mediator, false);
Throwable eventException = invocationEvent.getException();
if (eventException != null) {
if (eventException instanceof UndeclaredThrowableException) {
eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
}
throw new InvocationTargetException(eventException);
}
checkException(invocationEvent);
}
public static void invokeLater(Runnable event, Component component)
throws InvocationTargetException {
final InvocationEvent invocationEvent =
new InvocationEvent(component != null ? component : Toolkit.getDefaultToolkit(), event);
Objects.requireNonNull(component, "Null component provided to invokeLater");
if (component != null) {
final AppContext appContext = SunToolkit.targetToAppContext(component);
SunToolkit.postEvent(appContext, invocationEvent);
InvocationEvent invocationEvent = new InvocationEvent(component, event);
// 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
SunToolkit.flushPendingEvents(appContext);
} else {
// This should be the equivalent to EventQueue.invokeAndWait
((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
}
AppContext appContext = SunToolkit.targetToAppContext(component);
SunToolkit.postEvent(SunToolkit.targetToAppContext(component), invocationEvent);
// 3746956 - flush events from PostEventQueue to prevent them from getting stuck and causing a deadlock
SunToolkit.flushPendingEvents(appContext);
final Throwable eventException = invocationEvent.getException();
checkException(invocationEvent);
}
/**
* Checks if exception occurred while {@code InvocationEvent} was processed and rethrows it as
* an {@code InvocationTargetException}
*
* @param event the event to check for an exception
* @throws InvocationTargetException if exception occurred when event was processed
*/
private static void checkException(InvocationEvent event) throws InvocationTargetException {
Throwable eventException = event.getException();
if (eventException == null) return;
if (eventException instanceof UndeclaredThrowableException) {
throw new InvocationTargetException(((UndeclaredThrowableException)eventException).getUndeclaredThrowable());
eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
}
throw new InvocationTargetException(eventException);
}
@ -686,11 +680,6 @@ public final class LWCToolkit extends LWToolkit {
*/
native static void performOnMainThreadAfterDelay(Runnable r, long delay);
// This exists purely to get around permissions issues with getSystemEventQueueImpl
EventQueue getSystemEventQueueForInvokeAndWait() {
return getSystemEventQueueImpl();
}
// DnD support
@Override
@ -712,7 +701,14 @@ public final class LWCToolkit extends LWToolkit {
return (T)dgr;
}
// InputMethodSupport Method
@Override
protected PlatformDropTarget createDropTarget(DropTarget dropTarget,
Component component,
LWComponentPeer<?, ?> peer) {
return new CDropTarget(dropTarget, component, peer);
}
// InputMethodSupport Method
/**
* Returns the default keyboard locale of the underlying operating system
*/

View File

@ -27,6 +27,7 @@
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
#import "jni_util.h"
#import "ThreadUtilities.h"
#import "AWTView.h"
@ -391,14 +392,12 @@ AWT_ASSERT_APPKIT_THREAD;
(jint)absP.x, (jint)absP.y,
[event deltaY],
[event deltaX]);
if (jEvent == nil) {
// Unable to create event by some reason.
return;
}
CHECK_NULL(jEvent);
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
JNFCallVoidMethod(env, m_cPlatformView, jm_deliverMouseEvent, jEvent);
(*env)->DeleteLocalRef(env, jEvent);
}
- (void) resetTrackingArea {
@ -447,20 +446,22 @@ AWT_ASSERT_APPKIT_THREAD;
static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;)V");
jobject jevent = JNFNewObject(env, jctor_NSEvent,
jobject jEvent = JNFNewObject(env, jctor_NSEvent,
[event type],
[event modifierFlags],
[event keyCode],
characters);
CHECK_NULL(jEvent);
static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView,
"deliverKeyEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
JNFCallVoidMethod(env, m_cPlatformView, jm_deliverKeyEvent, jevent);
JNFCallVoidMethod(env, m_cPlatformView, jm_deliverKeyEvent, jEvent);
if (characters != NULL) {
(*env)->DeleteLocalRef(env, characters);
}
(*env)->DeleteLocalRef(env, jEvent);
}
-(void) deliverResize: (NSRect) rect {

View File

@ -261,7 +261,8 @@ AWT_ASSERT_APPKIT_THREAD;
// returns id for the topmost window under mouse
+ (NSInteger) getTopmostWindowUnderMouseID {
NSInteger result = -1;
NSRect screenRect = [[NSScreen mainScreen] frame];
NSPoint nsMouseLocation = [NSEvent mouseLocation];
CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y);
@ -274,11 +275,13 @@ AWT_ASSERT_APPKIT_THREAD;
CGRect rect;
CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect);
if (CGRectContainsPoint(rect, cgMouseLocation)) {
return [[window objectForKey:(id)kCGWindowNumber] integerValue];
result = [[window objectForKey:(id)kCGWindowNumber] integerValue];
break;
}
}
}
return -1;
[windows release];
return result;
}
// checks that this window is under the mouse cursor and this point is not overlapped by others windows

View File

@ -48,7 +48,7 @@
+ (CDropTarget *) currentDropTarget;
// Common methods:
- (id)init:(jobject)dropTarget component:(jobject)jcomponent peer:(jobject)jpeer control:(id)control;
- (id)init:(jobject)dropTarget component:(jobject)jcomponent control:(id)control;
- (void)controlModelControlValid;
- (void)removeFromView:(JNIEnv *)env;

View File

@ -65,7 +65,7 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
return sCurrentDropTarget;
}
- (id)init:(jobject)jdropTarget component:(jobject)jcomponent peer:(jobject)jpeer control:(id)control
- (id)init:(jobject)jdropTarget component:(jobject)jcomponent control:(id)control
{
self = [super init];
DLog2(@"[CDropTarget init]: %@\n", self);
@ -714,13 +714,13 @@ extern JNFClassInfo jc_CDropTargetContextPeer;
* Signature: (Ljava/awt/dnd/DropTarget;Ljava/awt/Component;Ljava/awt/peer/ComponentPeer;J)J
*/
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDropTarget_createNativeDropTarget
(JNIEnv *env, jobject jthis, jobject jdroptarget, jobject jcomponent, jobject jpeer, jlong jnativepeer)
(JNIEnv *env, jobject jthis, jobject jdroptarget, jobject jcomponent, jlong jnativepeer)
{
CDropTarget* dropTarget = nil;
JNF_COCOA_ENTER(env);
id controlObj = (id) jlong_to_ptr(jnativepeer);
dropTarget = [[CDropTarget alloc] init:jdroptarget component:jcomponent peer:jpeer control:controlObj];
dropTarget = [[CDropTarget alloc] init:jdroptarget component:jcomponent control:controlObj];
JNF_COCOA_EXIT(env);
return ptr_to_jlong(dropTarget);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -66,7 +66,8 @@ static CFMutableArrayRef getAllValidDisplayModes(jint displayID){
CFArrayAppendValue(validModes, cRef);
}
}
CFRelease(allModes);
CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(displayID);
BOOL containsCurrentMode = NO;
@ -81,6 +82,7 @@ static CFMutableArrayRef getAllValidDisplayModes(jint displayID){
if (!containsCurrentMode) {
CFArrayAppendValue(validModes, currentMode);
}
CGDisplayModeRelease(currentMode);
return validModes;
}
@ -154,14 +156,12 @@ JNIEXPORT jdouble JNICALL
Java_sun_awt_CGraphicsDevice_nativeGetXResolution
(JNIEnv *env, jclass class, jint displayID)
{
// TODO: this is the physically correct answer, but we probably want
// to use NSScreen API instead...
// CGDisplayScreenSize can return 0 if displayID is invalid
CGSize size = CGDisplayScreenSize(displayID);
CGRect rect = CGDisplayBounds(displayID);
// 1 inch == 25.4 mm
jfloat inches = size.width / 25.4f;
jfloat dpi = rect.size.width / inches;
return dpi;
return inches > 0 ? rect.size.width / inches : 72;
}
/*
@ -173,14 +173,12 @@ JNIEXPORT jdouble JNICALL
Java_sun_awt_CGraphicsDevice_nativeGetYResolution
(JNIEnv *env, jclass class, jint displayID)
{
// TODO: this is the physically correct answer, but we probably want
// to use NSScreen API instead...
// CGDisplayScreenSize can return 0 if displayID is invalid
CGSize size = CGDisplayScreenSize(displayID);
CGRect rect = CGDisplayBounds(displayID);
// 1 inch == 25.4 mm
jfloat inches = size.height / 25.4f;
jfloat dpi = rect.size.height / inches;
return dpi;
return inches > 0 ? rect.size.height / inches : 72;
}
/*
@ -235,17 +233,19 @@ Java_sun_awt_CGraphicsDevice_nativeSetDisplayMode
{
JNF_COCOA_ENTER(env);
CFArrayRef allModes = getAllValidDisplayModes(displayID);
CGDisplayModeRef closestMatch = getBestModeForParameters(allModes, (int)w, (int)h, (int)bpp, (int)refrate);
__block CGError retCode = kCGErrorSuccess;
if (closestMatch != NULL) {
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
CGDisplayModeRetain(closestMatch);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
CGDisplayConfigRef config;
retCode = CGBeginDisplayConfiguration(&config);
if (retCode == kCGErrorSuccess) {
CGConfigureDisplayWithDisplayMode(config, displayID, closestMatch, NULL);
retCode = CGCompleteDisplayConfiguration(config, kCGConfigureForAppOnly);
}
CGDisplayModeRelease(closestMatch);
}];
} else {
[JNFException raise:env as:kIllegalArgumentException reason:"Invalid display mode"];
@ -253,8 +253,7 @@ Java_sun_awt_CGraphicsDevice_nativeSetDisplayMode
if (retCode != kCGErrorSuccess){
[JNFException raise:env as:kIllegalArgumentException reason:"Unable to set display mode!"];
}
}
CFRelease(allModes);
JNF_COCOA_EXIT(env);
}

View File

@ -76,17 +76,17 @@ static void CImage_CopyNSImageIntoArray
static NSBitmapImageRep* CImage_CreateImageRep(JNIEnv *env, jintArray buffer, jint width, jint height)
{
NSBitmapImageRep* imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:width
pixelsHigh:height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:NSAlphaFirstBitmapFormat
bytesPerRow:width*4 // TODO: use explicit scanStride
bitsPerPixel:32];
NSBitmapImageRep* imageRep = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:width
pixelsHigh:height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:NSAlphaFirstBitmapFormat
bytesPerRow:width*4 // TODO: use explicit scanStride
bitsPerPixel:32] autorelease];
jint *imgData = (jint *)[imageRep bitmapData];
if (imgData == NULL) return 0L;
@ -115,9 +115,8 @@ JNF_COCOA_ENTER(env);
NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
if (imageRep) {
NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(width, height)] retain];
NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
[nsImage addRepresentation:imageRep];
[imageRep release];
result = ptr_to_jlong(nsImage);
}
@ -160,7 +159,7 @@ JNF_COCOA_ENTER(env);
(*env)->ReleaseIntArrayElements(env, widths, ws, JNI_ABORT);
}
if ([reps count]) {
NSImage *nsImage = [[[NSImage alloc] initWithSize:NSMakeSize(0, 0)] retain];
NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(0, 0)];
[nsImage addRepresentations: reps];
result = ptr_to_jlong(nsImage);
}
@ -184,7 +183,7 @@ JNF_COCOA_ENTER(env);
IconRef iconRef;
if (noErr == GetIconRef(kOnSystemDisk, kSystemIconsCreator, selector, &iconRef)) {
image = [[[NSImage alloc] initWithIconRef:iconRef] retain];
image = [[NSImage alloc] initWithIconRef:iconRef];
ReleaseIconRef(iconRef);
}
@ -206,7 +205,7 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromFile
JNF_COCOA_ENTER(env);
NSString *path = JNFNormalizedNSStringForPath(env, file);
image = [[[NSImage alloc] initByReferencingFile:path] retain];
image = [[NSImage alloc] initByReferencingFile:path];
JNF_COCOA_EXIT(env);
@ -435,7 +434,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_lwawt_macosx_CImage_nativeGetPlatformImage
JNF_COCOA_ENTER(env);
NSBitmapImageRep* imageRep = [CImage_CreateImageRep(env, buffer, width, height) autorelease];
NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
if (imageRep) {
NSData *tiffImage = [imageRep TIFFRepresentation];
jsize tiffSize = (jsize)[tiffImage length];

View File

@ -25,6 +25,7 @@
#import <AppKit/AppKit.h>
#import <JavaNativeFoundation/JavaNativeFoundation.h>
#import "jni_util.h"
#import "CTrayIcon.h"
#import "ThreadUtilities.h"
@ -146,14 +147,12 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) {
(jint)absP.x, (jint)absP.y,
[event deltaY],
[event deltaX]);
if (jEvent == nil) {
// Unable to create event by some reason.
return;
}
CHECK_NULL(jEvent);
static JNF_CLASS_CACHE(jc_TrayIcon, "sun/lwawt/macosx/CTrayIcon");
static JNF_MEMBER_CACHE(jm_handleMouseEvent, jc_TrayIcon, "handleMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
JNFCallVoidMethod(env, peer, jm_handleMouseEvent, jEvent);
(*env)->DeleteLocalRef(env, jEvent);
}
@end //AWTTrayIcon

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -157,61 +157,6 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env);
}
static JNF_CLASS_CACHE(jc_Component, "java/awt/Component");
static JNF_MEMBER_CACHE(jf_Component_appContext, jc_Component, "appContext", "Lsun/awt/AppContext;");
static JNF_CLASS_CACHE(jc_MenuComponent, "java/awt/MenuComponent");
static JNF_MEMBER_CACHE(jf_MenuComponent_appContext, jc_MenuComponent, "appContext", "Lsun/awt/AppContext;");
/*
* Class: sun_awt_SunToolkit
* Method: getAppContext
* Signature: (Ljava/awt/Object;)Lsun/awt/AppContext;
*/
JNIEXPORT jobject JNICALL
Java_sun_awt_SunToolkit_getAppContext
(JNIEnv *env, jclass cls, jobject obj)
{
jobject appContext = NULL;
JNF_COCOA_ENTER(env);
if (JNFIsInstanceOf(env, obj, &jc_Component)) {
appContext = JNFGetObjectField(env, obj, jf_Component_appContext);
} else if (JNFIsInstanceOf(env, obj, &jc_MenuComponent)) {
appContext = JNFGetObjectField(env, obj, jf_MenuComponent_appContext);
}
JNF_COCOA_EXIT(env);
return appContext;
}
/*
* Class: sun_awt_SunToolkit
* Method: setAppContext
* Signature: (Ljava/lang/Object;Lsun/awt/AppContext;)Z
*/
JNIEXPORT jboolean JNICALL
Java_sun_awt_SunToolkit_setAppContext
(JNIEnv *env, jclass cls, jobject obj, jobject appContext)
{
jboolean isComponent;
JNF_COCOA_ENTER(env);
if (JNFIsInstanceOf(env, obj, &jc_Component)) {
JNFSetObjectField(env, obj, jf_Component_appContext, appContext);
isComponent = JNI_TRUE;
} else if (JNFIsInstanceOf(env, obj, &jc_MenuComponent)) {
JNFSetObjectField(env, obj, jf_MenuComponent_appContext, appContext);
isComponent = JNI_FALSE;
}
JNF_COCOA_EXIT(env);
return isComponent;
}
/*
* Class: sun_lwawt_macosx_LWCToolkit
* Method: beep

View File

@ -435,7 +435,7 @@ JNF_COCOA_ENTER(env);
forceEmbeddedMode = YES;
}
JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
jclass jc_ThreadGroupUtils = (*env)->FindClass(env, "sun/misc/ThreadGroupUtils");
jclass jc_ThreadGroupUtils = (*env)->FindClass(env, "sun/awt/util/ThreadGroupUtils");
jmethodID sjm_getRootThreadGroup = (*env)->GetStaticMethodID(env, jc_ThreadGroupUtils, "getRootThreadGroup", "()Ljava/lang/ThreadGroup;");
jobject rootThreadGroup = (*env)->CallStaticObjectMethod(env, jc_ThreadGroupUtils, sjm_getRootThreadGroup);
[ThreadUtilities setAppkitThreadGroup:(*env)->NewGlobalRef(env, rootThreadGroup)];

View File

@ -32,9 +32,10 @@
#define kInternalError "java/lang/InternalError"
#define AWT_DEBUG_LOG(str) \
NSLog(@"Cocoa AWT: %@ %@", str, [NSThread callStackSymbols])
NSLog(@"\tCocoa AWT: %@ %@", str, [NSThread callStackSymbols])
#define AWT_DEBUG_BUG_REPORT_MESSAGE \
NSLog(@"\tPlease file a bug report at http://java.net/jira/browse/MACOSX_PORT with this message and a reproducible test case.")
NSLog(@"\tPlease file a bug report at http://bugreport.java.com/bugreport \
with this message and a reproducible test case.")
#endif

View File

@ -664,6 +664,12 @@ public class PNGImageReader extends ImageReader {
try {
while (true) {
int chunkLength = stream.readInt();
// verify the chunk length first
if (chunkLength < 0 || chunkLength + 4 < 0) {
throw new IIOException("Invalid chunk length " + chunkLength);
}
int chunkType = stream.readInt();
if (chunkType == IDAT_TYPE) {
@ -692,7 +698,7 @@ public class PNGImageReader extends ImageReader {
// verify the chunk length
if (chunkLength < 0) {
throw new IIOException("Invalid chunk lenght " + chunkLength);
throw new IIOException("Invalid chunk length " + chunkLength);
};
try {

View File

@ -1683,6 +1683,7 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
* adjustments that windows/metal do. This is because gtk doesn't
* provide margins/insets for checkbox/radiobuttons.
*/
@SuppressWarnings("fallthrough")
private static class GnomeLayoutStyle extends DefaultLayoutStyle {
private static GnomeLayoutStyle INSTANCE = new GnomeLayoutStyle();

View File

@ -2409,6 +2409,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
// Windows LayoutStyle. From:
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
@SuppressWarnings("fallthrough")
private class WindowsLayoutStyle extends DefaultLayoutStyle {
@Override
public int getPreferredGap(JComponent component1,

View File

@ -51,6 +51,8 @@ import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
public class WindowsScrollBarUI extends BasicScrollBarUI {
private Grid thumbGrid;
private Grid highlightGrid;
private Dimension horizontalThumbSize;
private Dimension verticalThumbSize;
/**
* Creates a UI for a JScrollBar.
@ -65,11 +67,32 @@ public class WindowsScrollBarUI extends BasicScrollBarUI {
protected void installDefaults() {
super.installDefaults();
if (XPStyle.getXP() != null) {
XPStyle xp = XPStyle.getXP();
if (xp != null) {
scrollbar.setBorder(null);
horizontalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNHORZ);
verticalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNVERT);
} else {
horizontalThumbSize = null;
verticalThumbSize = null;
}
}
private static Dimension getSize(Component component, XPStyle xp, Part part) {
Skin skin = xp.getSkin(component, part);
return new Dimension(skin.getWidth(), skin.getHeight());
}
@Override
protected Dimension getMinimumThumbSize() {
if ((horizontalThumbSize == null) || (verticalThumbSize == null)) {
return super.getMinimumThumbSize();
}
return JScrollBar.HORIZONTAL == scrollbar.getOrientation()
? horizontalThumbSize
: verticalThumbSize;
}
public void uninstallUI(JComponent c) {
super.uninstallUI(c);
thumbGrid = highlightGrid = null;

View File

@ -182,7 +182,6 @@ public class WindowsTableHeaderUI extends BasicTableHeaderUI {
if (sortOrder != null) {
switch(sortOrder) {
case ASCENDING:
/* falls through */
case DESCENDING:
switch (state) {
case NORMAL:
@ -197,6 +196,7 @@ public class WindowsTableHeaderUI extends BasicTableHeaderUI {
default:
/* do nothing */
}
break;
default :
/* do nothing */
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -459,10 +459,10 @@ public final class Connection implements Runnable {
// will be woken up before readTimeout only if reply is
// available
ldr.wait(readTimeout);
waited = true;
} else {
ldr.wait(15 * 1000); // 15 second timeout
}
waited = true;
} else {
break;
}
@ -474,7 +474,7 @@ public final class Connection implements Runnable {
}
if ((rber == null) && waited) {
removeRequest(ldr);
abandonRequest(ldr, null);
throw new NamingException("LDAP response read timed out, timeout used:"
+ readTimeout + "ms." );

View File

@ -48,7 +48,7 @@ abstract class AbstractLine implements Line {
protected Control[] controls;
AbstractMixer mixer;
private boolean open = false;
private final Vector listeners = new Vector();
private final Vector<Object> listeners = new Vector<>();
/**
* Contains event dispatcher per thread group.

View File

@ -70,7 +70,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
/** List of Receivers and Transmitters that opened the device implicitely.
*/
private List openKeepingObjects;
private List<Object> openKeepingObjects;
/**
* This is the device handle returned from native code
@ -284,6 +284,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
@SuppressWarnings("unchecked") // Cast of result of clone
public final List<Receiver> getReceivers() {
List<Receiver> recs;
synchronized (traRecLock) {
@ -313,6 +314,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
}
@SuppressWarnings("unchecked") // Cast of result of clone
public final List<Transmitter> getTransmitters() {
List<Transmitter> tras;
synchronized (traRecLock) {
@ -372,9 +374,9 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice
/** Return the list of objects that have opened the device implicitely.
*/
private synchronized List getOpenKeepingObjects() {
private synchronized List<Object> getOpenKeepingObjects() {
if (openKeepingObjects == null) {
openKeepingObjects = new ArrayList();
openKeepingObjects = new ArrayList<>();
}
return openKeepingObjects;
}

View File

@ -90,13 +90,13 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
/**
* Source lines (ports) currently open
*/
private final Vector sourceLines = new Vector();
private final Vector<Line> sourceLines = new Vector<>();
/**
* Target lines currently open.
*/
private final Vector targetLines = new Vector();
private final Vector<Line> targetLines = new Vector<>();
/**
@ -151,7 +151,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
public final Line.Info[] getSourceLineInfo(Line.Info info) {
int i;
Vector vec = new Vector();
Vector<Line.Info> vec = new Vector<>();
for (i = 0; i < sourceLineInfo.length; i++) {
@ -162,7 +162,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
Line.Info[] returnedArray = new Line.Info[vec.size()];
for (i = 0; i < returnedArray.length; i++) {
returnedArray[i] = (Line.Info)vec.elementAt(i);
returnedArray[i] = vec.elementAt(i);
}
return returnedArray;
@ -172,7 +172,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
public final Line.Info[] getTargetLineInfo(Line.Info info) {
int i;
Vector vec = new Vector();
Vector<Line.Info> vec = new Vector<>();
for (i = 0; i < targetLineInfo.length; i++) {
@ -183,7 +183,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
Line.Info[] returnedArray = new Line.Info[vec.size()];
for (i = 0; i < returnedArray.length; i++) {
returnedArray[i] = (Line.Info)vec.elementAt(i);
returnedArray[i] = vec.elementAt(i);
}
return returnedArray;
@ -231,7 +231,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
localLines = new Line[sourceLines.size()];
for (int i = 0; i < localLines.length; i++) {
localLines[i] = (Line)sourceLines.elementAt(i);
localLines[i] = sourceLines.elementAt(i);
}
}
@ -248,7 +248,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
localLines = new Line[targetLines.size()];
for (int i = 0; i < localLines.length; i++) {
localLines[i] = (Line)targetLines.elementAt(i);
localLines[i] = targetLines.elementAt(i);
}
}
@ -453,7 +453,8 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
return;
}
Vector localSourceLines = (Vector)sourceLines.clone();
@SuppressWarnings("unchecked")
Vector<Line> localSourceLines = (Vector<Line>)sourceLines.clone();
for (int i = 0; i < localSourceLines.size(); i++) {
// if any other open line is running, return
@ -468,7 +469,8 @@ abstract class AbstractMixer extends AbstractLine implements Mixer {
}
}
Vector localTargetLines = (Vector)targetLines.clone();
@SuppressWarnings("unchecked")
Vector<Line> localTargetLines = (Vector<Line>)targetLines.clone();
for (int i = 0; i < localTargetLines.size(); i++) {
// if any other open line is running, return

View File

@ -213,7 +213,7 @@ public final class AlawCodec extends SunCodec {
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
Vector formats = new Vector();
Vector<AudioFormat> formats = new Vector<>();
AudioFormat format;
if ( AudioFormat.Encoding.PCM_SIGNED.equals(inputFormat.getEncoding())) {
@ -248,7 +248,7 @@ public final class AlawCodec extends SunCodec {
AudioFormat[] formatArray = new AudioFormat[formats.size()];
for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = (AudioFormat)(formats.elementAt(i));
formatArray[i] = formats.elementAt(i);
}
return formatArray;
}

View File

@ -68,7 +68,7 @@ public final class AudioSynthesizerPropertyInfo {
* The <code>valueClass</code> field specifies class
* used in <code>value</code> field.
*/
public Class valueClass = null;
public Class<?> valueClass = null;
/**
* An array of possible values if the value for the field
* <code>AudioSynthesizerPropertyInfo.value</code> may be selected

View File

@ -94,7 +94,7 @@ final class DirectAudioDevice extends AbstractMixer {
}
private DirectDLI createDataLineInfo(boolean isSource) {
Vector formats = new Vector();
Vector<AudioFormat> formats = new Vector<>();
AudioFormat[] hardwareFormatArray = null;
AudioFormat[] formatArray = null;
@ -107,7 +107,7 @@ final class DirectAudioDevice extends AbstractMixer {
int formatArraySize = size;
hardwareFormatArray = new AudioFormat[size];
for (int i = 0; i < size; i++) {
AudioFormat format = (AudioFormat)formats.elementAt(i);
AudioFormat format = formats.elementAt(i);
hardwareFormatArray[i] = format;
int bits = format.getSampleSizeInBits();
boolean isSigned = format.getEncoding().equals(AudioFormat.Encoding.PCM_SIGNED);
@ -265,7 +265,7 @@ final class DirectAudioDevice extends AbstractMixer {
return ((DirectAudioDeviceProvider.DirectAudioDeviceInfo) getMixerInfo()).getMaxSimulLines();
}
private static void addFormat(Vector v, int bits, int frameSizeInBytes, int channels, float sampleRate,
private static void addFormat(Vector<AudioFormat> v, int bits, int frameSizeInBytes, int channels, float sampleRate,
int encoding, boolean signed, boolean bigEndian) {
AudioFormat.Encoding enc = null;
switch (encoding) {
@ -338,7 +338,7 @@ final class DirectAudioDevice extends AbstractMixer {
private static final class DirectDLI extends DataLine.Info {
final AudioFormat[] hardwareFormats;
private DirectDLI(Class clazz, AudioFormat[] formatArray,
private DirectDLI(Class<?> clazz, AudioFormat[] formatArray,
AudioFormat[] hardwareFormatArray,
int minBuffer, int maxBuffer) {
super(clazz, formatArray, minBuffer, maxBuffer);
@ -1457,7 +1457,7 @@ final class DirectAudioDevice extends AbstractMixer {
} // class DirectBAOS
@SuppressWarnings("rawtypes")
private static native void nGetFormats(int mixerIndex, int deviceID,
boolean isSource, Vector formats);

View File

@ -57,7 +57,7 @@ final class EventDispatcher implements Runnable {
/**
* List of events
*/
private final ArrayList eventQueue = new ArrayList();
private final ArrayList<EventInfo> eventQueue = new ArrayList<>();
/**
@ -186,7 +186,7 @@ final class EventDispatcher implements Runnable {
}
if (eventQueue.size() > 0) {
// Remove the event from the queue and dispatch it to the listeners.
eventInfo = (EventInfo) eventQueue.remove(0);
eventInfo = eventQueue.remove(0);
}
} // end of synchronized
@ -230,7 +230,7 @@ final class EventDispatcher implements Runnable {
/**
* Send audio and MIDI events.
*/
void sendAudioEvents(Object event, List listeners) {
void sendAudioEvents(Object event, List<Object> listeners) {
if ((listeners == null)
|| (listeners.size() == 0)) {
// nothing to do
@ -392,7 +392,7 @@ final class EventDispatcher implements Runnable {
* @param event the event to be dispatched
* @param listeners listener list; will be copied
*/
EventInfo(Object event, List listeners) {
EventInfo(Object event, List<Object> listeners) {
this.event = event;
this.listeners = listeners.toArray();
}

View File

@ -118,7 +118,7 @@ public final class JDK13Services {
(the part before the hash sign), if available. If the property is
not set or the value has no provider class name part, null is returned.
*/
public static synchronized String getDefaultProviderClassName(Class typeClass) {
public static synchronized String getDefaultProviderClassName(Class<?> typeClass) {
String value = null;
String defaultProviderSpec = getDefaultProvider(typeClass);
if (defaultProviderSpec != null) {
@ -144,7 +144,7 @@ public final class JDK13Services {
part after the hash sign), if available. If the property is not set
or the value has no instance name part, null is returned.
*/
public static synchronized String getDefaultInstanceName(Class typeClass) {
public static synchronized String getDefaultInstanceName(Class<?> typeClass) {
String value = null;
String defaultProviderSpec = getDefaultProvider(typeClass);
if (defaultProviderSpec != null) {
@ -165,7 +165,7 @@ public final class JDK13Services {
@return The complete value of the property, if available.
If the property is not set, null is returned.
*/
private static synchronized String getDefaultProvider(Class typeClass) {
private static synchronized String getDefaultProvider(Class<?> typeClass) {
if (!SourceDataLine.class.equals(typeClass)
&& !TargetDataLine.class.equals(typeClass)
&& !Clip.class.equals(typeClass)

View File

@ -106,9 +106,9 @@ public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider {
* the new instance will not reflect that state...
*/
static final class MidiInDeviceInfo extends AbstractMidiDeviceProvider.Info {
private final Class providerClass;
private final Class<?> providerClass;
private MidiInDeviceInfo(int index, Class providerClass) {
private MidiInDeviceInfo(int index, Class<?> providerClass) {
super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index);
this.providerClass = providerClass;
}

View File

@ -104,9 +104,9 @@ public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider {
* the new instance will not reflect that state...
*/
static final class MidiOutDeviceInfo extends AbstractMidiDeviceProvider.Info {
private final Class providerClass;
private final Class<?> providerClass;
private MidiOutDeviceInfo(int index, Class providerClass) {
private MidiOutDeviceInfo(int index, Class<?> providerClass) {
super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index);
this.providerClass = providerClass;
}

View File

@ -295,7 +295,7 @@ public final class MidiUtils {
public synchronized void refresh(Sequence seq) {
ArrayList list = new ArrayList();
ArrayList<MidiEvent> list = new ArrayList<>();
Track[] tracks = seq.getTracks();
if (tracks.length > 0) {
// tempo events only occur in track 0
@ -313,7 +313,7 @@ public final class MidiUtils {
int size = list.size() + 1;
firstTempoIsFake = true;
if ((size > 1)
&& (((MidiEvent) list.get(0)).getTick() == 0)) {
&& (list.get(0).getTick() == 0)) {
// do not need to add an initial tempo event at the beginning
size--;
firstTempoIsFake = false;
@ -328,7 +328,7 @@ public final class MidiUtils {
e++;
}
for (int i = 0; i < list.size(); i++, e++) {
MidiEvent evt = (MidiEvent) list.get(i);
MidiEvent evt = list.get(i);
ticks[e] = evt.getTick();
tempos[e] = getTempoMPQ(evt.getMessage());
}

View File

@ -91,7 +91,7 @@ public final class PCMtoPCMCodec extends SunCodec {
// filter out targetEncoding from the old getOutputFormats( sourceFormat ) method
AudioFormat[] formats = getOutputFormats( sourceFormat );
Vector newFormats = new Vector();
Vector<AudioFormat> newFormats = new Vector<>();
for(int i=0; i<formats.length; i++ ) {
if( formats[i].getEncoding().equals( targetEncoding ) ) {
newFormats.addElement( formats[i] );
@ -101,7 +101,7 @@ public final class PCMtoPCMCodec extends SunCodec {
AudioFormat[] formatArray = new AudioFormat[newFormats.size()];
for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = (AudioFormat)(newFormats.elementAt(i));
formatArray[i] = newFormats.elementAt(i);
}
return formatArray;
@ -181,7 +181,7 @@ public final class PCMtoPCMCodec extends SunCodec {
/* public AudioFormat[] getOutputFormats(AudioFormat inputFormat) { */
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
Vector formats = new Vector();
Vector<AudioFormat> formats = new Vector<>();
AudioFormat format;
int sampleSize = inputFormat.getSampleSizeInBits();
@ -335,7 +335,7 @@ public final class PCMtoPCMCodec extends SunCodec {
for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = (AudioFormat)(formats.elementAt(i));
formatArray[i] = formats.elementAt(i);
}
}

View File

@ -253,12 +253,12 @@ final class PortMixer extends AbstractMixer {
long newID = ((PortMixer) mixer).getID();
if ((id == 0) || (newID != id) || (controls.length == 0)) {
id = newID;
Vector vector = new Vector();
Vector<Control> vector = new Vector<>();
synchronized (vector) {
nGetControls(id, portIndex, vector);
controls = new Control[vector.size()];
for (int i = 0; i < controls.length; i++) {
controls[i] = (Control) vector.elementAt(i);
controls[i] = vector.elementAt(i);
}
}
} else {
@ -494,6 +494,7 @@ final class PortMixer extends AbstractMixer {
private static native String nGetPortName(long id, int portIndex);
// fills the vector with the controls for this port
@SuppressWarnings("rawtypes")
private static native void nGetControls(long id, int portIndex, Vector vector);
// getters/setters for controls

View File

@ -122,7 +122,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
/**
* List of tracks to which we're recording
*/
private final List recordingTracks = new ArrayList();
private final List<RecordingTrack> recordingTracks = new ArrayList<>();
private long loopStart = 0;
@ -133,13 +133,13 @@ final class RealTimeSequencer extends AbstractMidiDevice
/**
* Meta event listeners
*/
private final ArrayList metaEventListeners = new ArrayList();
private final ArrayList<Object> metaEventListeners = new ArrayList<>();
/**
* Control change listeners
*/
private final ArrayList controllerEventListeners = new ArrayList();
private final ArrayList<ControllerListElement> controllerEventListeners = new ArrayList<>();
/** automatic connection support */
@ -645,7 +645,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
boolean flag = false;
for(int i=0; i < controllerEventListeners.size(); i++) {
cve = (ControllerListElement) controllerEventListeners.get(i);
cve = controllerEventListeners.get(i);
if (cve.listener.equals(listener)) {
cve.addControllers(controllers);
@ -669,7 +669,7 @@ final class RealTimeSequencer extends AbstractMidiDevice
ControllerListElement cve = null;
boolean flag = false;
for (int i=0; i < controllerEventListeners.size(); i++) {
cve = (ControllerListElement) controllerEventListeners.get(i);
cve = controllerEventListeners.get(i);
if (cve.listener.equals(listener)) {
cve.removeControllers(controllers);
flag = true;
@ -940,9 +940,9 @@ final class RealTimeSequencer extends AbstractMidiDevice
}
ShortMessage msg = (ShortMessage) message;
int controller = msg.getData1();
List sendToListeners = new ArrayList();
List<Object> sendToListeners = new ArrayList<>();
for (int i = 0; i < size; i++) {
ControllerListElement cve = (ControllerListElement) controllerEventListeners.get(i);
ControllerListElement cve = controllerEventListeners.get(i);
for(int j = 0; j < cve.controllers.length; j++) {
if (cve.controllers[j] == controller) {
sendToListeners.add(cve.listener);
@ -1213,13 +1213,13 @@ final class RealTimeSequencer extends AbstractMidiDevice
this.channel = channel;
}
static RecordingTrack get(List recordingTracks, Track track) {
static RecordingTrack get(List<RecordingTrack> recordingTracks, Track track) {
synchronized(recordingTracks) {
int size = recordingTracks.size();
for (int i = 0; i < size; i++) {
RecordingTrack current = (RecordingTrack)recordingTracks.get(i);
RecordingTrack current = recordingTracks.get(i);
if (current.track == track) {
return current;
}
@ -1228,12 +1228,12 @@ final class RealTimeSequencer extends AbstractMidiDevice
return null;
}
static Track get(List recordingTracks, int channel) {
static Track get(List<RecordingTrack> recordingTracks, int channel) {
synchronized(recordingTracks) {
int size = recordingTracks.size();
for (int i = 0; i < size; i++) {
RecordingTrack current = (RecordingTrack)recordingTracks.get(i);
RecordingTrack current = recordingTracks.get(i);
if ((current.channel == channel) || (current.channel == -1)) {
return current.track;
}

View File

@ -949,7 +949,7 @@ public final class SoftSynthesizer implements AudioSynthesizer,
Object v = (info == null) ? null : info.get(item2.name);
v = (v != null) ? v : storedProperties.getProperty(item2.name);
if (v != null) {
Class c = (item2.valueClass);
Class<?> c = (item2.valueClass);
if (c.isInstance(v))
item2.value = v;
else if (v instanceof String) {

View File

@ -198,7 +198,7 @@ public final class UlawCodec extends SunCodec {
/* public AudioFormat[] getOutputFormats(AudioFormat inputFormat) { */
private AudioFormat[] getOutputFormats(AudioFormat inputFormat) {
Vector formats = new Vector();
Vector<AudioFormat> formats = new Vector<>();
AudioFormat format;
if ((inputFormat.getSampleSizeInBits() == 16)
@ -235,7 +235,7 @@ public final class UlawCodec extends SunCodec {
AudioFormat[] formatArray = new AudioFormat[formats.size()];
for (int i = 0; i < formatArray.length; i++) {
formatArray[i] = (AudioFormat)(formats.elementAt(i));
formatArray[i] = formats.elementAt(i);
}
return formatArray;
}

View File

@ -86,7 +86,8 @@ public class AWTKeyStroke implements Serializable {
* Must be called under locked AWTKeyStro
*/
private static Class<AWTKeyStroke> getAWTKeyStrokeClass() {
Class<AWTKeyStroke> clazz = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
@SuppressWarnings("unchecked")
Class<AWTKeyStroke> clazz = (Class<AWTKeyStroke>)AppContext.getAppContext().get(AWTKeyStroke.class);
if (clazz == null) {
clazz = AWTKeyStroke.class;
AppContext.getAppContext().put(AWTKeyStroke.class, AWTKeyStroke.class);
@ -182,6 +183,7 @@ public class AWTKeyStroke implements Serializable {
throw new IllegalArgumentException("subclass cannot be null");
}
synchronized (AWTKeyStroke.class) {
@SuppressWarnings("unchecked")
Class<AWTKeyStroke> keyStrokeClass = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
if (keyStrokeClass != null && keyStrokeClass.equals(subclass)){
// Already registered
@ -192,7 +194,7 @@ public class AWTKeyStroke implements Serializable {
throw new ClassCastException("subclass is not derived from AWTKeyStroke");
}
Constructor ctor = getCtor(subclass);
Constructor<?> ctor = getCtor(subclass);
String couldNotInstantiate = "subclass could not be instantiated";
@ -227,12 +229,12 @@ public class AWTKeyStroke implements Serializable {
threat as accessible flag is set only for this Constructor object,
not for Class constructor.
*/
private static Constructor getCtor(final Class clazz)
private static Constructor<?> getCtor(final Class<?> clazz)
{
Constructor ctor = AccessController.doPrivileged(new PrivilegedAction<Constructor>() {
public Constructor run() {
Constructor<?> ctor = AccessController.doPrivileged(new PrivilegedAction<Constructor<?>>() {
public Constructor<?> run() {
try {
Constructor ctor = clazz.getDeclaredConstructor((Class[]) null);
Constructor<?> ctor = clazz.getDeclaredConstructor((Class<?>[]) null);
if (ctor != null) {
ctor.setAccessible(true);
}
@ -249,6 +251,7 @@ public class AWTKeyStroke implements Serializable {
private static synchronized AWTKeyStroke getCachedStroke
(char keyChar, int keyCode, int modifiers, boolean onKeyRelease)
{
@SuppressWarnings("unchecked")
Map<AWTKeyStroke, AWTKeyStroke> cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY);
AWTKeyStroke cacheKey = (AWTKeyStroke)AppContext.getAppContext().get(APP_CONTEXT_KEYSTROKE_KEY);

View File

@ -560,6 +560,7 @@ public class CardLayout implements LayoutManager2,
/**
* Reads serializable fields from stream.
*/
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException
{

View File

@ -6184,7 +6184,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
/**
* Parameter types of coalesceEvents(AWTEvent,AWTEVent).
*/
private static final Class[] coalesceEventsParams = {
private static final Class<?>[] coalesceEventsParams = {
AWTEvent.class, AWTEvent.class
};

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -95,18 +95,18 @@ public abstract class GraphicsEnvironment {
String nm = AccessController.doPrivileged(new GetPropertyAction("java.awt.graphicsenv", null));
try {
// long t0 = System.currentTimeMillis();
Class<GraphicsEnvironment> geCls;
Class<?> geCls;
try {
// First we try if the bootclassloader finds the requested
// class. This way we can avoid to run in a privileged block.
geCls = (Class<GraphicsEnvironment>)Class.forName(nm);
geCls = Class.forName(nm);
} catch (ClassNotFoundException ex) {
// If the bootclassloader fails, we try again with the
// application classloader.
ClassLoader cl = ClassLoader.getSystemClassLoader();
geCls = (Class<GraphicsEnvironment>)Class.forName(nm, true, cl);
geCls = Class.forName(nm, true, cl);
}
ge = geCls.newInstance();
ge = (GraphicsEnvironment)geCls.newInstance();
// long t1 = System.currentTimeMillis();
// System.out.println("GE creation took " + (t1-t0)+ "ms.");
if (isHeadless()) {

View File

@ -348,6 +348,7 @@ public abstract class KeyboardFocusManager
* Component of those Windows that has no such array of its own explicitly
* set.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
private Set<AWTKeyStroke>[] defaultFocusTraversalKeys = new Set[4];
/**
@ -422,7 +423,7 @@ public abstract class KeyboardFocusManager
targetSet.add(AWTKeyStroke.getAWTKeyStroke(tokens.nextToken()));
}
return (targetSet.isEmpty())
? Collections.EMPTY_SET
? Collections.emptySet()
: Collections.unmodifiableSet(targetSet);
}
@ -436,7 +437,7 @@ public abstract class KeyboardFocusManager
work_set.add(defaultFocusTraversalKeyStrokes[i][j]);
}
defaultFocusTraversalKeys[i] = (work_set.isEmpty())
? Collections.EMPTY_SET
? Collections.emptySet()
: Collections.unmodifiableSet(work_set);
}
initPeer();
@ -1750,11 +1751,12 @@ public abstract class KeyboardFocusManager
* @see #addKeyEventDispatcher
* @see #removeKeyEventDispatcher
*/
@SuppressWarnings("unchecked") // Cast of result of clone
protected synchronized java.util.List<KeyEventDispatcher>
getKeyEventDispatchers()
{
return (keyEventDispatchers != null)
? (java.util.List)keyEventDispatchers.clone()
? (java.util.List<KeyEventDispatcher>)keyEventDispatchers.clone()
: null;
}
@ -1841,11 +1843,12 @@ public abstract class KeyboardFocusManager
* @see #addKeyEventPostProcessor
* @see #removeKeyEventPostProcessor
*/
@SuppressWarnings("unchecked") // Cast of result of clone
protected java.util.List<KeyEventPostProcessor>
getKeyEventPostProcessors()
{
return (keyEventPostProcessors != null)
? (java.util.List)keyEventPostProcessors.clone()
? (java.util.List<KeyEventPostProcessor>)keyEventPostProcessors.clone()
: null;
}
@ -1907,8 +1910,7 @@ public abstract class KeyboardFocusManager
* javax.swing.JComponent.runInputVerifier() using reflection.
*/
static synchronized Component getMostRecentFocusOwner(Window window) {
WeakReference<Component> weakValue =
(WeakReference)mostRecentFocusOwners.get(window);
WeakReference<Component> weakValue = mostRecentFocusOwners.get(window);
return weakValue == null ? null : weakValue.get();
}

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

@ -259,7 +259,9 @@ public class SystemTray {
Vector<TrayIcon> icons = null;
synchronized (this) {
oldArray = systemTray.getTrayIcons();
icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
@SuppressWarnings("unchecked")
Vector<TrayIcon> tmp = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
icons = tmp;
if (icons == null) {
icons = new Vector<TrayIcon>(3);
AppContext.getAppContext().put(TrayIcon.class, icons);
@ -304,6 +306,7 @@ public class SystemTray {
TrayIcon[] oldArray = null, newArray = null;
synchronized (this) {
oldArray = systemTray.getTrayIcons();
@SuppressWarnings("unchecked")
Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
// TrayIcon with no peer is not contained in the array.
if (icons == null || !icons.remove(trayIcon)) {
@ -335,6 +338,7 @@ public class SystemTray {
* @see TrayIcon
*/
public TrayIcon[] getTrayIcons() {
@SuppressWarnings("unchecked")
Vector<TrayIcon> icons = (Vector<TrayIcon>)AppContext.getAppContext().get(TrayIcon.class);
if (icons != null) {
return icons.toArray(new TrayIcon[icons.size()]);

View File

@ -296,14 +296,14 @@ class MimeTypeParameterList implements Cloneable {
/**
* @return a clone of this object
*/
@SuppressWarnings("unchecked") // Cast from clone
public Object clone() {
MimeTypeParameterList newObj = null;
try {
newObj = (MimeTypeParameterList)super.clone();
} catch (CloneNotSupportedException cannotHappen) {
}
newObj.parameters = (Hashtable)parameters.clone();
newObj.parameters = (Hashtable<String, String>)parameters.clone();
return newObj;
}

View File

@ -38,13 +38,14 @@ import java.net.URL;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.WeakHashMap;
import sun.awt.AppContext;
import sun.awt.datatransfer.DataTransferer;
@ -101,20 +102,12 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
*/
private static final String HTML_TEXT_BASE_TYPE = "text/html";
/**
* This constant is passed to flavorToNativeLookup() to indicate that a
* a native should be synthesized, stored, and returned by encoding the
* DataFlavor's MIME type in case if the DataFlavor is not found in
* 'flavorToNative' map.
*/
private static final boolean SYNTHESIZE_IF_NOT_FOUND = true;
/**
* Maps native Strings to Lists of DataFlavors (or base type Strings for
* text DataFlavors).
* Do not use the field directly, use getNativeToFlavor() instead.
*/
private final Map<String, List<DataFlavor>> nativeToFlavor = new HashMap<>();
private final Map<String, LinkedHashSet<DataFlavor>> nativeToFlavor = new HashMap<>();
/**
* Accessor to nativeToFlavor map. Since we use lazy initialization we must
@ -123,7 +116,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
*
* @return nativeToFlavor
*/
private Map<String, List<DataFlavor>> getNativeToFlavor() {
private Map<String, LinkedHashSet<DataFlavor>> getNativeToFlavor() {
if (!isMapInitialized) {
initSystemFlavorMap();
}
@ -135,7 +128,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* native Strings.
* Do not use the field directly, use getFlavorToNative() instead.
*/
private final Map<DataFlavor, List<String>> flavorToNative = new HashMap<>();
private final Map<DataFlavor, LinkedHashSet<String>> flavorToNative = new HashMap<>();
/**
* Accessor to flavorToNative map. Since we use lazy initialization we must
@ -144,29 +137,52 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
*
* @return flavorToNative
*/
private synchronized Map<DataFlavor, List<String>> getFlavorToNative() {
private synchronized Map<DataFlavor, LinkedHashSet<String>> getFlavorToNative() {
if (!isMapInitialized) {
initSystemFlavorMap();
}
return flavorToNative;
}
/**
* Maps a text DataFlavor primary mime-type to the native. Used only to store
* standard mappings registered in the flavormap.properties
* Do not use this field directly, use getTextTypeToNative() instead.
*/
private Map<String, LinkedHashSet<String>> textTypeToNative = new HashMap<>();
/**
* Shows if the object has been initialized.
*/
private boolean isMapInitialized = false;
/**
* Caches the result of getNativesForFlavor(). Maps DataFlavors to
* SoftReferences which reference Lists of String natives.
* An accessor to textTypeToNative map. Since we use lazy initialization we
* must use this accessor instead of direct access to the field which may not
* be initialized yet. This method will initialize the field if needed.
*
* @return textTypeToNative
*/
private Map<DataFlavor, SoftReference<List<String>>> getNativesForFlavorCache = new HashMap<>();
private synchronized Map<String, LinkedHashSet<String>> getTextTypeToNative() {
if (!isMapInitialized) {
initSystemFlavorMap();
// From this point the map should not be modified
textTypeToNative = Collections.unmodifiableMap(textTypeToNative);
}
return textTypeToNative;
}
/**
* Caches the result of getNativesForFlavor(). Maps DataFlavors to
* SoftReferences which reference LinkedHashSet of String natives.
*/
private final SoftCache<DataFlavor, String> nativesForFlavorCache = new SoftCache<>();
/**
* Caches the result getFlavorsForNative(). Maps String natives to
* SoftReferences which reference Lists of DataFlavors.
* SoftReferences which reference LinkedHashSet of DataFlavors.
*/
private Map<String, SoftReference<List<DataFlavor>>> getFlavorsForNativeCache = new HashMap<>();
private final SoftCache<String, DataFlavor> flavorsForNativeCache = new SoftCache<>();
/**
* Dynamic mapping generation used for text mappings should not be applied
@ -174,7 +190,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* explicitly specified with setFlavorsForNative() or
* setNativesForFlavor(). This keeps all such keys.
*/
private Set disabledMappingGenerationKeys = new HashSet();
private Set<Object> disabledMappingGenerationKeys = new HashSet<>();
/**
* Returns the default FlavorMap for this thread's ClassLoader.
@ -404,7 +420,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
flavor = new DataFlavor(value);
} catch (Exception e) {
try {
flavor = new DataFlavor(value, (String)null);
flavor = new DataFlavor(value, null);
} catch (Exception ee) {
ee.printStackTrace();
continue;
@ -412,11 +428,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
}
final LinkedHashSet<DataFlavor> dfs = new LinkedHashSet<>();
dfs.add(flavor);
if ("text".equals(flavor.getPrimaryType())) {
dfs.addAll(convertMimeTypeToDataFlavors(value));
store(flavor.mimeType.getBaseType(), key, getTextTypeToNative());
}
for (DataFlavor df : dfs) {
@ -505,10 +521,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* the appropriate Map location, but rather will be appended to a List
* stored in that location.
*/
private <H, L> void store(H hashed, L listed, Map<H, List<L>> map) {
List<L> list = map.get(hashed);
private <H, L> void store(H hashed, L listed, Map<H, LinkedHashSet<L>> map) {
LinkedHashSet<L> list = map.get(hashed);
if (list == null) {
list = new ArrayList<>(1);
list = new LinkedHashSet<>(1);
map.put(hashed, list);
}
if (!list.contains(listed)) {
@ -522,17 +538,16 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* case, a new DataFlavor is synthesized, stored, and returned, if and
* only if the specified native is encoded as a Java MIME type.
*/
private List<DataFlavor> nativeToFlavorLookup(String nat) {
List<DataFlavor> flavors = getNativeToFlavor().get(nat);
private LinkedHashSet<DataFlavor> nativeToFlavorLookup(String nat) {
LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat);
if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
DataTransferer transferer = DataTransferer.getInstance();
if (transferer != null) {
List<DataFlavor> platformFlavors =
LinkedHashSet<DataFlavor> platformFlavors =
transferer.getPlatformMappingsForNative(nat);
if (!platformFlavors.isEmpty()) {
if (flavors != null) {
platformFlavors.removeAll(new HashSet<>(flavors));
// Prepending the platform-specific mappings ensures
// that the flavors added with
// addFlavorForUnencodedNative() are at the end of
@ -558,24 +573,22 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
}
if (flavor != null) {
flavors = new ArrayList<>(1);
flavors = new LinkedHashSet<>(1);
getNativeToFlavor().put(nat, flavors);
flavors.add(flavor);
getFlavorsForNativeCache.remove(nat);
getFlavorsForNativeCache.remove(null);
flavorsForNativeCache.remove(nat);
List<String> natives = getFlavorToNative().get(flavor);
LinkedHashSet<String> natives = getFlavorToNative().get(flavor);
if (natives == null) {
natives = new ArrayList<>(1);
natives = new LinkedHashSet<>(1);
getFlavorToNative().put(flavor, natives);
}
natives.add(nat);
getNativesForFlavorCache.remove(flavor);
getNativesForFlavorCache.remove(null);
nativesForFlavorCache.remove(flavor);
}
}
return (flavors != null) ? flavors : new ArrayList<>(0);
return (flavors != null) ? flavors : new LinkedHashSet<>(0);
}
/**
@ -586,18 +599,18 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* encoding the DataFlavor's MIME type. Otherwise an empty List is returned
* and 'flavorToNative' remains unaffected.
*/
private List<String> flavorToNativeLookup(final DataFlavor flav,
final boolean synthesize) {
List<String> natives = getFlavorToNative().get(flav);
private LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav,
final boolean synthesize) {
LinkedHashSet<String> natives = getFlavorToNative().get(flav);
if (flav != null && !disabledMappingGenerationKeys.contains(flav)) {
DataTransferer transferer = DataTransferer.getInstance();
if (transferer != null) {
List<String> platformNatives =
LinkedHashSet<String> platformNatives =
transferer.getPlatformMappingsForFlavor(flav);
if (!platformNatives.isEmpty()) {
if (natives != null) {
platformNatives.removeAll(new HashSet<>(natives));
// Prepend the platform-specific mappings to ensure
// that the natives added with
// addUnencodedNativeForFlavor() are at the end of
@ -612,26 +625,25 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
if (natives == null) {
if (synthesize) {
String encoded = encodeDataFlavor(flav);
natives = new ArrayList<>(1);
natives = new LinkedHashSet<>(1);
getFlavorToNative().put(flav, natives);
natives.add(encoded);
getNativesForFlavorCache.remove(flav);
getNativesForFlavorCache.remove(null);
List<DataFlavor> flavors = getNativeToFlavor().get(encoded);
LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded);
if (flavors == null) {
flavors = new ArrayList<>(1);
flavors = new LinkedHashSet<>(1);
getNativeToFlavor().put(encoded, flavors);
}
flavors.add(flav);
getFlavorsForNativeCache.remove(encoded);
getFlavorsForNativeCache.remove(null);
nativesForFlavorCache.remove(flav);
flavorsForNativeCache.remove(encoded);
} else {
natives = new ArrayList<>(0);
natives = new LinkedHashSet<>(0);
}
}
return natives;
return new LinkedHashSet<>(natives);
}
/**
@ -659,103 +671,63 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* @see #encodeDataFlavor
* @since 1.4
*/
@Override
public synchronized List<String> getNativesForFlavor(DataFlavor flav) {
List<String> retval = null;
// Check cache, even for null flav
SoftReference<List<String>> ref = getNativesForFlavorCache.get(flav);
if (ref != null) {
retval = ref.get();
if (retval != null) {
// Create a copy, because client code can modify the returned
// list.
return new ArrayList<>(retval);
}
LinkedHashSet<String> retval = nativesForFlavorCache.check(flav);
if (retval != null) {
return new ArrayList<>(retval);
}
if (flav == null) {
retval = new ArrayList<>(getNativeToFlavor().keySet());
retval = new LinkedHashSet<>(getNativeToFlavor().keySet());
} else if (disabledMappingGenerationKeys.contains(flav)) {
// In this case we shouldn't synthesize a native for this flavor,
// since its mappings were explicitly specified.
retval = flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND);
retval = flavorToNativeLookup(flav, false);
} else if (DataTransferer.isFlavorCharsetTextType(flav)) {
retval = new LinkedHashSet<>(0);
// For text/* flavors, flavor-to-native mappings specified in
// flavormap.properties are stored per flavor's base type.
if ("text".equals(flav.getPrimaryType())) {
retval = getAllNativesForType(flav.mimeType.getBaseType());
if (retval != null) {
// To prevent the List stored in the map from modification.
retval = new ArrayList(retval);
LinkedHashSet<String> textTypeNatives =
getTextTypeToNative().get(flav.mimeType.getBaseType());
if (textTypeNatives != null) {
retval.addAll(textTypeNatives);
}
}
// Also include text/plain natives, but don't duplicate Strings
List<String> textPlainList = getAllNativesForType(TEXT_PLAIN_BASE_TYPE);
if (textPlainList != null && !textPlainList.isEmpty()) {
// To prevent the List stored in the map from modification.
// This also guarantees that removeAll() is supported.
textPlainList = new ArrayList<>(textPlainList);
if (retval != null && !retval.isEmpty()) {
// Use HashSet to get constant-time performance for search.
textPlainList.removeAll(new HashSet<>(retval));
retval.addAll(textPlainList);
} else {
retval = textPlainList;
}
LinkedHashSet<String> textTypeNatives =
getTextTypeToNative().get(TEXT_PLAIN_BASE_TYPE);
if (textTypeNatives != null) {
retval.addAll(textTypeNatives);
}
if (retval == null || retval.isEmpty()) {
retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
if (retval.isEmpty()) {
retval = flavorToNativeLookup(flav, true);
} else {
// In this branch it is guaranteed that natives explicitly
// listed for flav's MIME type were added with
// addUnencodedNativeForFlavor(), so they have lower priority.
List<String> explicitList =
flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND);
// flavorToNativeLookup() never returns null.
// It can return an empty List, however.
if (!explicitList.isEmpty()) {
// To prevent the List stored in the map from modification.
// This also guarantees that removeAll() is supported.
explicitList = new ArrayList<>(explicitList);
// Use HashSet to get constant-time performance for search.
explicitList.removeAll(new HashSet<>(retval));
retval.addAll(explicitList);
}
retval.addAll(flavorToNativeLookup(flav, false));
}
} else if (DataTransferer.isFlavorNoncharsetTextType(flav)) {
retval = getAllNativesForType(flav.mimeType.getBaseType());
retval = getTextTypeToNative().get(flav.mimeType.getBaseType());
if (retval == null || retval.isEmpty()) {
retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
retval = flavorToNativeLookup(flav, true);
} else {
// In this branch it is guaranteed that natives explicitly
// listed for flav's MIME type were added with
// addUnencodedNativeForFlavor(), so they have lower priority.
List<String> explicitList =
flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND);
// flavorToNativeLookup() never returns null.
// It can return an empty List, however.
if (!explicitList.isEmpty()) {
// To prevent the List stored in the map from modification.
// This also guarantees that add/removeAll() are supported.
retval = new ArrayList<>(retval);
explicitList = new ArrayList<>(explicitList);
// Use HashSet to get constant-time performance for search.
explicitList.removeAll(new HashSet<>(retval));
retval.addAll(explicitList);
}
retval.addAll(flavorToNativeLookup(flav, false));
}
} else {
retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
retval = flavorToNativeLookup(flav, true);
}
getNativesForFlavorCache.put(flav, new SoftReference<>(retval));
nativesForFlavorCache.put(flav, retval);
// Create a copy, because client code can modify the returned list.
return new ArrayList<>(retval);
}
@ -791,62 +763,38 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* @see #encodeJavaMIMEType
* @since 1.4
*/
@Override
public synchronized List<DataFlavor> getFlavorsForNative(String nat) {
// Check cache, even for null nat
SoftReference<List<DataFlavor>> ref = getFlavorsForNativeCache.get(nat);
if (ref != null) {
List<DataFlavor> retval = ref.get();
if (retval != null) {
return new ArrayList<>(retval);
}
LinkedHashSet<DataFlavor> returnValue = flavorsForNativeCache.check(nat);
if (returnValue != null) {
return new ArrayList<>(returnValue);
} else {
returnValue = new LinkedHashSet<>();
}
final LinkedHashSet <DataFlavor> returnValue =
new LinkedHashSet<>();
if (nat == null) {
final List<String> natives = getNativesForFlavor(null);
for (String n : natives)
{
final List<DataFlavor> flavors = getFlavorsForNative(n);
for (DataFlavor df : flavors)
{
returnValue.add(df);
}
for (String n : getNativesForFlavor(null)) {
returnValue.addAll(getFlavorsForNative(n));
}
} else {
final List<DataFlavor> flavors = nativeToFlavorLookup(nat);
final LinkedHashSet<DataFlavor> flavors = nativeToFlavorLookup(nat);
if (disabledMappingGenerationKeys.contains(nat)) {
return flavors;
return new ArrayList<>(flavors);
}
final List<DataFlavor> flavorsAndBaseTypes =
nativeToFlavorLookup(nat);
final LinkedHashSet<DataFlavor> flavorsWithSynthesized =
nativeToFlavorLookup(nat);
for (DataFlavor df : flavorsAndBaseTypes) {
for (DataFlavor df : flavorsWithSynthesized) {
returnValue.add(df);
if ("text".equals(df.getPrimaryType())) {
try {
returnValue.addAll(
convertMimeTypeToDataFlavors(
new MimeType(df.getMimeType()
).getBaseType()));
} catch (MimeTypeParseException e) {
e.printStackTrace();
}
String baseType = df.mimeType.getBaseType();
returnValue.addAll(convertMimeTypeToDataFlavors(baseType));
}
}
}
final List<DataFlavor> arrayList = new ArrayList<>(returnValue);
getFlavorsForNativeCache.put(nat, new SoftReference<>(arrayList));
return new ArrayList<>(arrayList);
flavorsForNativeCache.put(nat, returnValue);
return new ArrayList<>(returnValue);
}
private static Set<DataFlavor> convertMimeTypeToDataFlavors(
@ -862,7 +810,6 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} catch (MimeTypeParseException mtpe) {
// Cannot happen, since we checked all mappings
// on load from flavormap.properties.
assert(false);
}
if (DataTransferer.doesSubtypeSupportCharset(subType, null)) {
@ -941,10 +888,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
}
private static final String [] htmlDocumntTypes =
new String [] {"all", "selection", "fragment"};
new String [] {"all", "selection", "fragment"};
private static LinkedHashSet<String> handleHtmlMimeTypes(
String baseType, String mimeType) {
private static LinkedHashSet<String> handleHtmlMimeTypes(String baseType,
String mimeType) {
LinkedHashSet<String> returnValues = new LinkedHashSet<>();
@ -981,14 +928,14 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* @see #getNativesForFlavor
* @see #encodeDataFlavor
*/
public synchronized Map<DataFlavor,String>
getNativesForFlavors(DataFlavor[] flavors)
@Override
public synchronized Map<DataFlavor,String> getNativesForFlavors(DataFlavor[] flavors)
{
// Use getNativesForFlavor to generate extra natives for text flavors
// and stringFlavor
if (flavors == null) {
List flavor_list = getFlavorsForNative(null);
List<DataFlavor> flavor_list = getFlavorsForNative(null);
flavors = new DataFlavor[flavor_list.size()];
flavor_list.toArray(flavors);
}
@ -1027,15 +974,14 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* @see #getFlavorsForNative
* @see #encodeJavaMIMEType
*/
public synchronized Map<String,DataFlavor>
getFlavorsForNatives(String[] natives)
@Override
public synchronized Map<String,DataFlavor> getFlavorsForNatives(String[] natives)
{
// Use getFlavorsForNative to generate extra flavors for text natives
if (natives == null) {
List native_list = getNativesForFlavor(null);
natives = new String[native_list.size()];
native_list.toArray(natives);
List<String> nativesList = getNativesForFlavor(null);
natives = new String[nativesList.size()];
nativesList.toArray(natives);
}
Map<String, DataFlavor> retval = new HashMap<>(natives.length, 1.0f);
@ -1044,7 +990,6 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
DataFlavor flav = (flavors.isEmpty())? null : flavors.get(0);
retval.put(aNative, flav);
}
return retval;
}
@ -1070,20 +1015,16 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
*/
public synchronized void addUnencodedNativeForFlavor(DataFlavor flav,
String nat) {
if (flav == null || nat == null) {
throw new NullPointerException("null arguments not permitted");
}
Objects.requireNonNull(nat, "Null native not permitted");
Objects.requireNonNull(flav, "Null flavor not permitted");
List<String> natives = getFlavorToNative().get(flav);
LinkedHashSet<String> natives = getFlavorToNative().get(flav);
if (natives == null) {
natives = new ArrayList<>(1);
natives = new LinkedHashSet<>(1);
getFlavorToNative().put(flav, natives);
} else if (natives.contains(nat)) {
return;
}
natives.add(nat);
getNativesForFlavorCache.remove(flav);
getNativesForFlavorCache.remove(null);
nativesForFlavorCache.remove(flav);
}
/**
@ -1116,18 +1057,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
*/
public synchronized void setNativesForFlavor(DataFlavor flav,
String[] natives) {
if (flav == null || natives == null) {
throw new NullPointerException("null arguments not permitted");
}
Objects.requireNonNull(natives, "Null natives not permitted");
Objects.requireNonNull(flav, "Null flavors not permitted");
getFlavorToNative().remove(flav);
for (String aNative : natives) {
addUnencodedNativeForFlavor(flav, aNative);
}
disabledMappingGenerationKeys.add(flav);
// Clear the cache to handle the case of empty natives.
getNativesForFlavorCache.remove(flav);
getNativesForFlavorCache.remove(null);
nativesForFlavorCache.remove(flav);
}
/**
@ -1150,20 +1088,16 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
*/
public synchronized void addFlavorForUnencodedNative(String nat,
DataFlavor flav) {
if (nat == null || flav == null) {
throw new NullPointerException("null arguments not permitted");
}
Objects.requireNonNull(nat, "Null native not permitted");
Objects.requireNonNull(flav, "Null flavor not permitted");
List<DataFlavor> flavors = getNativeToFlavor().get(nat);
LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat);
if (flavors == null) {
flavors = new ArrayList<>(1);
flavors = new LinkedHashSet<>(1);
getNativeToFlavor().put(nat, flavors);
} else if (flavors.contains(flav)) {
return;
}
flavors.add(flav);
getFlavorsForNativeCache.remove(nat);
getFlavorsForNativeCache.remove(null);
flavorsForNativeCache.remove(nat);
}
/**
@ -1195,18 +1129,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
*/
public synchronized void setFlavorsForNative(String nat,
DataFlavor[] flavors) {
if (nat == null || flavors == null) {
throw new NullPointerException("null arguments not permitted");
}
Objects.requireNonNull(nat, "Null native not permitted");
Objects.requireNonNull(flavors, "Null flavors not permitted");
getNativeToFlavor().remove(nat);
for (DataFlavor flavor : flavors) {
addFlavorForUnencodedNative(nat, flavor);
}
disabledMappingGenerationKeys.add(nat);
// Clear the cache to handle the case of empty flavors.
getFlavorsForNativeCache.remove(nat);
getFlavorsForNativeCache.remove(null);
flavorsForNativeCache.remove(nat);
}
/**
@ -1307,17 +1238,29 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
: null;
}
private List<String> getAllNativesForType(String type) {
Set<String> retval = null;
for (DataFlavor dataFlavor : convertMimeTypeToDataFlavors(type)) {
List<String> natives = getFlavorToNative().get(dataFlavor);
if (natives != null && !natives.isEmpty()) {
if (retval == null) {
retval = new LinkedHashSet<>();
}
retval.addAll(natives);
private static final class SoftCache<K, V> {
Map<K, SoftReference<LinkedHashSet<V>>> cache;
public void put(K key, LinkedHashSet<V> value) {
if (cache == null) {
cache = new HashMap<>(1);
}
cache.put(key, new SoftReference<>(value));
}
public void remove(K key) {
if (cache == null) return;
cache.remove(null);
cache.remove(key);
}
public LinkedHashSet<V> check(K key) {
if (cache == null) return null;
SoftReference<LinkedHashSet<V>> ref = cache.get(key);
if (ref != null) {
return ref.get();
}
return null;
}
return retval == null ? null : new ArrayList<>(retval);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -357,6 +357,7 @@ public class DragGestureEvent extends EventObject {
action = newAction;
// Pre-1.4 support. 'events' was previously non-transient
@SuppressWarnings("rawtypes")
List newEvents;
try {
newEvents = (List)f.get("events", null);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -97,9 +97,9 @@ import sun.awt.geom.AreaOp;
* @since 1.2
*/
public class Area implements Shape, Cloneable {
private static Vector EmptyCurves = new Vector();
private static Vector<Curve> EmptyCurves = new Vector<>();
private Vector curves;
private Vector<Curve> curves;
/**
* Default constructor which creates an empty area.
@ -127,8 +127,8 @@ public class Area implements Shape, Cloneable {
}
}
private static Vector pathToCurves(PathIterator pi) {
Vector curves = new Vector();
private static Vector<Curve> pathToCurves(PathIterator pi) {
Vector<Curve> curves = new Vector<>();
int windingRule = pi.getWindingRule();
// coords array is big enough for holding:
// coordinates returned from currentSegment (6)
@ -334,7 +334,7 @@ public class Area implements Shape, Cloneable {
* @since 1.2
*/
public void reset() {
curves = new Vector();
curves = new Vector<>();
invalidateBounds();
}
@ -357,9 +357,9 @@ public class Area implements Shape, Cloneable {
* @since 1.2
*/
public boolean isPolygonal() {
Enumeration enum_ = curves.elements();
Enumeration<Curve> enum_ = curves.elements();
while (enum_.hasMoreElements()) {
if (((Curve) enum_.nextElement()).getOrder() > 1) {
if (enum_.nextElement().getOrder() > 1) {
return false;
}
}
@ -381,8 +381,8 @@ public class Area implements Shape, Cloneable {
if (size > 3) {
return false;
}
Curve c1 = (Curve) curves.get(1);
Curve c2 = (Curve) curves.get(2);
Curve c1 = curves.get(1);
Curve c2 = curves.get(2);
if (c1.getOrder() != 1 || c2.getOrder() != 1) {
return false;
}
@ -411,10 +411,10 @@ public class Area implements Shape, Cloneable {
if (curves.size() < 3) {
return true;
}
Enumeration enum_ = curves.elements();
Enumeration<Curve> enum_ = curves.elements();
enum_.nextElement(); // First Order0 "moveto"
while (enum_.hasMoreElements()) {
if (((Curve) enum_.nextElement()).getOrder() == 0) {
if (enum_.nextElement().getOrder() == 0) {
return false;
}
}
@ -431,11 +431,11 @@ public class Area implements Shape, Cloneable {
}
Rectangle2D r = new Rectangle2D.Double();
if (curves.size() > 0) {
Curve c = (Curve) curves.get(0);
Curve c = curves.get(0);
// First point is always an order 0 curve (moveto)
r.setRect(c.getX0(), c.getY0(), 0, 0);
for (int i = 1; i < curves.size(); i++) {
((Curve) curves.get(i)).enlarge(r);
curves.get(i).enlarge(r);
}
}
return (cachedBounds = r);
@ -507,7 +507,7 @@ public class Area implements Shape, Cloneable {
if (other == null) {
return false;
}
Vector c = new AreaOp.XorOp().calculate(this.curves, other.curves);
Vector<Curve> c = new AreaOp.XorOp().calculate(this.curves, other.curves);
return c.isEmpty();
}
@ -555,10 +555,10 @@ public class Area implements Shape, Cloneable {
if (!getCachedBounds().contains(x, y)) {
return false;
}
Enumeration enum_ = curves.elements();
Enumeration<Curve> enum_ = curves.elements();
int crossings = 0;
while (enum_.hasMoreElements()) {
Curve c = (Curve) enum_.nextElement();
Curve c = enum_.nextElement();
crossings += c.crossingsFor(x, y);
}
return ((crossings & 1) == 1);
@ -658,16 +658,16 @@ public class Area implements Shape, Cloneable {
class AreaIterator implements PathIterator {
private AffineTransform transform;
private Vector curves;
private Vector<Curve> curves;
private int index;
private Curve prevcurve;
private Curve thiscurve;
public AreaIterator(Vector curves, AffineTransform at) {
public AreaIterator(Vector<Curve> curves, AffineTransform at) {
this.curves = curves;
this.transform = at;
if (curves.size() >= 1) {
thiscurve = (Curve) curves.get(0);
thiscurve = curves.get(0);
}
}
@ -689,7 +689,7 @@ class AreaIterator implements PathIterator {
prevcurve = thiscurve;
index++;
if (index < curves.size()) {
thiscurve = (Curve) curves.get(index);
thiscurve = curves.get(index);
if (thiscurve.getOrder() != 0 &&
prevcurve.getX1() == thiscurve.getX0() &&
prevcurve.getY1() == thiscurve.getY0())

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -76,7 +76,7 @@ public class BufferedImage extends java.awt.Image
ColorModel colorModel;
WritableRaster raster;
OffScreenImageSource osis;
Hashtable properties;
Hashtable<?, ?> properties;
boolean isAlphaPremultiplied;// If true, alpha has been premultiplied in
// color channels
@ -1106,7 +1106,7 @@ public class BufferedImage extends java.awt.Image
public ImageProducer getSource() {
if (osis == null) {
if (properties == null) {
properties = new Hashtable();
properties = new Hashtable<>();
}
osis = new OffScreenImageSource(this, properties);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -79,6 +79,7 @@ public class CropImageFilter extends ImageFilter {
* with the filtering operation.
*/
public void setProperties(Hashtable<?,?> props) {
@SuppressWarnings("unchecked")
Hashtable<Object,Object> p = (Hashtable<Object,Object>)props.clone();
p.put("croprect", new Rectangle(cropX, cropY, cropW, cropH));
super.setProperties(p);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -68,7 +68,7 @@ public class FilteredImageSource implements ImageProducer {
filter = imgf;
}
private Hashtable proxies;
private Hashtable<ImageConsumer, ImageFilter> proxies;
/**
* Adds the specified <code>ImageConsumer</code>
@ -94,7 +94,7 @@ public class FilteredImageSource implements ImageProducer {
*/
public synchronized void addConsumer(ImageConsumer ic) {
if (proxies == null) {
proxies = new Hashtable();
proxies = new Hashtable<>();
}
if (!proxies.containsKey(ic)) {
ImageFilter imgf = filter.getFilterInstance(ic);
@ -137,7 +137,7 @@ public class FilteredImageSource implements ImageProducer {
*/
public synchronized void removeConsumer(ImageConsumer ic) {
if (proxies != null) {
ImageFilter imgf = (ImageFilter) proxies.get(ic);
ImageFilter imgf = proxies.get(ic);
if (imgf != null) {
src.removeConsumer(imgf);
proxies.remove(ic);
@ -173,9 +173,9 @@ public class FilteredImageSource implements ImageProducer {
*/
public void startProduction(ImageConsumer ic) {
if (proxies == null) {
proxies = new Hashtable();
proxies = new Hashtable<>();
}
ImageFilter imgf = (ImageFilter) proxies.get(ic);
ImageFilter imgf = proxies.get(ic);
if (imgf == null) {
imgf = filter.getFilterInstance(ic);
proxies.put(ic, imgf);
@ -200,7 +200,7 @@ public class FilteredImageSource implements ImageProducer {
*/
public void requestTopDownLeftRightResend(ImageConsumer ic) {
if (proxies != null) {
ImageFilter imgf = (ImageFilter) proxies.get(ic);
ImageFilter imgf = proxies.get(ic);
if (imgf != null) {
imgf.resendTopDownLeftRight(src);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -104,6 +104,7 @@ public class ImageFilter implements ImageConsumer, Cloneable {
* @exception NullPointerException if <code>props</code> is null
*/
public void setProperties(Hashtable<?,?> props) {
@SuppressWarnings("unchecked")
Hashtable<Object,Object> p = (Hashtable<Object,Object>)props.clone();
Object o = p.get("filters");
if (o == null) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -111,8 +111,8 @@ public class MemoryImageSource implements ImageProducer {
Object pixels;
int pixeloffset;
int pixelscan;
Hashtable properties;
Vector theConsumers = new Vector();
Hashtable<?, ?> properties;
Vector<ImageConsumer> theConsumers = new Vector<>();
boolean animating;
boolean fullbuffers;
@ -197,7 +197,7 @@ public class MemoryImageSource implements ImageProducer {
}
private void initialize(int w, int h, ColorModel cm,
Object pix, int off, int scan, Hashtable props) {
Object pix, int off, int scan, Hashtable<?,?> props) {
width = w;
height = h;
model = cm;
@ -205,7 +205,7 @@ public class MemoryImageSource implements ImageProducer {
pixeloffset = off;
pixelscan = scan;
if (props == null) {
props = new Hashtable();
props = new Hashtable<>();
}
properties = props;
}
@ -343,9 +343,9 @@ public class MemoryImageSource implements ImageProducer {
public synchronized void setAnimated(boolean animated) {
this.animating = animated;
if (!animating) {
Enumeration enum_ = theConsumers.elements();
Enumeration<ImageConsumer> enum_ = theConsumers.elements();
while (enum_.hasMoreElements()) {
ImageConsumer ic = (ImageConsumer) enum_.nextElement();
ImageConsumer ic = enum_.nextElement();
ic.imageComplete(ImageConsumer.STATICIMAGEDONE);
if (isConsumer(ic)) {
ic.imageComplete(ImageConsumer.IMAGEERROR);
@ -376,9 +376,9 @@ public class MemoryImageSource implements ImageProducer {
}
this.fullbuffers = fullbuffers;
if (animating) {
Enumeration enum_ = theConsumers.elements();
Enumeration<ImageConsumer> enum_ = theConsumers.elements();
while (enum_.hasMoreElements()) {
ImageConsumer ic = (ImageConsumer) enum_.nextElement();
ImageConsumer ic = enum_.nextElement();
ic.setHints(fullbuffers
? (ImageConsumer.TOPDOWNLEFTRIGHT |
ImageConsumer.COMPLETESCANLINES)
@ -474,9 +474,9 @@ public class MemoryImageSource implements ImageProducer {
if ((w <= 0 || h <= 0) && !framenotify) {
return;
}
Enumeration enum_ = theConsumers.elements();
Enumeration<ImageConsumer> enum_ = theConsumers.elements();
while (enum_.hasMoreElements()) {
ImageConsumer ic = (ImageConsumer) enum_.nextElement();
ImageConsumer ic = enum_.nextElement();
if (w > 0 && h > 0) {
sendPixels(ic, x, y, w, h);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -121,6 +121,7 @@ public class ReplicateScaleFilter extends ImageFilter {
* with the filtering operation.
*/
public void setProperties(Hashtable<?,?> props) {
@SuppressWarnings("unchecked")
Hashtable<Object,Object> p = (Hashtable<Object,Object>)props.clone();
String key = "rescale";
String val = destWidth + "x" + destHeight;

View File

@ -153,6 +153,7 @@ public class ParameterBlock implements Cloneable, Serializable {
*
* @return an Object clone of the <code>ParameterBlock</code>.
*/
@SuppressWarnings("unchecked") // casts from clone
public Object clone() {
ParameterBlock theClone;
@ -164,10 +165,10 @@ public class ParameterBlock implements Cloneable, Serializable {
}
if (sources != null) {
theClone.setSources((Vector)sources.clone());
theClone.setSources((Vector<Object>)sources.clone());
}
if (parameters != null) {
theClone.setParameters((Vector)parameters.clone());
theClone.setParameters((Vector<Object>)parameters.clone());
}
return (Object) theClone;
}
@ -280,7 +281,7 @@ public class ParameterBlock implements Cloneable, Serializable {
/** Clears the list of source images. */
public void removeSources() {
sources = new Vector();
sources = new Vector<>();
}
/**
@ -313,7 +314,7 @@ public class ParameterBlock implements Cloneable, Serializable {
/** Clears the list of parameters. */
public void removeParameters() {
parameters = new Vector();
parameters = new Vector<>();
}
/**
@ -696,9 +697,9 @@ public class ParameterBlock implements Cloneable, Serializable {
* of the parameters.
* @return an array of <code>Class</code> objects.
*/
public Class [] getParamClasses() {
public Class<?>[] getParamClasses() {
int numParams = getNumParameters();
Class [] classes = new Class[numParams];
Class<?>[] classes = new Class<?>[numParams];
int i;
for (i = 0; i < numParams; i++) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -87,11 +87,11 @@ public class RenderableImageOp implements RenderableImage {
return getRenderableSources();
}
private Vector getRenderableSources() {
Vector sources = null;
private Vector<RenderableImage> getRenderableSources() {
Vector<RenderableImage> sources = null;
if (paramBlock.getNumSources() > 0) {
sources = new Vector();
sources = new Vector<>();
int i = 0;
while (i < paramBlock.getNumSources()) {
Object o = paramBlock.getSource(i);
@ -314,19 +314,19 @@ public class RenderableImageOp implements RenderableImage {
// contains RenderableImage sources, they will be replaced by
// RenderedImages.
ParameterBlock renderedParamBlock = (ParameterBlock)paramBlock.clone();
Vector sources = getRenderableSources();
Vector<? extends Object> sources = getRenderableSources();
try {
// This assumes that if there is no renderable source, that there
// is a rendered source in paramBlock
if (sources != null) {
Vector renderedSources = new Vector();
Vector<Object> renderedSources = new Vector<>();
for (int i = 0; i < sources.size(); i++) {
rcOut = myCRIF.mapRenderContext(i, renderContext,
paramBlock, this);
RenderedImage rdrdImage =
((RenderableImage)sources.elementAt(i)).createRendering(rcOut);
((RenderableImage)sources.elementAt(i)).createRendering(rcOut);
if (rdrdImage == null) {
return null;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -68,7 +68,7 @@ public class RenderableImageProducer implements ImageProducer, Runnable {
RenderContext rc;
/** A Vector of image consumers. */
Vector ics = new Vector();
Vector<ImageConsumer> ics = new Vector<>();
/**
* Constructs a new RenderableImageProducer from a RenderableImage
@ -177,12 +177,12 @@ public class RenderableImageProducer implements ImageProducer, Runnable {
int width = raster.getWidth();
int height = raster.getHeight();
Enumeration icList;
Enumeration<ImageConsumer> icList;
ImageConsumer ic;
// Set up the ImageConsumers
icList = ics.elements();
while (icList.hasMoreElements()) {
ic = (ImageConsumer)icList.nextElement();
ic = icList.nextElement();
ic.setDimensions(width,height);
ic.setHints(ImageConsumer.TOPDOWNLEFTRIGHT |
ImageConsumer.COMPLETESCANLINES |
@ -204,7 +204,7 @@ public class RenderableImageProducer implements ImageProducer, Runnable {
// Now send the scanline to the Consumers
icList = ics.elements();
while (icList.hasMoreElements()) {
ic = (ImageConsumer)icList.nextElement();
ic = icList.nextElement();
ic.setPixels(0, j, width, 1, colorModel, pix, 0, width);
}
}
@ -212,7 +212,7 @@ public class RenderableImageProducer implements ImageProducer, Runnable {
// Now tell the consumers we're done.
icList = ics.elements();
while (icList.hasMoreElements()) {
ic = (ImageConsumer)icList.nextElement();
ic = icList.nextElement();
ic.imageComplete(ImageConsumer.STATICIMAGEDONE);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -47,7 +47,7 @@ public class Book implements Pageable {
/**
* The set of pages that make up the Book.
*/
private Vector mPages;
private Vector<BookPage> mPages;
/* Instance Methods */
@ -55,7 +55,7 @@ public class Book implements Pageable {
* Creates a new, empty <code>Book</code>.
*/
public Book() {
mPages = new Vector();
mPages = new Vector<>();
}
/**
@ -167,7 +167,7 @@ public class Book implements Pageable {
private BookPage getPage(int pageIndex)
throws ArrayIndexOutOfBoundsException
{
return (BookPage) mPages.elementAt(pageIndex);
return mPages.elementAt(pageIndex);
}
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -74,9 +74,9 @@ public abstract class PrinterJob {
if (security != null) {
security.checkPrintJobAccess();
}
return (PrinterJob) java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<PrinterJob>() {
public PrinterJob run() {
String nm = System.getProperty("java.awt.printerjob", null);
try {
return (PrinterJob)Class.forName(nm).newInstance();

View File

@ -162,6 +162,16 @@ public class MethodDescriptor extends FeatureDescriptor {
: null;
}
private static Method resolve(Method oldMethod, Method newMethod) {
if (oldMethod == null) {
return newMethod;
}
if (newMethod == null) {
return oldMethod;
}
return !oldMethod.isSynthetic() && newMethod.isSynthetic() ? oldMethod : newMethod;
}
/*
* Package-private constructor
* Merge two method descriptors. Where they conflict, give the
@ -173,8 +183,7 @@ public class MethodDescriptor extends FeatureDescriptor {
MethodDescriptor(MethodDescriptor x, MethodDescriptor y) {
super(x, y);
Method method = y.methodRef.get();
this.methodRef.set(null != method ? method : x.methodRef.get());
this.methodRef.set(resolve(x.methodRef.get(), y.methodRef.get()));
params = x.params;
if (y.params != null) {
params = y.params;

View File

@ -25,6 +25,9 @@
package javax.accessibility;
import sun.awt.AWTAccessor;
import sun.awt.AppContext;
import java.util.Locale;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@ -79,6 +82,26 @@ import java.awt.IllegalComponentStateException;
*/
public abstract class AccessibleContext {
/**
* The AppContext that should be used to dispatch events for this
* AccessibleContext
*/
private volatile AppContext targetAppContext;
static {
AWTAccessor.setAccessibleContextAccessor(new AWTAccessor.AccessibleContextAccessor() {
@Override
public void setAppContext(AccessibleContext accessibleContext, AppContext appContext) {
accessibleContext.targetAppContext = appContext;
}
@Override
public AppContext getAppContext(AccessibleContext accessibleContext) {
return accessibleContext.targetAppContext;
}
});
}
/**
* Constant used to determine when the accessibleName property has
* changed. The old value in the PropertyChangeEvent will be the old

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,7 +35,7 @@ import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.UnsupportedAudioFileException;
/**
* Provider for audio file reading services. Classes providing concrete
* Provider for audio file reading services. Classes providing concrete
* implementations can parse the format information from one or more types of
* audio file, and can produce audio input streams from files of these types.
*
@ -45,93 +45,106 @@ import javax.sound.sampled.UnsupportedAudioFileException;
public abstract class AudioFileReader {
/**
* Obtains the audio file format of the input stream provided. The stream must
* point to valid audio file data. In general, audio file readers may
* Obtains the audio file format of the input stream provided. The stream
* must point to valid audio file data. In general, audio file readers may
* need to read some data from the stream before determining whether they
* support it. These parsers must
* be able to mark the stream, read enough data to determine whether they
* support the stream, and, if not, reset the stream's read pointer to its original
* position. If the input stream does not support this, this method may fail
* with an <code>IOException</code>.
* @param stream the input stream from which file format information should be
* extracted
* @return an <code>AudioFileFormat</code> object describing the audio file format
* @throws UnsupportedAudioFileException if the stream does not point to valid audio
* file data recognized by the system
* support it. These parsers must be able to mark the stream, read enough
* data to determine whether they support the stream, and, if not, reset the
* stream's read pointer to its original position. If the input stream does
* not support this, this method may fail with an {@code IOException}.
*
* @param stream the input stream from which file format information should
* be extracted
* @return an {@code AudioFileFormat} object describing the audio file
* format
* @throws UnsupportedAudioFileException if the stream does not point to
* valid audio file data recognized by the system
* @throws IOException if an I/O exception occurs
* @see InputStream#markSupported
* @see InputStream#mark
*/
public abstract AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException;
public abstract AudioFileFormat getAudioFileFormat(InputStream stream)
throws UnsupportedAudioFileException, IOException;
/**
* Obtains the audio file format of the URL provided. The URL must
* point to valid audio file data.
* @param url the URL from which file format information should be
* extracted
* @return an <code>AudioFileFormat</code> object describing the audio file format
* @throws UnsupportedAudioFileException if the URL does not point to valid audio
* file data recognized by the system
* Obtains the audio file format of the URL provided. The URL must point to
* valid audio file data.
*
* @param url the URL from which file format information should be
* extracted
* @return an {@code AudioFileFormat} object describing the audio file
* format
* @throws UnsupportedAudioFileException if the URL does not point to valid
* audio file data recognized by the system
* @throws IOException if an I/O exception occurs
*/
public abstract AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException;
public abstract AudioFileFormat getAudioFileFormat(URL url)
throws UnsupportedAudioFileException, IOException;
/**
* Obtains the audio file format of the <code>File</code> provided. The <code>File</code> must
* point to valid audio file data.
* @param file the <code>File</code> from which file format information should be
* extracted
* @return an <code>AudioFileFormat</code> object describing the audio file format
* @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
* file data recognized by the system
* Obtains the audio file format of the {@code File} provided.
* The {@code File} must point to valid audio file data.
*
* @param file the {@code File} from which file format information
* should be extracted
* @return an {@code AudioFileFormat} object describing the audio file
* format
* @throws UnsupportedAudioFileException if the {@code File} does not point
* to valid audio file data recognized by the system
* @throws IOException if an I/O exception occurs
*/
public abstract AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException;
public abstract AudioFileFormat getAudioFileFormat(File file)
throws UnsupportedAudioFileException, IOException;
/**
* Obtains an audio input stream from the input stream provided. The stream must
* point to valid audio file data. In general, audio file readers may
* Obtains an audio input stream from the input stream provided. The stream
* must point to valid audio file data. In general, audio file readers may
* need to read some data from the stream before determining whether they
* support it. These parsers must
* be able to mark the stream, read enough data to determine whether they
* support the stream, and, if not, reset the stream's read pointer to its original
* position. If the input stream does not support this, this method may fail
* with an <code>IOException</code>.
* @param stream the input stream from which the <code>AudioInputStream</code> should be
* constructed
* @return an <code>AudioInputStream</code> object based on the audio file data contained
* in the input stream.
* @throws UnsupportedAudioFileException if the stream does not point to valid audio
* file data recognized by the system
* support it. These parsers must be able to mark the stream, read enough
* data to determine whether they support the stream, and, if not, reset the
* stream's read pointer to its original position. If the input stream does
* not support this, this method may fail with an {@code IOException}.
*
* @param stream the input stream from which the {@code AudioInputStream}
* should be constructed
* @return an {@code AudioInputStream} object based on the audio file data
* contained in the input stream.
* @throws UnsupportedAudioFileException if the stream does not point to
* valid audio file data recognized by the system
* @throws IOException if an I/O exception occurs
* @see InputStream#markSupported
* @see InputStream#mark
*/
public abstract AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException;
public abstract AudioInputStream getAudioInputStream(InputStream stream)
throws UnsupportedAudioFileException, IOException;
/**
* Obtains an audio input stream from the URL provided. The URL must
* point to valid audio file data.
* @param url the URL for which the <code>AudioInputStream</code> should be
* constructed
* @return an <code>AudioInputStream</code> object based on the audio file data pointed
* to by the URL
* @throws UnsupportedAudioFileException if the URL does not point to valid audio
* file data recognized by the system
* Obtains an audio input stream from the URL provided. The URL must point
* to valid audio file data.
*
* @param url the URL for which the {@code AudioInputStream} should be
* constructed
* @return an {@code AudioInputStream} object based on the audio file data
* pointed to by the URL
* @throws UnsupportedAudioFileException if the URL does not point to valid
* audio file data recognized by the system
* @throws IOException if an I/O exception occurs
*/
public abstract AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException;
public abstract AudioInputStream getAudioInputStream(URL url)
throws UnsupportedAudioFileException, IOException;
/**
* Obtains an audio input stream from the <code>File</code> provided. The <code>File</code> must
* point to valid audio file data.
* @param file the <code>File</code> for which the <code>AudioInputStream</code> should be
* constructed
* @return an <code>AudioInputStream</code> object based on the audio file data pointed
* to by the File
* @throws UnsupportedAudioFileException if the <code>File</code> does not point to valid audio
* file data recognized by the system
* Obtains an audio input stream from the {@code File} provided.
* The {@code File} must point to valid audio file data.
*
* @param file the {@code File} for which the {@code AudioInputStream}
* should be constructed
* @return an {@code AudioInputStream} object based on the audio file data
* pointed to by the File
* @throws UnsupportedAudioFileException if the {@code File} does not point
* to valid audio file data recognized by the system
* @throws IOException if an I/O exception occurs
*/
public abstract AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException;
public abstract AudioInputStream getAudioInputStream(File file)
throws UnsupportedAudioFileException, IOException;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,16 +26,15 @@
package javax.sound.sampled.spi;
import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioInputStream;
import static javax.sound.sampled.AudioFileFormat.Type;
/**
* Provider for audio file writing services. Classes providing concrete
* Provider for audio file writing services. Classes providing concrete
* implementations can write one or more types of audio file from an audio
* stream.
*
@ -47,22 +46,23 @@ public abstract class AudioFileWriter {
/**
* Obtains the file types for which file writing support is provided by this
* audio file writer.
* @return array of file types. If no file types are supported,
* an array of length 0 is returned.
*
* @return array of file types. If no file types are supported, an array of
* length 0 is returned.
*/
public abstract AudioFileFormat.Type[] getAudioFileTypes();
public abstract Type[] getAudioFileTypes();
/**
* Indicates whether file writing support for the specified file type is provided
* by this audio file writer.
* @param fileType the file type for which write capabilities are queried
* @return <code>true</code> if the file type is supported,
* otherwise <code>false</code>
* Indicates whether file writing support for the specified file type is
* provided by this audio file writer.
*
* @param fileType the file type for which write capabilities are queried
* @return {@code true} if the file type is supported, otherwise
* {@code false}
*/
public boolean isFileTypeSupported(AudioFileFormat.Type fileType) {
public boolean isFileTypeSupported(Type fileType) {
AudioFileFormat.Type types[] = getAudioFileTypes();
Type types[] = getAudioFileTypes();
for(int i=0; i<types.length; i++) {
if( fileType.equals( types[i] ) ) {
@ -72,29 +72,29 @@ public abstract class AudioFileWriter {
return false;
}
/**
* Obtains the file types that this audio file writer can write from the
* audio input stream specified.
* @param stream the audio input stream for which audio file type support
* is queried
* @return array of file types. If no file types are supported,
* an array of length 0 is returned.
*
* @param stream the audio input stream for which audio file type support
* is queried
* @return array of file types. If no file types are supported, an array of
* length 0 is returned.
*/
public abstract AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream);
public abstract Type[] getAudioFileTypes(AudioInputStream stream);
/**
* Indicates whether an audio file of the type specified can be written
* from the audio input stream indicated.
* @param fileType file type for which write capabilities are queried
* @param stream for which file writing support is queried
* @return <code>true</code> if the file type is supported for this audio input stream,
* otherwise <code>false</code>
* Indicates whether an audio file of the type specified can be written from
* the audio input stream indicated.
*
* @param fileType file type for which write capabilities are queried
* @param stream for which file writing support is queried
* @return {@code true} if the file type is supported for this audio input
* stream, otherwise {@code false}
*/
public boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream stream) {
public boolean isFileTypeSupported(Type fileType, AudioInputStream stream) {
AudioFileFormat.Type types[] = getAudioFileTypes( stream );
Type types[] = getAudioFileTypes( stream );
for(int i=0; i<types.length; i++) {
if( fileType.equals( types[i] ) ) {
@ -104,44 +104,44 @@ public abstract class AudioFileWriter {
return false;
}
/**
* Writes a stream of bytes representing an audio file of the file type
* indicated to the output stream provided. Some file types require that
* indicated to the output stream provided. Some file types require that
* the length be written into the file header, and cannot be written from
* start to finish unless the length is known in advance. An attempt
* to write such a file type will fail with an IOException if the length in
* the audio file format is
* {@link javax.sound.sampled.AudioSystem#NOT_SPECIFIED AudioSystem.NOT_SPECIFIED}.
* @param stream the audio input stream containing audio data to be
* written to the output stream
* @param fileType file type to be written to the output stream
* @param out stream to which the file data should be written
* start to finish unless the length is known in advance. An attempt to
* write such a file type will fail with an IOException if the length in the
* audio file format is {@link javax.sound.sampled.AudioSystem#NOT_SPECIFIED
* AudioSystem.NOT_SPECIFIED}.
*
* @param stream the audio input stream containing audio data to be written
* to the output stream
* @param fileType file type to be written to the output stream
* @param out stream to which the file data should be written
* @return the number of bytes written to the output stream
* @throws IOException if an I/O exception occurs
* @throws IllegalArgumentException if the file type is not supported by
* the system
* @see #isFileTypeSupported(AudioFileFormat.Type, AudioInputStream)
* @throws IllegalArgumentException if the file type is not supported by the
* system
* @see #isFileTypeSupported(Type, AudioInputStream)
* @see #getAudioFileTypes
*/
public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException;
public abstract int write(AudioInputStream stream, Type fileType,
OutputStream out) throws IOException;
/**
* Writes a stream of bytes representing an audio file of the file format
* indicated to the external file provided.
* @param stream the audio input stream containing audio data to be
* written to the file
* @param fileType file type to be written to the file
* @param out external file to which the file data should be written
*
* @param stream the audio input stream containing audio data to be written
* to the file
* @param fileType file type to be written to the file
* @param out external file to which the file data should be written
* @return the number of bytes written to the file
* @throws IOException if an I/O exception occurs
* @throws IllegalArgumentException if the file format is not supported by
* the system
* the system
* @see #isFileTypeSupported
* @see #getAudioFileTypes
*/
public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException;
public abstract int write(AudioInputStream stream, Type fileType, File out)
throws IOException;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,63 +25,62 @@
package javax.sound.sampled.spi;
import java.io.InputStream;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import static javax.sound.sampled.AudioFormat.Encoding;
/**
* A format conversion provider provides format conversion services
* from one or more input formats to one or more output formats.
* Converters include codecs, which encode and/or decode audio data,
* as well as transcoders, etc. Format converters provide methods for
* determining what conversions are supported and for obtaining an audio
* stream from which converted data can be read.
* A format conversion provider provides format conversion services from one or
* more input formats to one or more output formats. Converters include codecs,
* which encode and/or decode audio data, as well as transcoders, etc. Format
* converters provide methods for determining what conversions are supported and
* for obtaining an audio stream from which converted data can be read.
* <p>
* The source format represents the format of the incoming
* audio data, which will be converted.
* The source format represents the format of the incoming audio data, which
* will be converted.
* <p>
* The target format represents the format of the processed, converted
* audio data. This is the format of the data that can be read from
* the stream returned by one of the <code>getAudioInputStream</code> methods.
* The target format represents the format of the processed, converted audio
* data. This is the format of the data that can be read from the stream
* returned by one of the {@code getAudioInputStream} methods.
*
* @author Kara Kytle
* @since 1.3
*/
public abstract class FormatConversionProvider {
// NEW METHODS
/**
* Obtains the set of source format encodings from which format
* conversion services are provided by this provider.
* Obtains the set of source format encodings from which format conversion
* services are provided by this provider.
*
* @return array of source format encodings. If for some reason provider
* does not provide any conversion services, an array of length 0 is
* returned.
* does not provide any conversion services, an array of length 0 is
* returned.
*/
public abstract AudioFormat.Encoding[] getSourceEncodings();
public abstract Encoding[] getSourceEncodings();
/**
* Obtains the set of target format encodings to which format
* conversion services are provided by this provider.
* Obtains the set of target format encodings to which format conversion
* services are provided by this provider.
*
* @return array of target format encodings. If for some reason provider
* does not provide any conversion services, an array of length 0 is
* returned.
* does not provide any conversion services, an array of length 0 is
* returned.
*/
public abstract AudioFormat.Encoding[] getTargetEncodings();
public abstract Encoding[] getTargetEncodings();
/**
* Indicates whether the format converter supports conversion from the
* specified source format encoding.
* @param sourceEncoding the source format encoding for which support is queried
* @return <code>true</code> if the encoding is supported, otherwise <code>false</code>
*
* @param sourceEncoding the source format encoding for which support is
* queried
* @return {@code true} if the encoding is supported, otherwise
* {@code false}
*/
public boolean isSourceEncodingSupported(AudioFormat.Encoding sourceEncoding){
public boolean isSourceEncodingSupported(Encoding sourceEncoding) {
AudioFormat.Encoding sourceEncodings[] = getSourceEncodings();
Encoding sourceEncodings[] = getSourceEncodings();
for(int i=0; i<sourceEncodings.length; i++) {
if( sourceEncoding.equals( sourceEncodings[i]) ) {
@ -91,16 +90,18 @@ public abstract class FormatConversionProvider {
return false;
}
/**
* Indicates whether the format converter supports conversion to the
* specified target format encoding.
* @param targetEncoding the target format encoding for which support is queried
* @return <code>true</code> if the encoding is supported, otherwise <code>false</code>
*
* @param targetEncoding the target format encoding for which support is
* queried
* @return {@code true} if the encoding is supported, otherwise
* {@code false}
*/
public boolean isTargetEncodingSupported(AudioFormat.Encoding targetEncoding){
public boolean isTargetEncodingSupported(Encoding targetEncoding) {
AudioFormat.Encoding targetEncodings[] = getTargetEncodings();
Encoding targetEncodings[] = getTargetEncodings();
for(int i=0; i<targetEncodings.length; i++) {
if( targetEncoding.equals( targetEncodings[i]) ) {
@ -110,28 +111,29 @@ public abstract class FormatConversionProvider {
return false;
}
/**
* Obtains the set of target format encodings supported by the format converter
* given a particular source format.
* If no target format encodings are supported for this source format,
* an array of length 0 is returned.
* @param sourceFormat format of the incoming data
* Obtains the set of target format encodings supported by the format
* converter given a particular source format. If no target format encodings
* are supported for this source format, an array of length 0 is returned.
*
* @param sourceFormat format of the incoming data
* @return array of supported target format encodings.
*/
public abstract AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat);
public abstract Encoding[] getTargetEncodings(AudioFormat sourceFormat);
/**
* Indicates whether the format converter supports conversion to a particular encoding
* from a particular format.
* @param targetEncoding desired encoding of the outgoing data
* @param sourceFormat format of the incoming data
* @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
* Indicates whether the format converter supports conversion to a
* particular encoding from a particular format.
*
* @param targetEncoding desired encoding of the outgoing data
* @param sourceFormat format of the incoming data
* @return {@code true} if the conversion is supported, otherwise
* {@code false}
*/
public boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){
public boolean isConversionSupported(Encoding targetEncoding,
AudioFormat sourceFormat) {
AudioFormat.Encoding targetEncodings[] = getTargetEncodings(sourceFormat);
Encoding targetEncodings[] = getTargetEncodings(sourceFormat);
for(int i=0; i<targetEncodings.length; i++) {
if( targetEncoding.equals( targetEncodings[i]) ) {
@ -141,27 +143,29 @@ public abstract class FormatConversionProvider {
return false;
}
/**
* Obtains the set of target formats with the encoding specified
* supported by the format converter
* If no target formats with the specified encoding are supported
* for this source format, an array of length 0 is returned.
* @param targetEncoding desired encoding of the stream after processing
* @param sourceFormat format of the incoming data
* Obtains the set of target formats with the encoding specified supported
* by the format converter If no target formats with the specified encoding
* are supported for this source format, an array of length 0 is returned.
*
* @param targetEncoding desired encoding of the stream after processing
* @param sourceFormat format of the incoming data
* @return array of supported target formats.
*/
public abstract AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat);
public abstract AudioFormat[] getTargetFormats(Encoding targetEncoding,
AudioFormat sourceFormat);
/**
* Indicates whether the format converter supports conversion to one
* particular format from another.
* @param targetFormat desired format of outgoing data
* @param sourceFormat format of the incoming data
* @return <code>true</code> if the conversion is supported, otherwise <code>false</code>
*
* @param targetFormat desired format of outgoing data
* @param sourceFormat format of the incoming data
* @return {@code true} if the conversion is supported, otherwise
* {@code false}
*/
public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat){
public boolean isConversionSupported(AudioFormat targetFormat,
AudioFormat sourceFormat) {
AudioFormat targetFormats[] = getTargetFormats( targetFormat.getEncoding(), sourceFormat );
@ -173,28 +177,33 @@ public abstract class FormatConversionProvider {
return false;
}
/**
* Obtains an audio input stream with the specified encoding from the given
* audio input stream.
*
* @param targetEncoding desired encoding of the stream after processing
* @param sourceStream stream from which data to be processed should be
* read
* @return stream from which processed data with the specified target
* encoding may be read
* @throws IllegalArgumentException if the format combination supplied is
* not supported.
*/
public abstract AudioInputStream getAudioInputStream(
Encoding targetEncoding, AudioInputStream sourceStream);
/**
* Obtains an audio input stream with the specified encoding from the given audio
* input stream.
* @param targetEncoding desired encoding of the stream after processing
* @param sourceStream stream from which data to be processed should be read
* @return stream from which processed data with the specified target encoding may be read
* Obtains an audio input stream with the specified format from the given
* audio input stream.
*
* @param targetFormat desired data format of the stream after processing
* @param sourceStream stream from which data to be processed should be
* read
* @return stream from which processed data with the specified format may be
* read
* @throws IllegalArgumentException if the format combination supplied is
* not supported.
* not supported.
*/
public abstract AudioInputStream getAudioInputStream(AudioFormat.Encoding targetEncoding, AudioInputStream sourceStream);
/**
* Obtains an audio input stream with the specified format from the given audio
* input stream.
* @param targetFormat desired data format of the stream after processing
* @param sourceStream stream from which data to be processed should be read
* @return stream from which processed data with the specified format may be read
* @throws IllegalArgumentException if the format combination supplied is
* not supported.
*/
public abstract AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream);
public abstract AudioInputStream getAudioInputStream(
AudioFormat targetFormat, AudioInputStream sourceStream);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,28 +28,27 @@ package javax.sound.sampled.spi;
import javax.sound.sampled.Mixer;
/**
* A provider or factory for a particular mixer type.
* This mechanism allows the implementation to determine
* how resources are managed in creation / management of
* a mixer.
* A provider or factory for a particular mixer type. This mechanism allows the
* implementation to determine how resources are managed in creation /
* management of a mixer.
*
* @author Kara Kytle
* @since 1.3
*/
public abstract class MixerProvider {
/**
* Indicates whether the mixer provider supports the mixer represented by
* the specified mixer info object.
* <p>
* The full set of mixer info objects that represent the mixers supported
* by this {@code MixerProvider} may be obtained
* through the {@code getMixerInfo} method.
* The full set of mixer info objects that represent the mixers supported by
* this {@code MixerProvider} may be obtained through the
* {@code getMixerInfo} method.
*
* @param info an info object that describes the mixer for which support is queried
* @return {@code true} if the specified mixer is supported,
* otherwise {@code false}
* @param info an info object that describes the mixer for which support is
* queried
* @return {@code true} if the specified mixer is supported, otherwise
* {@code false}
* @see #getMixerInfo()
*/
public boolean isMixerSupported(Mixer.Info info) {
@ -64,38 +63,34 @@ public abstract class MixerProvider {
return false;
}
/**
* Obtains the set of info objects representing the mixer
* or mixers provided by this MixerProvider.
* Obtains the set of info objects representing the mixer or mixers provided
* by this MixerProvider.
* <p>
* The {@code isMixerSupported} method returns {@code true}
* for all the info objects returned by this method.
* The corresponding mixer instances for the info objects
* are returned by the {@code getMixer} method.
* The {@code isMixerSupported} method returns {@code true} for all the info
* objects returned by this method. The corresponding mixer instances for
* the info objects are returned by the {@code getMixer} method.
*
* @return a set of mixer info objects
* @see #getMixer(javax.sound.sampled.Mixer.Info) getMixer(Mixer.Info)
* @see #isMixerSupported(javax.sound.sampled.Mixer.Info) isMixerSupported(Mixer.Info)
* @see #getMixer(Mixer.Info)
* @see #isMixerSupported(Mixer.Info)
*/
public abstract Mixer.Info[] getMixerInfo();
/**
* Obtains an instance of the mixer represented by the info object.
* <p>
* The full set of the mixer info objects that represent the mixers
* supported by this {@code MixerProvider} may be obtained
* through the {@code getMixerInfo} method.
* Use the {@code isMixerSupported} method to test whether
* this {@code MixerProvider} supports a particular mixer.
* supported by this {@code MixerProvider} may be obtained through the
* {@code getMixerInfo} method. Use the {@code isMixerSupported} method to
* test whether this {@code MixerProvider} supports a particular mixer.
*
* @param info an info object that describes the desired mixer
* @param info an info object that describes the desired mixer
* @return mixer instance
* @throws IllegalArgumentException if the info object specified does not
* match the info object for a mixer supported by this MixerProvider.
* match the info object for a mixer supported by this MixerProvider
* @see #getMixerInfo()
* @see #isMixerSupported(javax.sound.sampled.Mixer.Info) isMixerSupported(Mixer.Info)
* @see #isMixerSupported(Mixer.Info)
*/
public abstract Mixer getMixer(Mixer.Info info);
}

View File

@ -3986,7 +3986,18 @@ public abstract class JComponent extends Container implements Serializable,
* @see AccessibleKeyBinding
* @since 1.4
*/
public AccessibleKeyBinding getAccessibleKeyBinding() {
public AccessibleKeyBinding getAccessibleKeyBinding(){
// Try to get the linked label's mnemonic if it exists
Object o = getClientProperty(JLabel.LABELED_BY_PROPERTY);
if (o instanceof Accessible){
AccessibleContext ac = ((Accessible) o).getAccessibleContext();
if (ac != null){
AccessibleComponent comp = ac.getAccessibleComponent();
if (! (comp instanceof AccessibleExtendedComponent))
return null;
return ((AccessibleExtendedComponent)comp).getAccessibleKeyBinding();
}
}
return null;
}
} // inner class AccessibleJComponent

View File

@ -144,8 +144,8 @@ public class LineBorder extends AbstractBorder
int offs = this.thickness;
int size = offs + offs;
if (this.roundedCorners) {
int arc = offs + size;
outer = new RoundRectangle2D.Float(x, y, width, height, arc, arc);
float arc = .2f * offs;
outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
}
else {

View File

@ -2271,6 +2271,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
// From the JLF Design Guidelines:
// http://www.oracle.com/technetwork/java/jlf-135985.html
@SuppressWarnings("fallthrough")
private static class MetalLayoutStyle extends DefaultLayoutStyle {
private static MetalLayoutStyle INSTANCE = new MetalLayoutStyle();
@ -2407,4 +2408,4 @@ public class MetalLookAndFeel extends BasicLookAndFeel
return 0;
}
}
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
@ -13424,10 +13424,10 @@
<state stateKeys="Selected">
<style>
<textForeground>
<matte red="255" green="255" blue="255" alpha="255" uiDefaultParentName="nimbusLightBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
<matte red="255" green="255" blue="255" alpha="255" uiDefaultParentName="nimbusLightBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textForeground>
<textBackground>
<matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
<matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textBackground>
<background/>
<inherit-textForeground>false</inherit-textForeground>
@ -13453,7 +13453,7 @@
<style>
<textForeground/>
<textBackground>
<matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
<matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textBackground>
<background/>
<inherit-textBackground>false</inherit-textBackground>
@ -13477,7 +13477,7 @@
<state stateKeys="Disabled">
<style>
<textForeground>
<matte red="142" green="143" blue="145" alpha="255" uiDefaultParentName="nimbusDisabledText" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
<matte red="142" green="143" blue="145" alpha="255" uiDefaultParentName="nimbusDisabledText" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</textForeground>
<textBackground/>
<background/>
@ -13520,7 +13520,7 @@
</textForeground>
<textBackground/>
<background>
<matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0" uiResource="false"/>
<matte red="57" green="105" blue="138" alpha="255" uiDefaultParentName="nimbusSelectionBackground" hueOffset="0.0" saturationOffset="0.0" brightnessOffset="0.0" alphaOffset="0"/>
</background>
<inherit-textForeground>false</inherit-textForeground>
<inherit-background>false</inherit-background>

View File

@ -4473,6 +4473,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
// composed(uncommitted) text is done here after all input
// method listeners get called for stealing the events.
//
@SuppressWarnings("fallthrough")
protected void processInputMethodEvent(InputMethodEvent e) {
// let listeners handle the events
super.processInputMethodEvent(e);

View File

@ -2324,6 +2324,7 @@ public class StyleSheet extends StyleContext {
* @param itemNum number to format
* @param type type of ordered list
*/
@SuppressWarnings("fallthrough")
String formatItemNum(int itemNum, char type) {
String numStyle = "1";

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -92,12 +92,14 @@ class ContentModelState {
* tokens required in the input stream.
* @return true if the model can terminate without further input
*/
@SuppressWarnings("fallthrough")
public boolean terminate() {
switch (model.type) {
case '+':
if ((value == 0) && !(model).empty()) {
return false;
}
// Fall through
case '*':
case '?':
return (next == null) || next.terminate();

View File

@ -906,6 +906,7 @@ class Parser implements DTDConstants {
if (lower) {
ch = 'a' + (ch - 'A');
}
break;
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
@ -930,6 +931,7 @@ class Parser implements DTDConstants {
if (lower) {
ch = 'a' + (ch - 'A');
}
break;
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
@ -1268,6 +1270,7 @@ class Parser implements DTDConstants {
/**
* Parse attribute value. [33] 331:1
*/
@SuppressWarnings("fallthrough")
String parseAttributeValue(boolean lower) throws IOException {
int delim = -1;
@ -1312,6 +1315,7 @@ class Parser implements DTDConstants {
case '\t':
if (delim < 0)
c = ' ';
// Fall through
case ' ':
ch = readCh();
if (delim < 0) {
@ -1621,6 +1625,7 @@ class Parser implements DTDConstants {
/**
* Parse a start or end tag.
*/
@SuppressWarnings("fallthrough")
void parseTag() throws IOException {
Element elem;
boolean net = false;
@ -1664,6 +1669,7 @@ class Parser implements DTDConstants {
continue;
case '>':
ch = readCh();
return;
case -1:
return;
default:
@ -1688,6 +1694,7 @@ class Parser implements DTDConstants {
switch(ch) {
case '>':
ch = readCh();
// Fall through
case -1:
error("invalid.markup");
return;
@ -1719,6 +1726,7 @@ class Parser implements DTDConstants {
switch (ch = readCh()) {
case '>':
ch = readCh();
// Fall through
case '<':
// empty end tag. either </> or </<
if (recent == null) {
@ -1737,6 +1745,7 @@ class Parser implements DTDConstants {
switch (ch) {
case '>':
ch = readCh();
break;
case '<':
break;
@ -1937,6 +1946,7 @@ class Parser implements DTDConstants {
switch (ch) {
case '/':
net = true;
// Fall through
case '>':
ch = readCh();
if (ch == '>' && net) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -868,6 +868,7 @@ public void writeEndgroup()
afterKeyword = false;
}
@SuppressWarnings("fallthrough")
public void writeCharacter(char ch)
throws IOException
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -148,6 +148,7 @@ abstract class RTFParser extends AbstractFilter
handleText(s);
}
@SuppressWarnings("fallthrough")
public void write(char ch)
throws IOException
{

View File

@ -27,6 +27,7 @@ package sun.awt;
import sun.misc.Unsafe;
import javax.accessibility.AccessibleContext;
import java.awt.*;
import java.awt.KeyboardFocusManager;
import java.awt.DefaultKeyboardFocusManager;
@ -620,7 +621,7 @@ public final class AWTAccessor {
/**
* Returns menus
*/
Vector getMenus(MenuBar menuBar);
Vector<Menu> getMenus(MenuBar menuBar);
}
/**
@ -662,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);
}
/**
@ -761,6 +762,14 @@ public final class AWTAccessor {
void updateSystemColors();
}
/*
* An accessor object for the AccessibleContext class
*/
public interface AccessibleContextAccessor {
void setAppContext(AccessibleContext accessibleContext, AppContext appContext);
AppContext getAppContext(AccessibleContext accessibleContext);
}
/*
* Accessor instances are initialized in the static initializers of
* corresponding AWT classes by using setters defined below.
@ -791,6 +800,7 @@ public final class AWTAccessor {
private static ToolkitAccessor toolkitAccessor;
private static InvocationEventAccessor invocationEventAccessor;
private static SystemColorAccessor systemColorAccessor;
private static AccessibleContextAccessor accessibleContextAccessor;
/*
* Set an accessor object for the java.awt.Component class.
@ -1234,4 +1244,21 @@ public final class AWTAccessor {
public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) {
AWTAccessor.systemColorAccessor = systemColorAccessor;
}
/*
* Get the accessor object for the javax.accessibility.AccessibleContext class.
*/
public static AccessibleContextAccessor getAccessibleContextAccessor() {
if (accessibleContextAccessor == null) {
unsafe.ensureClassInitialized(AccessibleContext.class);
}
return accessibleContextAccessor;
}
/*
* Set the accessor object for the javax.accessibility.AccessibleContext class.
*/
public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
AWTAccessor.accessibleContextAccessor = accessor;
}
}

View File

@ -35,7 +35,7 @@ import java.util.Map;
import java.util.Set;
import sun.util.logging.PlatformLogger;
import sun.misc.ThreadGroupUtils;
import sun.awt.util.ThreadGroupUtils;
/**
* This class is to let AWT shutdown automatically when a user is done

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;
}

Some files were not shown because too many files have changed in this diff Show More