提交 c0e44a94 编写于 作者: M mullan

Merge

......@@ -175,3 +175,4 @@ e4bae5c53fca8fcb9393d47fd36a34b9e2e8d4ec jdk8-b50
e865efbc71059a414b3b2dd2e0adfcb3d2ab6ff9 jdk8-b51
e8569a473cee7f4955bd9e76a9bdf6c6a07ced27 jdk8-b52
2c6933c5106b81a8578b70996fe5b735fb3adb60 jdk8-b53
70ad0ed1d6cef0e7712690d1bab21e4769708aad jdk8-b54
......@@ -125,6 +125,26 @@ ifeq ($(PLATFORM), windows)
OTHER_LDLIBS += jli.lib
endif
#
# Applications expect to be able to link against libjawt without invoking
# System.loadLibrary("jawt") first. This was the behaviour described in the
# devloper documentation of JAWT and what worked with OpenJDK6.
#
ifeq ($(PLATFORM), solaris)
ifeq ($(ARCH_DATA_MODEL), 32)
LDFLAGS += -R \$$ORIGIN/../lib/$(LIBARCH)
LDFLAGS += -R \$$ORIGIN/../jre/lib/$(LIBARCH)
else # ! ARCH_DATA_MODEL 64-bit
LDFLAGS += -R \$$ORIGIN/../../lib/$(LIBARCH)
LDFLAGS += -R \$$ORIGIN/../../jre/lib/$(LIBARCH)
endif # ARCH_DATA_MODEL
endif # PLATFORM SOLARIS
ifeq ($(PLATFORM), linux)
LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../lib/$(LIBARCH)
LDFLAGS += -Wl,-rpath -Wl,\$$ORIGIN/../jre/lib/$(LIBARCH)
endif # PLATFORM LINUX
#
# Launcher specific files.
#
......
......@@ -73,7 +73,7 @@ ifeq ($(ARCH_DATA_MODEL),64)
else ifeq ($(ARCH),universal)
MAX_VM_MEMORY = 1024
else
MAX_VM_MEMORY = 612
MAX_VM_MEMORY = 768
endif
# List of all possible directories for javadoc to look for sources
......
......@@ -87,7 +87,7 @@ else
endif
SUBDIRS_desktop = audio $(RENDER_SUBDIR) image \
$(LWAWT_PRE_SUBDIR) $(DISPLAY_LIBS) $(DGA_SUBDIR) $(LWAWT_SUBDIR) \
jawt font jpeg cmm $(DISPLAY_TOOLS) beans
jawt font jpeg cmm $(DISPLAY_TOOLS)
SUBDIRS_management = management
SUBDIRS_misc = $(ORG_SUBDIR) rmi $(JDBC_SUBDIR) tracing
SUBDIRS_tools = native2ascii serialver tools jconsole
......
#
# Copyright (c) 1997, 2005, 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
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#
# Makefile for building sun.beans.*
#
BUILDDIR = ../..
PACKAGE = sun.beans
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
#
# Files
#
AUTO_FILES_JAVA_DIRS = sun/beans
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
......@@ -30,6 +30,13 @@ PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
#
# libjawt links to other programs, but nothing links to it directly. An RPATH
# entry has been added to the launcher so third-party programs linked against
# it will be able to find it no matter where the JDK or the third-party program
# is located.
#
#
# Files
#
......
......@@ -34,7 +34,7 @@ import javax.swing.plaf.ComponentUI;
import sun.lwawt.macosx.CMenuItem;
class ScreenMenuItem extends MenuItem implements ActionListener, ComponentListener, ScreenMenuPropertyHandler {
final class ScreenMenuItem extends MenuItem implements ActionListener, ComponentListener, ScreenMenuPropertyHandler {
ScreenMenuPropertyListener fListener;
JMenuItem fMenuItem;
......@@ -96,21 +96,31 @@ class ScreenMenuItem extends MenuItem implements ActionListener, ComponentListen
fMenuItem.removeComponentListener(this);
}
public void setAccelerator(final KeyStroke ks) {
if (ks == null) {
setShortcut(null);
static void syncLabelAndKS(MenuItem menuItem, String label, KeyStroke ks) {
final MenuComponentPeer peer = menuItem.getPeer();
if (!(peer instanceof CMenuItem)) {
//Is it possible?
return;
}
final MenuComponentPeer peer = getPeer();
if (peer instanceof CMenuItem) {
final CMenuItem ourPeer = (CMenuItem)peer;
ourPeer.setLabel(fMenuItem.getText(), ks.getKeyChar(), ks.getKeyCode(), ks.getModifiers());
final CMenuItem cmi = (CMenuItem) peer;
if (ks == null) {
cmi.setLabel(label);
} else {
setShortcut(new MenuShortcut(ks.getKeyCode(), (ks.getModifiers() & InputEvent.SHIFT_MASK) != 0));
cmi.setLabel(label, ks.getKeyChar(), ks.getKeyCode(),
ks.getModifiers());
}
}
@Override
public synchronized void setLabel(final String label) {
syncLabelAndKS(this, label, fMenuItem.getAccelerator());
}
@Override
public void setAccelerator(final KeyStroke ks) {
syncLabelAndKS(this, fMenuItem.getText(), ks);
}
public void actionPerformed(final ActionEvent e) {
fMenuItem.doClick(0); // This takes care of all the different events
}
......
......@@ -36,7 +36,7 @@ import com.apple.laf.AquaMenuItemUI.IndeterminateListener;
import sun.lwawt.macosx.*;
class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionListener, ComponentListener, ScreenMenuPropertyHandler, ItemListener {
final class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionListener, ComponentListener, ScreenMenuPropertyHandler, ItemListener {
JMenuItem fMenuItem;
MenuContainer fParent;
......@@ -110,19 +110,14 @@ class ScreenMenuItemCheckbox extends CheckboxMenuItem implements ActionListener,
super.removeNotify();
}
public void setAccelerator(final KeyStroke ks) {
if (ks == null) {
setShortcut(null);
return;
}
@Override
public synchronized void setLabel(final String label) {
ScreenMenuItem.syncLabelAndKS(this, label, fMenuItem.getAccelerator());
}
final MenuComponentPeer peer = getPeer();
if (peer instanceof CMenuItem) {
final CMenuItem ourPeer = (CMenuItem)peer;
ourPeer.setLabel(fMenuItem.getText(), ks.getKeyChar(), ks.getKeyCode(), ks.getModifiers());
} else {
setShortcut(new MenuShortcut(ks.getKeyCode(), (ks.getModifiers() & InputEvent.SHIFT_MASK) != 0));
}
@Override
public void setAccelerator(final KeyStroke ks) {
ScreenMenuItem.syncLabelAndKS(this, fMenuItem.getText(), ks);
}
public void actionPerformed(final ActionEvent e) {
......
......@@ -31,8 +31,12 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.ImageCapabilities;
import java.awt.Rectangle;
import java.awt.Transparency;
import java.awt.color.ColorSpace;
import java.awt.image.BufferedImage;
......@@ -44,6 +48,7 @@ import java.awt.image.WritableRaster;
import sun.awt.CGraphicsConfig;
import sun.awt.CGraphicsDevice;
import sun.awt.TextureSizeConstraining;
import sun.awt.image.OffScreenImage;
import sun.awt.image.SunVolatileImage;
import sun.awt.image.SurfaceManager;
......@@ -65,7 +70,7 @@ import sun.java2d.pipe.hw.AccelDeviceEventNotifier;
import sun.lwawt.macosx.CPlatformView;
public class CGLGraphicsConfig extends CGraphicsConfig
implements OGLGraphicsConfig
implements OGLGraphicsConfig, TextureSizeConstraining
{
//private static final int kOpenGLSwapInterval = RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
private static final int kOpenGLSwapInterval = 0; // TODO
......@@ -242,6 +247,8 @@ public class CGLGraphicsConfig extends CGraphicsConfig
} finally {
rq.unlock();
}
updateTotalDisplayBounds();
}
@Override
......@@ -478,4 +485,50 @@ public class CGLGraphicsConfig extends CGraphicsConfig
public void removeDeviceEventListener(AccelDeviceEventListener l) {
AccelDeviceEventNotifier.removeListener(l);
}
private static final Rectangle totalDisplayBounds = new Rectangle();
private static void updateTotalDisplayBounds() {
synchronized (totalDisplayBounds) {
Rectangle virtualBounds = new Rectangle();
for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
for (GraphicsConfiguration gc : gd.getConfigurations()) {
virtualBounds = virtualBounds.union(gc.getBounds());
}
}
totalDisplayBounds.setBounds(virtualBounds);
}
}
// 7160609: GL still fails to create a square texture of this size,
// so we use this value to cap the total display bounds.
native private static int getMaxTextureSize();
@Override
public int getMaxTextureWidth() {
int width;
synchronized (totalDisplayBounds) {
if (totalDisplayBounds.width == 0) {
updateTotalDisplayBounds();
}
width = totalDisplayBounds.width;
}
return Math.min(width, getMaxTextureSize());
}
@Override
public int getMaxTextureHeight() {
int height;
synchronized (totalDisplayBounds) {
if (totalDisplayBounds.height == 0) {
updateTotalDisplayBounds();
}
height = totalDisplayBounds.height;
}
return Math.min(height, getMaxTextureSize());
}
}
......@@ -282,7 +282,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
* Note that we call setVisible() at the end of initialization.
*/
public final void initialize() {
platformComponent.initialize(target, this, getPlatformWindow());
platformComponent.initialize(getPlatformWindow());
initializeImpl();
setVisible(target.isVisible());
}
......
......@@ -338,6 +338,18 @@ public class LWWindowPeer
h = MINIMUM_HEIGHT;
}
if (graphicsConfig instanceof TextureSizeConstraining) {
final int maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
final int maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
if (w > maxW) {
w = maxW;
}
if (h > maxH) {
h = maxH;
}
}
// Don't post ComponentMoved/Resized and Paint events
// until we've got a notification from the delegate
setBounds(x, y, w, h, op, false, false);
......@@ -405,14 +417,33 @@ public class LWWindowPeer
@Override
public void updateMinimumSize() {
Dimension d = null;
final Dimension min;
if (getTarget().isMinimumSizeSet()) {
d = getTarget().getMinimumSize();
min = getTarget().getMinimumSize();
min.width = Math.max(min.width, MINIMUM_WIDTH);
min.height = Math.max(min.height, MINIMUM_HEIGHT);
} else {
min = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
}
if (d == null) {
d = new Dimension(MINIMUM_WIDTH, MINIMUM_HEIGHT);
final int maxW, maxH;
if (graphicsConfig instanceof TextureSizeConstraining) {
maxW = ((TextureSizeConstraining)graphicsConfig).getMaxTextureWidth();
maxH = ((TextureSizeConstraining)graphicsConfig).getMaxTextureHeight();
} else {
maxW = maxH = Integer.MAX_VALUE;
}
final Dimension max;
if (getTarget().isMaximumSizeSet()) {
max = getTarget().getMaximumSize();
max.width = Math.min(max.width, maxW);
max.height = Math.min(max.height, maxH);
} else {
max = new Dimension(maxW, maxH);
}
platformWindow.setMinimumSize(d.width, d.height);
platformWindow.setSizeConstraints(min.width, min.height, max.width, max.height);
}
@Override
......
......@@ -23,15 +23,38 @@
* questions.
*/
package sun.lwawt;
import java.awt.Component;
package sun.lwawt;
/**
* Can be used to store information about native resource related to the
* lightweight component.
*/
public interface PlatformComponent {
public void initialize(Component target, LWComponentPeer peer, PlatformWindow platformWindow);
/**
* Initializes platform component.
*
* @param platformWindow already initialized {@code PlatformWindow}.
*/
void initialize(PlatformWindow platformWindow);
public void setBounds(int x, int y, int w, int h);
/**
* Moves and resizes this component. The new location of the top-left corner
* is specified by {@code x} and {@code y}, and the new size is specified by
* {@code w} and {@code h}. The location is specified relative to the {@code
* platformWindow}.
*
* @param x the X location of the component
* @param y the Y location of the component
* @param w the width of the component
* @param h the height of the component
*/
void setBounds(int x, int y, int w, int h);
public void dispose();
/**
* Releases all of the native resources used by this {@code
* PlatformComponent}.
*/
void dispose();
}
......@@ -131,7 +131,10 @@ public interface PlatformWindow {
public void setResizable(boolean resizable);
public void setMinimumSize(int width, int height);
/**
* Applies the minimum and maximum size to the platform window.
*/
public void setSizeConstraints(int minW, int minH, int maxW, int maxH);
/**
* Transforms the given Graphics object according to the native
......
......@@ -33,8 +33,8 @@ package sun.lwawt.macosx;
public class CFRetainedResource {
private static native void nativeCFRelease(final long ptr, final boolean disposeOnAppKitThread);
final boolean disposeOnAppKitThread;
protected long ptr;
private final boolean disposeOnAppKitThread;
protected volatile long ptr;
/**
* @param ptr CFRetained native object pointer
......
......@@ -30,12 +30,14 @@ import java.awt.peer.*;
import java.awt.BufferCapabilities.FlipContents;
import java.awt.event.*;
import java.awt.image.*;
import java.security.AccessController;
import java.util.List;
import java.io.*;
import sun.awt.CausedFocusEvent.Cause;
import sun.awt.AWTAccessor;
import sun.java2d.pipe.Region;
import sun.security.action.GetBooleanAction;
class CFileDialog implements FileDialogPeer {
......@@ -53,11 +55,14 @@ class CFileDialog implements FileDialogPeer {
if (title == null) {
title = " ";
}
Boolean chooseDirectories = AccessController.doPrivileged(
new GetBooleanAction("apple.awt.fileDialogForDirectories"));
String[] userFileNames = nativeRunFileDialog(title,
dialogMode,
target.isMultipleMode(),
navigateApps,
chooseDirectories,
target.getFilenameFilter() != null,
target.getDirectory(),
target.getFile());
......@@ -142,7 +147,8 @@ class CFileDialog implements FileDialogPeer {
}
private native String[] nativeRunFileDialog(String title, int mode,
boolean multipleMode, boolean shouldNavigateApps, boolean hasFilenameFilter,
boolean multipleMode, boolean shouldNavigateApps,
boolean canChooseDirectories, boolean hasFilenameFilter,
String directory, String file);
@Override
......
......@@ -23,27 +23,24 @@
* questions.
*/
package sun.lwawt.macosx;
import java.awt.Component;
import java.awt.Insets;
import sun.lwawt.PlatformComponent;
import sun.lwawt.PlatformWindow;
import sun.lwawt.LWComponentPeer;
import sun.lwawt.macosx.CFRetainedResource;
public class CPlatformComponent extends CFRetainedResource implements PlatformComponent {
Component target;
LWComponentPeer peer;
PlatformWindow platformWindow;
/**
* On OSX {@code CPlatformComponent} stores pointer to the native CAlayer which
* can be used from JAWT.
*/
final class CPlatformComponent extends CFRetainedResource
implements PlatformComponent {
private native long nativeCreateComponent(long windowLayer);
private native long nativeSetBounds(long ptr, int x, int y, int width, int height);
private volatile PlatformWindow platformWindow;
public CPlatformComponent() {
CPlatformComponent() {
super(0, true);
}
......@@ -51,27 +48,28 @@ public class CPlatformComponent extends CFRetainedResource implements PlatformCo
return ptr;
}
public void initialize(Component target, LWComponentPeer peer, PlatformWindow platformWindow) {
this.target = target;
this.peer = peer;
@Override
public void initialize(final PlatformWindow platformWindow) {
this.platformWindow = platformWindow;
long windowLayerPtr = platformWindow.getLayerPtr();
setPtr(nativeCreateComponent(windowLayerPtr));
setPtr(nativeCreateComponent(platformWindow.getLayerPtr()));
}
// TODO: visibility, z-order
@Override
public void setBounds(int x, int y, int width, int height) {
public void setBounds(final int x, final int y, final int w, final int h) {
// translates values from the coordinate system of the top-level window
// to the coordinate system of the content view
Insets insets = platformWindow.getPeer().getInsets();
nativeSetBounds(getPointer(), x - insets.left, y - insets.top, width, height);
final Insets insets = platformWindow.getPeer().getInsets();
nativeSetBounds(getPointer(), x - insets.left, y - insets.top, w, h);
}
@Override
public void dispose() {
super.dispose();
}
private native long nativeCreateComponent(long windowLayer);
private native void nativeSetBounds(long ptr, int x, int y, int w, int h);
}
......@@ -180,7 +180,7 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
public void setResizable(boolean resizable) {}
@Override
public void setMinimumSize(int width, int height) {}
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {}
@Override
public Graphics transformGraphics(Graphics g) {
......
......@@ -672,20 +672,15 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
// Re-apply the size constraints and the size to ensure the space
// occupied by the grow box is counted properly
setMinimumSize(1, 1); // the method ignores its arguments
peer.updateMinimumSize();
Rectangle bounds = peer.getBounds();
setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
}
@Override
public void setMinimumSize(int width, int height) {
//TODO width, height should be used
//NOTE: setResizable() calls setMinimumSize(1,1) relaying on the logic below
final long nsWindowPtr = getNSWindowPtr();
final Dimension min = target.getMinimumSize();
final Dimension max = target.getMaximumSize();
nativeSetNSWindowMinMax(nsWindowPtr, min.getWidth(), min.getHeight(), max.getWidth(), max.getHeight());
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
nativeSetNSWindowMinMax(getNSWindowPtr(), minW, minH, maxW, maxH);
}
@Override
......
......@@ -42,7 +42,7 @@ import java.util.concurrent.Callable;
import sun.awt.*;
import sun.lwawt.*;
import sun.lwawt.LWWindowPeer.PeerType;
import sun.security.action.GetBooleanAction;
class NamedCursor extends Cursor {
NamedCursor(String name) {
......@@ -81,14 +81,6 @@ public class LWCToolkit extends LWToolkit {
}
}
static String getSystemProperty(final String name, final String deflt) {
return AccessController.doPrivileged (new PrivilegedAction<String>() {
public String run() {
return System.getProperty(name, deflt);
}
});
}
public LWCToolkit() {
SunToolkit.setDataTransfererClassName("sun.lwawt.macosx.CDataTransferer");
......@@ -700,8 +692,8 @@ public class LWCToolkit extends LWToolkit {
*/
public synchronized static boolean getSunAwtDisableCALayers() {
if (sunAwtDisableCALayers == null) {
sunAwtDisableCALayers =
getBooleanSystemProperty("sun.awt.disableCALayers");
sunAwtDisableCALayers = AccessController.doPrivileged(
new GetBooleanAction("sun.awt.disableCALayers"));
}
return sunAwtDisableCALayers.booleanValue();
}
......
......@@ -78,11 +78,10 @@
// translates values to the coordinate system of the "root" layer
CGFloat newY = windowLayer.bounds.size.height - rect.origin.y - rect.size.height;
CGRect newRect = CGRectMake(rect.origin.x, newY, rect.size.width, rect.size.height);
// REMIND: why do we need to inverse position?
CGRect newRect = CGRectMake(-rect.origin.x, -newY, rect.size.width, rect.size.height);
layer.frame = newRect;
layer.bounds = newRect;
[AWTSurfaceLayers repaintLayersRecursively:layer];
}
......
......@@ -52,6 +52,9 @@
// Should we navigate into apps?
BOOL fNavigateApps;
// Can the dialog choose directories ?
BOOL fChooseDirectories;
// Contains the absolute paths of the selected files as URLs
NSArray *fURLs;
}
......@@ -65,6 +68,7 @@
mode:(jint)inMode
multipleMode:(BOOL)inMultipleMode
shouldNavigate:(BOOL)inNavigateApps
canChooseDirectories:(BOOL)inChooseDirectories
withEnv:(JNIEnv*)env;
// Invoked from the main thread
......
......@@ -43,6 +43,7 @@
mode:(jint)inMode
multipleMode:(BOOL)inMultipleMode
shouldNavigate:(BOOL)inNavigateApps
canChooseDirectories:(BOOL)inChooseDirectories
withEnv:(JNIEnv*)env;
{
if (self == [super init]) {
......@@ -57,6 +58,7 @@
fMode = inMode;
fMultipleMode = inMultipleMode;
fNavigateApps = inNavigateApps;
fChooseDirectories = inChooseDirectories;
fPanelResult = NSCancelButton;
}
......@@ -109,7 +111,7 @@
NSOpenPanel *openPanel = (NSOpenPanel *)thePanel;
[openPanel setAllowsMultipleSelection:fMultipleMode];
[openPanel setCanChooseFiles:YES];
[openPanel setCanChooseDirectories:NO];
[openPanel setCanChooseDirectories:fChooseDirectories];
[openPanel setCanCreateDirectories:YES];
}
......@@ -182,7 +184,8 @@
JNIEXPORT jobjectArray JNICALL
Java_sun_lwawt_macosx_CFileDialog_nativeRunFileDialog
(JNIEnv *env, jobject peer, jstring title, jint mode, jboolean multipleMode,
jboolean navigateApps, jboolean hasFilter, jstring directory, jstring file)
jboolean navigateApps, jboolean chooseDirectories, jboolean hasFilter,
jstring directory, jstring file)
{
jobjectArray returnValue = NULL;
......@@ -200,6 +203,7 @@ JNF_COCOA_ENTER(env);
mode:mode
multipleMode:multipleMode
shouldNavigate:navigateApps
canChooseDirectories:chooseDirectories
withEnv:env];
[JNFRunLoop performOnMainThread:@selector(safeSaveOrLoad)
......
......@@ -447,3 +447,20 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getOGLCapabilities
return cglinfo->context->caps;
}
}
JNIEXPORT jint JNICALL
Java_sun_java2d_opengl_CGLGraphicsConfig_getMaxTextureSize
(JNIEnv *env, jclass cglgc)
{
J2dTraceLn(J2D_TRACE_INFO, "CGLGraphicsConfig_getMaxTextureSize");
__block int max = 0;
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
[sharedContext makeCurrentContext];
j2d_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max);
}];
return (jint)max;
}
......@@ -28,7 +28,6 @@
@interface NSApplicationAWT : NSApplication {
NSString *fApplicationName;
BOOL fUseDefaultIcon;
NSWindow *eventTransparentWindow;
}
......
......@@ -52,7 +52,6 @@ BOOL postEventDuringEventSynthesis = NO;
AWT_ASSERT_APPKIT_THREAD;
fApplicationName = nil;
fUseDefaultIcon = NO;
// NSApplication will call _RegisterApplication with the application's bundle, but there may not be one.
// So, we need to call it ourselves to ensure the app is set up properly.
......@@ -147,10 +146,6 @@ AWT_ASSERT_APPKIT_THREAD;
if (appName != NULL) {
fApplicationName = [NSString stringWithUTF8String:appName];
unsetenv(envVar);
// If this environment variable was set we were launched from the command line, so we
// should use a generic app icon if one wasn't set.
fUseDefaultIcon = YES;
}
// If it wasn't specified as an argument, see if it was specified as a system property.
......@@ -171,9 +166,6 @@ AWT_ASSERT_APPKIT_THREAD;
if (lastPeriod.location != NSNotFound) {
fApplicationName = [fApplicationName substringFromIndex:lastPeriod.location + 1];
}
// If this environment variable was set we were launched from the command line, so we
// should use a generic app icon if one wasn't set.
fUseDefaultIcon = YES;
}
}
......@@ -266,8 +258,11 @@ AWT_ASSERT_APPKIT_THREAD;
// If the icon file wasn't specified as an argument and we need to get an icon
// we'll use the generic java app icon.
NSString *defaultIconPath = [NSString stringWithFormat:@"%@%@", SHARED_FRAMEWORK_BUNDLE, @"/Resources/GenericApp.icns"];
if (fUseDefaultIcon && (theIconPath == nil)) {
theIconPath = defaultIconPath;
if (theIconPath == nil) {
NSString* bundleIcon = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIconFile"];
if (bundleIcon == nil) {
theIconPath = defaultIconPath;
}
}
// Set up the dock icon if we have an icon name.
......
......@@ -68,12 +68,23 @@ int JLI_GetStdArgc();
#define JLI_StrNCaseCmp(p1, p2, p3) strnicmp((p1), (p2), (p3))
#define JLI_Snprintf _snprintf
void JLI_CmdToArgs(char *cmdline);
#else
#define JLI_Lseek _lseeki64
#else /* NIXES */
#include <unistd.h>
#include <strings.h>
#define JLI_StrCaseCmp(p1, p2) strcasecmp((p1), (p2))
#define JLI_StrNCaseCmp(p1, p2, p3) strncasecmp((p1), (p2), (p3))
#define JLI_Snprintf snprintf
#ifdef __solaris__
#define JLI_Lseek llseek
#endif
#ifdef __linux__
#define _LARGFILE64_SOURCE
#define JLI_Lseek lseek64
#endif
#ifdef MACOSX
#define JLI_Lseek lseek
#endif
#endif /* _WIN32 */
/*
......
/*
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2012, 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
......@@ -37,6 +37,8 @@
#define CENSIG 0x02014b50L /* "PK\001\002" */
#define ENDSIG 0x06054b50L /* "PK\005\006" */
#define ZIP64_ENDSIG 0x06064b50L /* "PK\006\006" */
#define ZIP64_LOCSIG 0x07064b50L /* "PK\006\007" */
/*
* Header sizes including signatures
*/
......@@ -45,12 +47,21 @@
#define CENHDR 46
#define ENDHDR 22
#define ZIP64_ENDHDR 56 // ZIP64 end header size
#define ZIP64_LOCHDR 20 // ZIP64 end loc header size
#define ZIP64_EXTHDR 24 // EXT header size
#define ZIP64_EXTID 1 // Extra field Zip64 header ID
#define ZIP64_MAGICVAL 0xffffffffLL
#define ZIP64_MAGICCOUNT 0xffff
/*
* Header field access macros
*/
#define CH(b, n) (((unsigned char *)(b))[n])
#define SH(b, n) (CH(b, n) | (CH(b, n+1) << 8))
#define LG(b, n) (SH(b, n) | (SH(b, n+2) << 16))
#define LG(b, n) ((SH(b, n) | (SH(b, n+2) << 16)) &0xffffffffUL)
#define LL(b, n) (((jlong)LG(b, n)) | (((jlong)LG(b, n+4)) << 32))
#define GETSIG(b) LG(b, 0)
/*
......@@ -101,6 +112,26 @@
#define ENDOFF(b) LG(b, 16) /* central directory offset */
#define ENDCOM(b) SH(b, 20) /* size of zip file comment */
/*
* Macros for getting Zip64 end of central directory header fields
*/
#define ZIP64_ENDLEN(b) LL(b, 4) /* size of zip64 end of central dir */
#define ZIP64_ENDVEM(b) SH(b, 12) /* version made by */
#define ZIP64_ENDVER(b) SH(b, 14) /* version needed to extract */
#define ZIP64_ENDNMD(b) LG(b, 16) /* number of this disk */
#define ZIP64_ENDDSK(b) LG(b, 20) /* disk number of start */
#define ZIP64_ENDTOD(b) LL(b, 24) /* total number of entries on this disk */
#define ZIP64_ENDTOT(b) LL(b, 32) /* total number of entries */
#define ZIP64_ENDSIZ(b) LL(b, 40) /* central directory size in bytes */
#define ZIP64_ENDOFF(b) LL(b, 48) /* offset of first CEN header */
/*
* Macros for getting Zip64 end of central directory locator fields
*/
#define ZIP64_LOCDSK(b) LG(b, 4) /* disk number start */
#define ZIP64_LOCOFF(b) LL(b, 8) /* offset of zip64 end */
#define ZIP64_LOCTOT(b) LG(b, 16) /* total number of disks */
/*
* A comment of maximum length of 64kb can follow the END record. This
* is the furthest the END record can be from the end of the file.
......@@ -119,7 +150,7 @@
typedef struct zentry { /* Zip file entry */
size_t isize; /* size of inflated data */
size_t csize; /* size of compressed data (zero if uncompressed) */
off_t offset; /* position of compressed data */
jlong offset; /* position of compressed data */
int how; /* compression method (if any) */
} zentry;
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2012, 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
......@@ -61,7 +61,7 @@ inflate_file(int fd, zentry *entry, int *size_out)
if (entry->csize == (size_t) -1 || entry->isize == (size_t) -1 )
return (NULL);
if (lseek(fd, entry->offset, SEEK_SET) < (off_t)0)
if (JLI_Lseek(fd, entry->offset, SEEK_SET) < (jlong)0)
return (NULL);
if ((in = malloc(entry->csize + 1)) == NULL)
return (NULL);
......@@ -110,6 +110,38 @@ inflate_file(int fd, zentry *entry, int *size_out)
return (NULL);
}
static jboolean zip64_present = JNI_FALSE;
/*
* Checks to see if we have ZIP64 archive, and save
* the check for later use
*/
static int
haveZIP64(Byte *p) {
jlong cenlen, cenoff, centot;
cenlen = ENDSIZ(p);
cenoff = ENDOFF(p);
centot = ENDTOT(p);
zip64_present = (cenlen == ZIP64_MAGICVAL ||
cenoff == ZIP64_MAGICVAL ||
centot == ZIP64_MAGICCOUNT);
return zip64_present;
}
static jlong
find_end64(int fd, Byte *ep, jlong pos)
{
jlong end64pos;
jlong bytes;
if ((end64pos = JLI_Lseek(fd, pos - ZIP64_LOCHDR, SEEK_SET)) < (jlong)0)
return -1;
if ((bytes = read(fd, ep, ZIP64_LOCHDR)) < 0)
return -1;
if (GETSIG(ep) == ZIP64_LOCSIG)
return end64pos;
return -1;
}
/*
* A very little used routine to handle the case that zip file has
* a comment at the end. Believe it or not, the only way to find the
......@@ -122,12 +154,12 @@ inflate_file(int fd, zentry *entry, int *size_out)
* Returns the offset of the END record in the file on success,
* -1 on failure.
*/
static off_t
static jlong
find_end(int fd, Byte *eb)
{
off_t len;
off_t pos;
off_t flen;
jlong len;
jlong pos;
jlong flen;
int bytes;
Byte *cp;
Byte *endpos;
......@@ -136,14 +168,16 @@ find_end(int fd, Byte *eb)
/*
* 99.44% (or more) of the time, there will be no comment at the
* end of the zip file. Try reading just enough to read the END
* record from the end of the file.
* record from the end of the file, at this time we should also
* check to see if we have a ZIP64 archive.
*/
if ((pos = lseek(fd, -ENDHDR, SEEK_END)) < (off_t)0)
if ((pos = JLI_Lseek(fd, -ENDHDR, SEEK_END)) < (jlong)0)
return (-1);
if ((bytes = read(fd, eb, ENDHDR)) < 0)
return (-1);
if (GETSIG(eb) == ENDSIG)
return (pos);
if (GETSIG(eb) == ENDSIG) {
return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
}
/*
* Shucky-Darn,... There is a comment at the end of the zip file.
......@@ -151,10 +185,10 @@ find_end(int fd, Byte *eb)
* Allocate and fill a buffer with enough of the zip file
* to meet the specification for a maximal comment length.
*/
if ((flen = lseek(fd, 0, SEEK_END)) < (off_t)0)
if ((flen = JLI_Lseek(fd, 0, SEEK_END)) < (jlong)0)
return (-1);
len = (flen < END_MAXLEN) ? flen : END_MAXLEN;
if (lseek(fd, -len, SEEK_END) < (off_t)0)
if (JLI_Lseek(fd, -len, SEEK_END) < (jlong)0)
return (-1);
if ((buffer = malloc(END_MAXLEN)) == NULL)
return (-1);
......@@ -175,12 +209,92 @@ find_end(int fd, Byte *eb)
(cp + ENDHDR + ENDCOM(cp) == endpos)) {
(void) memcpy(eb, cp, ENDHDR);
free(buffer);
return (flen - (endpos - cp));
pos = flen - (endpos - cp);
return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
}
free(buffer);
return (-1);
}
#define BUFSIZE (3 * 65536 + CENHDR + SIGSIZ)
#define MINREAD 1024
/*
* Computes and positions at the start of the CEN header, ie. the central
* directory, this will also return the offset if there is a zip file comment
* at the end of the archive, for most cases this would be 0.
*/
static jlong
compute_cen(int fd, Byte *bp)
{
int bytes;
Byte *p;
jlong base_offset;
jlong offset;
char buffer[MINREAD];
p = buffer;
/*
* Read the END Header, which is the starting point for ZIP files.
* (Clearly designed to make writing a zip file easier than reading
* one. Now isn't that precious...)
*/
if ((base_offset = find_end(fd, bp)) == -1) {
return (-1);
}
p = bp;
/*
* There is a historical, but undocumented, ability to allow for
* additional "stuff" to be prepended to the zip/jar file. It seems
* that this has been used to prepend an actual java launcher
* executable to the jar on Windows. Although this is just another
* form of statically linking a small piece of the JVM to the
* application, we choose to continue to support it. Note that no
* guarantees have been made (or should be made) to the customer that
* this will continue to work.
*
* Therefore, calculate the base offset of the zip file (within the
* expanded file) by assuming that the central directory is followed
* immediately by the end record.
*/
if (zip64_present) {
if ((offset = ZIP64_LOCOFF(p)) < (jlong)0) {
return -1;
}
if (JLI_Lseek(fd, offset, SEEK_SET) < (jlong) 0) {
return (-1);
}
if ((bytes = read(fd, buffer, MINREAD)) < 0) {
return (-1);
}
if (GETSIG(buffer) != ZIP64_ENDSIG) {
return -1;
}
if ((offset = ZIP64_ENDOFF(buffer)) < (jlong)0) {
return -1;
}
if (JLI_Lseek(fd, offset, SEEK_SET) < (jlong)0) {
return (-1);
}
p = buffer;
base_offset = base_offset - ZIP64_ENDSIZ(p) - ZIP64_ENDOFF(p) - ZIP64_ENDHDR;
} else {
base_offset = base_offset - ENDSIZ(p) - ENDOFF(p);
/*
* The END Header indicates the start of the Central Directory
* Headers. Remember that the desired Central Directory Header (CEN)
* will almost always be the second one and the first one is a small
* directory entry ("META-INF/"). Keep the code optimized for
* that case.
*
* Seek to the beginning of the Central Directory.
*/
if (JLI_Lseek(fd, base_offset + ENDOFF(p), SEEK_SET) < (jlong) 0) {
return (-1);
}
}
return base_offset;
}
/*
* Locate the manifest file with the zip/jar file.
*
......@@ -208,9 +322,6 @@ find_end(int fd, Byte *eb)
* a typical jar file (META-INF and META-INF/MANIFEST.MF). Keep this factoid
* in mind when optimizing this code.
*/
#define BUFSIZE (3 * 65536 + CENHDR + SIGSIZ)
#define MINREAD 1024
static int
find_file(int fd, zentry *entry, const char *file_name)
{
......@@ -218,7 +329,7 @@ find_file(int fd, zentry *entry, const char *file_name)
int res;
int entry_size;
int read_size;
int base_offset;
jlong base_offset;
Byte *p;
Byte *bp;
Byte *buffer;
......@@ -228,54 +339,18 @@ find_file(int fd, zentry *entry, const char *file_name)
return(-1);
}
p = buffer;
bp = buffer;
/*
* Read the END Header, which is the starting point for ZIP files.
* (Clearly designed to make writing a zip file easier than reading
* one. Now isn't that precious...)
*/
if ((base_offset = find_end(fd, bp)) == -1) {
base_offset = compute_cen(fd, bp);
if (base_offset == -1) {
free(buffer);
return (-1);
return -1;
}
/*
* There is a historical, but undocumented, ability to allow for
* additional "stuff" to be prepended to the zip/jar file. It seems
* that this has been used to prepend an actual java launcher
* executable to the jar on Windows. Although this is just another
* form of statically linking a small piece of the JVM to the
* application, we choose to continue to support it. Note that no
* guarantees have been made (or should be made) to the customer that
* this will continue to work.
*
* Therefore, calculate the base offset of the zip file (within the
* expanded file) by assuming that the central directory is followed
* immediately by the end record.
*/
base_offset = base_offset - ENDSIZ(p) - ENDOFF(p);
/*
* The END Header indicates the start of the Central Directory
* Headers. Remember that the desired Central Directory Header (CEN)
* will almost always be the second one and the first one is a small
* directory entry ("META-INF/"). Keep the code optimized for
* that case.
*
* Begin by seeking to the beginning of the Central Directory and
* reading in the first buffer full of bits.
*/
if (lseek(fd, base_offset + ENDOFF(p), SEEK_SET) < (off_t)0) {
free(buffer);
return (-1);
}
if ((bytes = read(fd, bp, MINREAD)) < 0) {
free(buffer);
return (-1);
}
p = bp;
/*
* Loop through the Central Directory Headers. Note that a valid zip/jar
* must have an ENDHDR (with ENDSIG) after the Central Directory.
......@@ -319,7 +394,7 @@ find_file(int fd, zentry *entry, const char *file_name)
*/
if ((size_t)CENNAM(p) == JLI_StrLen(file_name) &&
memcmp((p + CENHDR), file_name, JLI_StrLen(file_name)) == 0) {
if (lseek(fd, base_offset + CENOFF(p), SEEK_SET) < (off_t)0) {
if (JLI_Lseek(fd, base_offset + CENOFF(p), SEEK_SET) < (jlong)0) {
free(buffer);
return (-1);
}
......@@ -487,6 +562,9 @@ JLI_ParseManifest(char *jarfile, manifest_info *info)
char *splashscreen_name = NULL;
if ((fd = open(jarfile, O_RDONLY
#ifdef O_LARGEFILE
| O_LARGEFILE /* large file mode on solaris */
#endif
#ifdef O_BINARY
| O_BINARY /* use binary mode on windows */
#endif
......
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2012, 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,6 +28,8 @@ import com.sun.beans.finder.MethodFinder;
import java.lang.reflect.Method;
import sun.reflect.misc.MethodUtil;
/**
* This class is intended to handle &lt;method&gt; element.
* It describes invocation of the method.
......@@ -101,7 +103,7 @@ final class MethodElementHandler extends NewElementHandler {
if (method.isVarArgs()) {
args = getArguments(args, method.getParameterTypes());
}
Object value = method.invoke(bean, args);
Object value = MethodUtil.invoke(method, bean, args);
return method.getReturnType().equals(void.class)
? ValueObjectImpl.VOID
: ValueObjectImpl.create(value);
......
/*
* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2012, 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,7 +23,7 @@
* questions.
*/
package sun.beans.editors;
package com.sun.beans.editors;
/**
* Property editor for a java builtin "boolean" type.
......
/*
* Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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,7 +23,7 @@
* questions.
*/
package sun.beans.editors;
package com.sun.beans.editors;
/**
* Property editor for a java builtin "byte" type.
......
/*
* Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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,7 +23,7 @@
* questions.
*/
package sun.beans.editors;
package com.sun.beans.editors;
import java.awt.*;
import java.beans.*;
......
/*
* Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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,7 +23,7 @@
* questions.
*/
package sun.beans.editors;
package com.sun.beans.editors;
/**
* Property editor for a java builtin "double" type.
......
/*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2012, 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
......@@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.beans.editors;
package com.sun.beans.editors;
import java.awt.Component;
import java.awt.Graphics;
......
/*
* Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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,7 +23,7 @@
* questions.
*/
package sun.beans.editors;
package com.sun.beans.editors;
/**
* Property editor for a java builtin "float" type.
......
/*
* Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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,7 +23,7 @@
* questions.
*/
package sun.beans.editors;
package com.sun.beans.editors;
import java.awt.*;
import java.beans.*;
......
/*
* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2012, 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,7 +23,7 @@
* questions.
*/
package sun.beans.editors;
package com.sun.beans.editors;
/**
* Property editor for a java builtin "int" type.
......
/*
* Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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,7 +23,7 @@
* questions.
*/
package sun.beans.editors;
package com.sun.beans.editors;
/**
* Property editor for a java builtin "long" type.
......
/*
* Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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,7 +23,7 @@
* questions.
*/
package sun.beans.editors;
package com.sun.beans.editors;
/**
* Abstract Property editor for a java builtin number types.
......
/*
* Copyright (c) 1996, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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
......@@ -24,7 +24,7 @@
*/
package sun.beans.editors;
package com.sun.beans.editors;
/**
* Property editor for a java builtin "short" type.
......
/*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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
......@@ -24,7 +24,7 @@
*/
package sun.beans.editors;
package com.sun.beans.editors;
import java.beans.*;
......
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2012, 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
......@@ -42,6 +42,7 @@ public final class BeanInfoFinder
extends InstanceFinder<BeanInfo> {
private static final String DEFAULT = "sun.beans.infos";
private static final String DEFAULT_NEW = "com.sun.beans.infos";
public BeanInfoFinder() {
super(BeanInfo.class, true, "BeanInfo", DEFAULT);
......@@ -53,10 +54,13 @@ public final class BeanInfoFinder
@Override
protected BeanInfo instantiate(Class<?> type, String prefix, String name) {
if (DEFAULT.equals(prefix)) {
prefix = DEFAULT_NEW;
}
// this optimization will only use the BeanInfo search path
// if is has changed from the original
// or trying to get the ComponentBeanInfo
BeanInfo info = !DEFAULT.equals(prefix) || "ComponentBeanInfo".equals(name)
BeanInfo info = !DEFAULT_NEW.equals(prefix) || "ComponentBeanInfo".equals(name)
? super.instantiate(type, prefix, name)
: null;
......
/*
* Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2012, 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
......@@ -24,6 +24,8 @@
*/
package com.sun.beans.finder;
import static sun.reflect.misc.ReflectUtil.checkPackageAccess;
/**
* This is utility class that provides {@code static} methods
* to find a class with the specified name using the specified class loader.
......@@ -54,6 +56,7 @@ public final class ClassFinder {
* @see Thread#getContextClassLoader()
*/
public static Class<?> findClass(String name) throws ClassNotFoundException {
checkPackageAccess(name);
try {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
if (loader == null) {
......@@ -94,6 +97,7 @@ public final class ClassFinder {
* @see Class#forName(String,boolean,ClassLoader)
*/
public static Class<?> findClass(String name, ClassLoader loader) throws ClassNotFoundException {
checkPackageAccess(name);
if (loader != null) {
try {
return Class.forName(name, false, loader);
......
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2012, 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
......@@ -29,6 +29,8 @@ import com.sun.beans.WeakCache;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
import static sun.reflect.misc.ReflectUtil.isPackageAccessible;
/**
* This utility class provides {@code static} methods
* to find a public constructor with specified parameter types
......@@ -61,7 +63,7 @@ public final class ConstructorFinder extends AbstractFinder<Constructor<?>> {
if (Modifier.isAbstract(type.getModifiers())) {
throw new NoSuchMethodException("Abstract class cannot be instantiated");
}
if (!Modifier.isPublic(type.getModifiers())) {
if (!Modifier.isPublic(type.getModifiers()) || !isPackageAccessible(type)) {
throw new NoSuchMethodException("Class is not accessible");
}
PrimitiveWrapperMap.replacePrimitivesWithWrappers(args);
......
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2012, 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
......@@ -27,6 +27,8 @@ package com.sun.beans.finder;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import static sun.reflect.misc.ReflectUtil.isPackageAccessible;
/**
* This utility class provides {@code static} methods
* to find a public field with specified name
......@@ -56,7 +58,8 @@ public final class FieldFinder {
if (!Modifier.isPublic(field.getModifiers())) {
throw new NoSuchFieldException("Field '" + name + "' is not public");
}
if (!Modifier.isPublic(field.getDeclaringClass().getModifiers())) {
type = field.getDeclaringClass();
if (!Modifier.isPublic(type.getModifiers()) || !isPackageAccessible(type)) {
throw new NoSuchFieldException("Field '" + name + "' is not accessible");
}
return field;
......
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2012, 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
......@@ -33,6 +33,8 @@ import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;
import static sun.reflect.misc.ReflectUtil.isPackageAccessible;
/**
* This utility class provides {@code static} methods
* to find a public method with specified name and parameter types
......@@ -120,7 +122,7 @@ public final class MethodFinder extends AbstractFinder<Method> {
*/
public static Method findAccessibleMethod(Method method) throws NoSuchMethodException {
Class<?> type = method.getDeclaringClass();
if (Modifier.isPublic(type.getModifiers())) {
if (Modifier.isPublic(type.getModifiers()) && isPackageAccessible(type)) {
return method;
}
if (Modifier.isStatic(method.getModifiers())) {
......
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2012, 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,14 +28,14 @@ import com.sun.beans.WeakCache;
import java.beans.PropertyEditor;
import sun.beans.editors.BooleanEditor;
import sun.beans.editors.ByteEditor;
import sun.beans.editors.DoubleEditor;
import sun.beans.editors.EnumEditor;
import sun.beans.editors.FloatEditor;
import sun.beans.editors.IntegerEditor;
import sun.beans.editors.LongEditor;
import sun.beans.editors.ShortEditor;
import com.sun.beans.editors.BooleanEditor;
import com.sun.beans.editors.ByteEditor;
import com.sun.beans.editors.DoubleEditor;
import com.sun.beans.editors.EnumEditor;
import com.sun.beans.editors.FloatEditor;
import com.sun.beans.editors.IntegerEditor;
import com.sun.beans.editors.LongEditor;
import com.sun.beans.editors.ShortEditor;
/**
* This is utility class that provides functionality
......@@ -48,10 +48,13 @@ import sun.beans.editors.ShortEditor;
public final class PropertyEditorFinder
extends InstanceFinder<PropertyEditor> {
private static final String DEFAULT = "sun.beans.editors";
private static final String DEFAULT_NEW = "com.sun.beans.editors";
private final WeakCache<Class<?>, Class<?>> registry;
public PropertyEditorFinder() {
super(PropertyEditor.class, false, "Editor", "sun.beans.editors");
super(PropertyEditor.class, false, "Editor", DEFAULT);
this.registry = new WeakCache<Class<?>, Class<?>>();
this.registry.put(Byte.TYPE, ByteEditor.class);
......@@ -84,4 +87,9 @@ public final class PropertyEditorFinder
}
return editor;
}
@Override
protected PropertyEditor instantiate(Class<?> type, String prefix, String name) {
return super.instantiate(type, DEFAULT.equals(prefix) ? DEFAULT_NEW : prefix, name);
}
}
/*
* Copyright (c) 1996, 2002, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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,7 +23,7 @@
* questions.
*/
package sun.beans.infos;
package com.sun.beans.infos;
import java.beans.*;
......
/*
* Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2012, 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,18 +47,122 @@ import javax.crypto.BadPaddingException;
* @see OutputFeedback
*/
public final class AESCipher extends CipherSpi {
abstract class AESCipher extends CipherSpi {
public static final class General extends AESCipher {
public General() {
super(-1);
}
}
abstract static class OidImpl extends AESCipher {
protected OidImpl(int keySize, String mode, String padding) {
super(keySize);
try {
engineSetMode(mode);
engineSetPadding(padding);
} catch (GeneralSecurityException gse) {
// internal error; re-throw as provider exception
ProviderException pe =new ProviderException("Internal Error");
pe.initCause(gse);
throw pe;
}
}
}
public static final class AES128_ECB_NoPadding extends OidImpl {
public AES128_ECB_NoPadding() {
super(16, "ECB", "NOPADDING");
}
}
public static final class AES192_ECB_NoPadding extends OidImpl {
public AES192_ECB_NoPadding() {
super(24, "ECB", "NOPADDING");
}
}
public static final class AES256_ECB_NoPadding extends OidImpl {
public AES256_ECB_NoPadding() {
super(32, "ECB", "NOPADDING");
}
}
public static final class AES128_CBC_NoPadding extends OidImpl {
public AES128_CBC_NoPadding() {
super(16, "CBC", "NOPADDING");
}
}
public static final class AES192_CBC_NoPadding extends OidImpl {
public AES192_CBC_NoPadding() {
super(24, "CBC", "NOPADDING");
}
}
public static final class AES256_CBC_NoPadding extends OidImpl {
public AES256_CBC_NoPadding() {
super(32, "CBC", "NOPADDING");
}
}
public static final class AES128_OFB_NoPadding extends OidImpl {
public AES128_OFB_NoPadding() {
super(16, "OFB", "NOPADDING");
}
}
public static final class AES192_OFB_NoPadding extends OidImpl {
public AES192_OFB_NoPadding() {
super(24, "OFB", "NOPADDING");
}
}
public static final class AES256_OFB_NoPadding extends OidImpl {
public AES256_OFB_NoPadding() {
super(32, "OFB", "NOPADDING");
}
}
public static final class AES128_CFB_NoPadding extends OidImpl {
public AES128_CFB_NoPadding() {
super(16, "CFB", "NOPADDING");
}
}
public static final class AES192_CFB_NoPadding extends OidImpl {
public AES192_CFB_NoPadding() {
super(24, "CFB", "NOPADDING");
}
}
public static final class AES256_CFB_NoPadding extends OidImpl {
public AES256_CFB_NoPadding() {
super(32, "CFB", "NOPADDING");
}
}
// utility method used by AESCipher and AESWrapCipher
static final void checkKeySize(Key key, int fixedKeySize)
throws InvalidKeyException {
if (fixedKeySize != -1) {
if (key == null) {
throw new InvalidKeyException("The key must not be null");
}
byte[] value = key.getEncoded();
if (value == null) {
throw new InvalidKeyException("Key encoding must not be null");
} else if (value.length != fixedKeySize) {
throw new InvalidKeyException("The key must be " +
fixedKeySize*8 + " bits");
}
}
}
/*
* internal CipherCore object which does the real work.
*/
private CipherCore core = null;
/*
* needed to support AES oids which associates a fixed key size
* to the cipher object.
*/
private final int fixedKeySize; // in bytes, -1 if no restriction
/**
* Creates an instance of AES cipher with default ECB mode and
* PKCS5Padding.
*/
public AESCipher() {
protected AESCipher(int keySize) {
core = new CipherCore(new AESCrypt(), AESConstants.AES_BLOCK_SIZE);
fixedKeySize = keySize;
}
/**
......@@ -183,6 +287,7 @@ public final class AESCipher extends CipherSpi {
*/
protected void engineInit(int opmode, Key key, SecureRandom random)
throws InvalidKeyException {
checkKeySize(key, fixedKeySize);
core.init(opmode, key, random);
}
......@@ -214,6 +319,7 @@ public final class AESCipher extends CipherSpi {
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
checkKeySize(key, fixedKeySize);
core.init(opmode, key, params, random);
}
......@@ -221,6 +327,7 @@ public final class AESCipher extends CipherSpi {
AlgorithmParameters params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
checkKeySize(key, fixedKeySize);
core.init(opmode, key, params, random);
}
......
/*
* Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2012, 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
......@@ -43,8 +43,27 @@ import javax.crypto.spec.*;
*
* @see AESCipher
*/
public final class AESWrapCipher extends CipherSpi {
abstract class AESWrapCipher extends CipherSpi {
public static final class General extends AESWrapCipher {
public General() {
super(-1);
}
}
public static final class AES128 extends AESWrapCipher {
public AES128() {
super(16);
}
}
public static final class AES192 extends AESWrapCipher {
public AES192() {
super(24);
}
}
public static final class AES256 extends AESWrapCipher {
public AES256() {
super(32);
}
}
private static final byte[] IV = {
(byte) 0xA6, (byte) 0xA6, (byte) 0xA6, (byte) 0xA6,
(byte) 0xA6, (byte) 0xA6, (byte) 0xA6, (byte) 0xA6
......@@ -62,12 +81,20 @@ public final class AESWrapCipher extends CipherSpi {
*/
private boolean decrypting = false;
/*
* needed to support AES oids which associates a fixed key size
* to the cipher object.
*/
private final int fixedKeySize; // in bytes, -1 if no restriction
/**
* Creates an instance of AES KeyWrap cipher with default
* mode, i.e. "ECB" and padding scheme, i.e. "NoPadding".
*/
public AESWrapCipher() {
public AESWrapCipher(int keySize) {
cipher = new AESCrypt();
fixedKeySize = keySize;
}
/**
......@@ -170,6 +197,7 @@ public final class AESWrapCipher extends CipherSpi {
throw new UnsupportedOperationException("This cipher can " +
"only be used for key wrapping and unwrapping");
}
AESCipher.checkKeySize(key, fixedKeySize);
cipher.init(decrypting, key.getAlgorithm(), key.getEncoded());
}
......
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, 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
......@@ -80,10 +80,10 @@ public final class DHKeyPairGenerator extends KeyPairGeneratorSpi {
* @param random the source of randomness
*/
public void initialize(int keysize, SecureRandom random) {
if ((keysize < 512) || (keysize > 1024) || (keysize % 64 != 0)) {
if ((keysize < 512) || (keysize > 2048) || (keysize % 64 != 0)) {
throw new InvalidParameterException("Keysize must be multiple "
+ "of 64, and can only range "
+ "from 512 to 1024 "
+ "from 512 to 2048 "
+ "(inclusive)");
}
this.pSize = keysize;
......@@ -115,11 +115,11 @@ public final class DHKeyPairGenerator extends KeyPairGeneratorSpi {
params = (DHParameterSpec)algParams;
pSize = params.getP().bitLength();
if ((pSize < 512) || (pSize > 1024) ||
if ((pSize < 512) || (pSize > 2048) ||
(pSize % 64 != 0)) {
throw new InvalidAlgorithmParameterException
("Prime size must be multiple of 64, and can only range "
+ "from 512 to 1024 (inclusive)");
+ "from 512 to 2048 (inclusive)");
}
// exponent size is optional, could be 0
......@@ -156,10 +156,11 @@ public final class DHKeyPairGenerator extends KeyPairGeneratorSpi {
BigInteger g = params.getG();
if (lSize <= 0) {
lSize = pSize >> 1;
// use an exponent size of (pSize / 2) but at least 384 bits
lSize = Math.max(384, pSize >> 1);
// if lSize is larger than pSize, limit by pSize
lSize = Math.min(lSize, pSize);
if (lSize < 384) {
lSize = 384;
}
}
BigInteger x;
......
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, 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
......@@ -67,10 +67,10 @@ extends AlgorithmParameterGeneratorSpi {
* @param random the source of randomness
*/
protected void engineInit(int keysize, SecureRandom random) {
if ((keysize < 512) || (keysize > 1024) || (keysize % 64 != 0)) {
if ((keysize < 512) || (keysize > 2048) || (keysize % 64 != 0)) {
throw new InvalidParameterException("Keysize must be multiple "
+ "of 64, and can only range "
+ "from 512 to 1024 "
+ "from 512 to 2048 "
+ "(inclusive)");
}
this.primeSize = keysize;
......@@ -99,10 +99,10 @@ extends AlgorithmParameterGeneratorSpi {
DHGenParameterSpec dhParamSpec = (DHGenParameterSpec)genParamSpec;
primeSize = dhParamSpec.getPrimeSize();
if ((primeSize<512) || (primeSize>1024) || (primeSize%64 != 0)) {
if ((primeSize<512) || (primeSize>2048) || (primeSize%64 != 0)) {
throw new InvalidAlgorithmParameterException
("Modulus size must be multiple of 64, and can only range "
+ "from 512 to 1024 (inclusive)");
+ "from 512 to 2048 (inclusive)");
}
exponentSize = dhParamSpec.getExponentSize();
......
......@@ -167,17 +167,67 @@ public final class SunJCE extends Provider {
put("Cipher.Blowfish SupportedPaddings", BLOCK_PADS);
put("Cipher.Blowfish SupportedKeyFormats", "RAW");
put("Cipher.AES", "com.sun.crypto.provider.AESCipher");
put("Cipher.AES", "com.sun.crypto.provider.AESCipher$General");
put("Alg.Alias.Cipher.Rijndael", "AES");
put("Cipher.AES SupportedModes", BLOCK_MODES128);
put("Cipher.AES SupportedPaddings", BLOCK_PADS);
put("Cipher.AES SupportedKeyFormats", "RAW");
put("Cipher.AESWrap", "com.sun.crypto.provider.AESWrapCipher");
put("Cipher.AES_128/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_ECB_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.1", "AES_128/ECB/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.1", "AES_128/ECB/NoPadding");
put("Cipher.AES_128/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_CBC_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.2", "AES_128/CBC/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.2", "AES_128/CBC/NoPadding");
put("Cipher.AES_128/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_OFB_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.3", "AES_128/OFB/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.3", "AES_128/OFB/NoPadding");
put("Cipher.AES_128/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES128_CFB_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.4", "AES_128/CFB/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.4", "AES_128/CFB/NoPadding");
put("Cipher.AES_192/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_ECB_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.21", "AES_192/ECB/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.21", "AES_192/ECB/NoPadding");
put("Cipher.AES_192/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_CBC_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.22", "AES_192/CBC/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.22", "AES_192/CBC/NoPadding");
put("Cipher.AES_192/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_OFB_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.23", "AES_192/OFB/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.23", "AES_192/OFB/NoPadding");
put("Cipher.AES_192/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES192_CFB_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.24", "AES_192/CFB/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.24", "AES_192/CFB/NoPadding");
put("Cipher.AES_256/ECB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_ECB_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.41", "AES_256/ECB/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.41", "AES_256/ECB/NoPadding");
put("Cipher.AES_256/CBC/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_CBC_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.42", "AES_256/CBC/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.42", "AES_256/CBC/NoPadding");
put("Cipher.AES_256/OFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_OFB_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.43", "AES_256/OFB/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.43", "AES_256/OFB/NoPadding");
put("Cipher.AES_256/CFB/NoPadding", "com.sun.crypto.provider.AESCipher$AES256_CFB_NoPadding");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.44", "AES_256/CFB/NoPadding");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.44", "AES_256/CFB/NoPadding");
put("Cipher.AESWrap", "com.sun.crypto.provider.AESWrapCipher$General");
put("Cipher.AESWrap SupportedModes", "ECB");
put("Cipher.AESWrap SupportedPaddings", "NOPADDING");
put("Cipher.AESWrap SupportedKeyFormats", "RAW");
put("Cipher.AESWrap_128", "com.sun.crypto.provider.AESWrapCipher$AES128");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.5", "AESWrap_128");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.5", "AESWrap_128");
put("Cipher.AESWrap_192", "com.sun.crypto.provider.AESWrapCipher$AES192");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.25", "AESWrap_192");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.25", "AESWrap_192");
put("Cipher.AESWrap_256", "com.sun.crypto.provider.AESWrapCipher$AES256");
put("Alg.Alias.Cipher.2.16.840.1.101.3.4.1.45", "AESWrap_256");
put("Alg.Alias.Cipher.OID.2.16.840.1.101.3.4.1.45", "AESWrap_256");
put("Cipher.RC2",
"com.sun.crypto.provider.RC2Cipher");
put("Cipher.RC2 SupportedModes", BLOCK_MODES);
......@@ -192,7 +242,7 @@ public final class SunJCE extends Provider {
put("Cipher.ARCFOUR SupportedKeyFormats", "RAW");
/*
* Key(pair) Generator engines
* Key(pair) Generator engines
*/
put("KeyGenerator.DES",
"com.sun.crypto.provider.DESKeyGenerator");
......@@ -221,6 +271,8 @@ public final class SunJCE extends Provider {
put("KeyGenerator.HmacSHA1",
"com.sun.crypto.provider.HmacSHA1KeyGenerator");
put("Alg.Alias.KeyGenerator.OID.1.2.840.113549.2.7", "HmacSHA1");
put("Alg.Alias.KeyGenerator.1.2.840.113549.2.7", "HmacSHA1");
put("KeyGenerator.HmacSHA224",
"com.sun.crypto.provider.KeyGeneratorCore$HmacSHA2KG$SHA224");
......@@ -326,14 +378,12 @@ public final class SunJCE extends Provider {
"com.sun.crypto.provider.AESParameters");
put("Alg.Alias.AlgorithmParameters.Rijndael", "AES");
put("AlgorithmParameters.RC2",
"com.sun.crypto.provider.RC2Parameters");
put("AlgorithmParameters.OAEP",
"com.sun.crypto.provider.OAEPParameters");
/*
* Key factories
*/
......@@ -403,6 +453,8 @@ public final class SunJCE extends Provider {
*/
put("Mac.HmacMD5", "com.sun.crypto.provider.HmacMD5");
put("Mac.HmacSHA1", "com.sun.crypto.provider.HmacSHA1");
put("Alg.Alias.Mac.OID.1.2.840.113549.2.7", "HmacSHA1");
put("Alg.Alias.Mac.1.2.840.113549.2.7", "HmacSHA1");
put("Mac.HmacSHA224",
"com.sun.crypto.provider.HmacCore$HmacSHA224");
put("Alg.Alias.Mac.OID.1.2.840.113549.2.8", "HmacSHA224");
......
......@@ -883,7 +883,7 @@ class PackageWriter extends BandStructure {
avHiBits &= (1L<<attrIndexLimit[i])-1;
int nextLoBit = 0;
Map<Attribute.Layout, int[]> defMap = allLayouts.get(i);
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
Map.Entry<Attribute.Layout, int[]>[] layoutsAndCounts =
new Map.Entry[defMap.size()];
defMap.entrySet().toArray(layoutsAndCounts);
......
......@@ -178,7 +178,7 @@ public class VMOption {
return "VM option: " + getName() +
" value: " + value + " " +
" origin: " + origin + " " +
(writeable ? "(read-only)" : "(read-write)");
(writeable ? "(read-write)" : "(read-only)");
}
/**
......
......@@ -153,8 +153,8 @@ public final class Init {
break;
}
}
for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) {
if (!(el instanceof Element)) {
for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) {
if (el.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
String tag=el.getLocalName();
......
......@@ -205,7 +205,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
try {
NameSpaceSymbTable ns=new NameSpaceSymbTable();
int nodeLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
if (rootNode instanceof Element) {
if (rootNode != null && rootNode.getNodeType() == Node.ELEMENT_NODE) {
//Fills the nssymbtable with the definitions of the parent of the root subnode
getParentNameSpaces((Element)rootNode,ns);
nodeLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
......@@ -335,7 +335,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
return;
sibling=parentNode.getNextSibling();
parentNode=parentNode.getParentNode();
if (!(parentNode instanceof Element)) {
if (parentNode !=null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
parentNode=null;
}
......@@ -391,7 +391,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
return;
boolean currentNodeIsVisible = false;
NameSpaceSymbTable ns=new NameSpaceSymbTable();
if (currentNode instanceof Element)
if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE)
getParentNameSpaces((Element)currentNode,ns);
Node sibling=null;
Node parentNode=null;
......@@ -512,7 +512,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
return;
sibling=parentNode.getNextSibling();
parentNode=parentNode.getParentNode();
if (!(parentNode instanceof Element)) {
if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
parentNode=null;
documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
}
......@@ -594,18 +594,14 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
final void getParentNameSpaces(Element el,NameSpaceSymbTable ns) {
List<Element> parents=new ArrayList<Element>(10);
Node n1=el.getParentNode();
if (!(n1 instanceof Element)) {
if (n1 == null || n1.getNodeType() != Node.ELEMENT_NODE) {
return;
}
//Obtain all the parents of the elemnt
Element parent=(Element) n1;
while (parent!=null) {
parents.add(parent);
Node n=parent.getParentNode();
if (!(n instanceof Element )) {
break;
}
parent=(Element)n;
Node parent = n1;
while (parent!=null && parent.getNodeType() == Node.ELEMENT_NODE) {
parents.add((Element)parent);
parent = parent.getParentNode();
}
//Visit them in reverse order.
ListIterator<Element> it=parents.listIterator(parents.size());
......
......@@ -1445,7 +1445,7 @@ public class XMLCipher {
// The de-serialiser returns a fragment whose children we need to
// take on.
if (sourceParent instanceof Document) {
if (sourceParent != null && sourceParent.getNodeType() == Node.DOCUMENT_NODE) {
// If this is a content decryption, this may have problems
......
......@@ -283,7 +283,7 @@ public class RetrievalMethodResolver extends KeyResolverSpi {
Element e=null;
while (it.hasNext()) {
Node currentNode=it.next();
if (currentNode instanceof Element) {
if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE) {
e=(Element)currentNode;
break;
}
......@@ -292,14 +292,14 @@ public class RetrievalMethodResolver extends KeyResolverSpi {
List<Element> parents=new ArrayList<Element>(10);
//Obtain all the parents of the elemnt
do {
while (e != null) {
parents.add(e);
Node n=e.getParentNode();
if (!(n instanceof Element )) {
if (n == null || n.getNodeType() != Node.ELEMENT_NODE) {
break;
}
e=(Element)n;
} while (e!=null);
}
//Visit them in reverse order.
ListIterator<Element> it2=parents.listIterator(parents.size()-1);
Element ele=null;
......
......@@ -225,7 +225,7 @@ public class IdResolver {
} while (sibling==null && parentNode!=null) {
sibling=parentNode.getNextSibling();
parentNode=parentNode.getParentNode();
if (!(parentNode instanceof Element)) {
if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
parentNode=null;
}
}
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2012, 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
......@@ -31,7 +31,6 @@ import javax.naming.*;
import java.io.*;
import java.math.*;
import java.util.*;
import java.beans.*;
import javax.sql.rowset.*;
......@@ -83,12 +82,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
*/
private ResultSetMetaData resMD;
/**
* The property that helps to fire the property changed event when certain
* properties are changed in the <code>JdbcRowSet</code> object. This property
* is being added to satisfy Rave requirements.
*/
private PropertyChangeSupport propertyChangeSupport;
/**
* The Vector holding the Match Columns
......@@ -145,7 +138,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
throw new RuntimeException(ioe);
}
propertyChangeSupport = new PropertyChangeSupport(this);
initParams();
......@@ -268,7 +260,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
throw new RuntimeException(ioe);
}
propertyChangeSupport = new PropertyChangeSupport(this);
initParams();
// set the defaults
......@@ -343,7 +334,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
throw new RuntimeException(ioe);
}
propertyChangeSupport = new PropertyChangeSupport(this);
initParams();
......@@ -360,10 +350,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
setMaxRows(0);
setMaxFieldSize(0);
// to ensure connection to a db call connect now
// and associate a conn with "this" object
// in this case.
conn = connect();
setParams();
setReadOnly(true);
......@@ -435,7 +421,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
throw new RuntimeException(ioe);
}
propertyChangeSupport = new PropertyChangeSupport(this);
initParams();
......@@ -620,12 +605,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
}
// An alternate solution is required instead of having the
// connect method as protected.
// This is a work around to assist Rave Team
// :ah
protected Connection connect() throws SQLException {
private Connection connect() throws SQLException {
// Get a JDBC connection.
......@@ -4056,9 +4036,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
// Added as per Rave requirements
if( conn.getHoldability() != HOLD_CURSORS_OVER_COMMIT) {
ResultSet oldVal = rs;
rs = null;
// propertyChangeSupport.firePropertyChange("ResultSet",oldVal,rs);
}
}
......@@ -4119,9 +4097,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
// Makes the result ste handle null after rollback
// Added as per Rave requirements
ResultSet oldVal = rs;
rs = null;
// propertyChangeSupport.firePropertyChange("ResultSet", oldVal,rs);
}
......@@ -4247,12 +4223,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
rs = resultSet;
}
// Over riding the setCommand from BaseRowSet for
// firing the propertyChangeSupport Event for
// Rave requirements when this property's value
// changes.
/**
* Sets this <code>JdbcRowSet</code> object's <code>command</code> property to
* the given <code>String</code> object and clears the parameters, if any,
......@@ -4277,28 +4247,19 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
* @see #getCommand
*/
public void setCommand(String command) throws SQLException {
String oldVal;
if (getCommand() != null) {
if(!getCommand().equals(command)) {
oldVal = getCommand();
super.setCommand(command);
ps = null;
rs = null;
propertyChangeSupport.firePropertyChange("command", oldVal,command);
}
}
else {
super.setCommand(command);
propertyChangeSupport.firePropertyChange("command", null,command);
}
}
// Over riding the setDataSourceName from BaseRowSet for
// firing the propertyChangeSupport Event for
// Rave requirements when this property's values
// changes.
/**
* Sets the <code>dataSourceName</code> property for this <code>JdbcRowSet</code>
* object to the given logical name and sets this <code>JdbcRowSet</code> object's
......@@ -4329,28 +4290,20 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
* @see #getDataSourceName
*/
public void setDataSourceName(String dsName) throws SQLException{
String oldVal;
if(getDataSourceName() != null) {
if(!getDataSourceName().equals(dsName)) {
oldVal = getDataSourceName();
super.setDataSourceName(dsName);
conn = null;
ps = null;
rs = null;
propertyChangeSupport.firePropertyChange("dataSourceName",oldVal,dsName);
}
}
else {
super.setDataSourceName(dsName);
propertyChangeSupport.firePropertyChange("dataSourceName",null,dsName);
}
}
// Over riding the setUrl from BaseRowSet for
// firing the propertyChangeSupport Event for
// Rave requirements when this property's values
// changes.
/**
* Sets the Url property for this <code>JdbcRowSet</code> object
......@@ -4394,29 +4347,20 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
*/
public void setUrl(String url) throws SQLException {
String oldVal;
if(getUrl() != null) {
if(!getUrl().equals(url)) {
oldVal = getUrl();
super.setUrl(url);
conn = null;
ps = null;
rs = null;
propertyChangeSupport.firePropertyChange("url", oldVal, url);
}
}
else {
super.setUrl(url);
propertyChangeSupport.firePropertyChange("url", null, url);
}
}
// Over riding the setUsername from BaseRowSet for
// firing the propertyChangeSupport Event for
// Rave requirements when this property's values
// changes.
/**
* Sets the username property for this <code>JdbcRowSet</code> object
* to the given user name. Because it
......@@ -4438,29 +4382,20 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
* @see #getUsername
*/
public void setUsername(String uname) {
String oldVal;
if( getUsername() != null) {
if(!getUsername().equals(uname)) {
oldVal = getUsername();
super.setUsername(uname);
conn = null;
ps = null;
rs = null;
propertyChangeSupport.firePropertyChange("username",oldVal,uname);
}
}
else{
super.setUsername(uname);
propertyChangeSupport.firePropertyChange("username",null,uname);
}
}
// Over riding the setPassword from BaseRowSet for
// firing the propertyChangeSupport Event for
// Rave requirements when this property's values
// changes.
/**
* Sets the password property for this <code>JdbcRowSet</code> object
* to the given <code>String</code> object. Because it
......@@ -4481,21 +4416,17 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
* that must be supplied to the database to create a connection
*/
public void setPassword(String password) {
String oldVal;
if ( getPassword() != null) {
if(!getPassword().equals(password)) {
oldVal = getPassword();
super.setPassword(password);
conn = null;
ps = null;
rs = null;
propertyChangeSupport.firePropertyChange("password",oldVal,password);
}
}
else{
super.setPassword(password);
propertyChangeSupport.firePropertyChange("password",null,password);
}
}
......@@ -4528,7 +4459,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
if(oldVal != type) {
super.setType(type);
propertyChangeSupport.firePropertyChange("type",oldVal,type);
}
}
......@@ -4561,78 +4491,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
if(oldVal != concur) {
super.setConcurrency(concur);
propertyChangeSupport.firePropertyChange("concurrency",oldVal,concur);
}
}
/**
* Sets the transaction isolation property for this JDBC <code>RowSet</code> object to the given
* constant. The DBMS will use this transaction isolation level for
* transactions if it can.
* <p>
* For <code>RowSet</code> implementations such as
* the <code>CachedRowSet</code> that operate in a disconnected environment,
* the <code>SyncProvider</code> object being used
* offers complementary locking and data integrity options. The
* options described below are pertinent only to connected <code>RowSet</code>
* objects (<code>JdbcRowSet</code> objects).
*
* @param transIso one of the following constants, listed in ascending order:
* <code>Connection.TRANSACTION_NONE</code>,
* <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,
* <code>Connection.TRANSACTION_READ_COMMITTED</code>,
* <code>Connection.TRANSACTION_REPEATABLE_READ</code>, or
* <code>Connection.TRANSACTION_SERIALIZABLE</code>
* @throws SQLException if the given parameter is not one of the Connection
* constants
* @see javax.sql.rowset.spi.SyncFactory
* @see javax.sql.rowset.spi.SyncProvider
* @see #getTransactionIsolation
*/
public void setTransactionIsolation(int transIso) throws SQLException {
int oldVal;
try {
oldVal = getTransactionIsolation();
}catch(NullPointerException ex) {
oldVal = 0;
}
if(oldVal != transIso) {
super.setTransactionIsolation(transIso);
propertyChangeSupport.firePropertyChange("transactionIsolation",oldVal,transIso);
}
}
/**
* Sets the maximum number of rows that this <code>RowSet</code> object may contain to
* the given number. If this limit is exceeded, the excess rows are
* silently dropped.
*
* @param mRows an <code>int</code> indicating the current maximum number
* of rows; zero means that there is no limit
* @throws SQLException if an error occurs internally setting the
* maximum limit on the number of rows that a JDBC <code>RowSet</code> object
* can contain; or if <i>max</i> is less than <code>0</code>; or
* if <i>max</i> is less than the <code>fetchSize</code> of the
* <code>RowSet</code>
*/
public void setMaxRows(int mRows) throws SQLException {
int oldVal;
try {
oldVal = getMaxRows();
}catch(NullPointerException ex) {
oldVal = 0;
}
if(oldVal != mRows) {
super.setMaxRows(mRows);
propertyChangeSupport.firePropertyChange("maxRows",oldVal,mRows);
}
}
......
......@@ -35,8 +35,6 @@ import sun.util.logging.PlatformLogger;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.io.ObjectInputStream;
import java.io.IOException;
/**
* The root event class for all AWT events.
......@@ -262,9 +260,11 @@ public abstract class AWTEvent extends EventObject {
public void setPosted(AWTEvent ev) {
ev.isPosted = true;
}
public void setSystemGenerated(AWTEvent ev) {
ev.isSystemGenerated = true;
}
public boolean isSystemGenerated(AWTEvent ev) {
return ev.isSystemGenerated;
}
......@@ -272,6 +272,15 @@ public abstract class AWTEvent extends EventObject {
public AccessControlContext getAccessControlContext(AWTEvent ev) {
return ev.getAccessControlContext();
}
public byte[] getBData(AWTEvent ev) {
return ev.bdata;
}
public void setBData(AWTEvent ev, byte[] bdata) {
ev.bdata = bdata;
}
});
}
......
......@@ -31,6 +31,7 @@ import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;
import javax.accessibility.*;
import sun.awt.AWTAccessor;
/**
......@@ -68,6 +69,13 @@ public class CheckboxMenuItem extends MenuItem implements ItemSelectable, Access
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
AWTAccessor.setCheckboxMenuItemAccessor(
new AWTAccessor.CheckboxMenuItemAccessor() {
public boolean getState(CheckboxMenuItem cmi) {
return cmi.state;
}
});
}
/**
......
......@@ -150,7 +150,7 @@ import sun.util.logging.PlatformLogger;
* import java.awt.event.*;
* import java.io.Serializable;
*
* class MyApp java.io.Serializable
* class MyApp implements java.io.Serializable
* {
* BigObjectThatShouldNotBeSerializedWithAButton bigOne;
* Button aButton = new Button();
......
......@@ -24,10 +24,6 @@
*/
package java.awt;
import java.awt.AWTException;
import java.awt.Point;
import java.awt.Toolkit;
import java.io.File;
import java.io.FileInputStream;
......@@ -39,6 +35,7 @@ import java.util.StringTokenizer;
import java.security.AccessController;
import sun.util.logging.PlatformLogger;
import sun.awt.AWTAccessor;
/**
* A class to encapsulate the bitmap representation of the mouse cursor.
......@@ -199,6 +196,21 @@ public class Cursor implements java.io.Serializable {
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
AWTAccessor.setCursorAccessor(
new AWTAccessor.CursorAccessor() {
public long getPData(Cursor cursor) {
return cursor.pData;
}
public void setPData(Cursor cursor, long pData) {
cursor.pData = pData;
}
public int getType(Cursor cursor) {
return cursor.type;
}
});
}
/**
......
......@@ -39,6 +39,7 @@ import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import sun.awt.AWTAccessor;
import sun.awt.CausedFocusEvent;
/**
......@@ -75,6 +76,15 @@ public class DefaultKeyboardFocusManager extends KeyboardFocusManager {
typeAheadMarkers = new LinkedList();
private boolean consumeNextKeyTyped;
static {
AWTAccessor.setDefaultKeyboardFocusManagerAccessor(
new AWTAccessor.DefaultKeyboardFocusManagerAccessor() {
public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e) {
dkfm.consumeNextKeyTyped(e);
}
});
}
private static class TypeAheadMarker {
long after;
Component untilFocused;
......
......@@ -36,6 +36,8 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.EmptyStackException;
import sun.awt.dnd.SunDropTargetEvent;
import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
......@@ -50,7 +52,6 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.atomic.AtomicInteger;
import java.security.AccessControlContext;
import java.security.ProtectionDomain;
import sun.misc.SharedSecrets;
import sun.misc.JavaSecurityAccess;
......@@ -186,6 +187,17 @@ public class EventQueue {
public boolean isDispatchThreadImpl(EventQueue eventQueue) {
return eventQueue.isDispatchThreadImpl();
}
public void removeSourceEvents(EventQueue eventQueue,
Object source,
boolean removeAllEvents) {
eventQueue.removeSourceEvents(source, removeAllEvents);
}
public boolean noEvents(EventQueue eventQueue) {
return eventQueue.noEvents();
}
public void wakeup(EventQueue eventQueue, boolean isShutdown) {
eventQueue.wakeup(isShutdown);
}
});
}
......@@ -464,7 +476,9 @@ public class EventQueue {
case MouseEvent.MOUSE_MOVED:
return MOVE;
case MouseEvent.MOUSE_DRAGGED:
return DRAG;
// Return -1 for SunDropTargetEvent since they are usually synchronous
// and we don't want to skip them by coalescing with MouseEvent or other drag events
return e instanceof SunDropTargetEvent ? -1 : DRAG;
default:
return e instanceof PeerEvent ? PEER : -1;
}
......
......@@ -56,7 +56,6 @@ import java.util.WeakHashMap;
import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.HeadlessToolkit;
import sun.awt.SunToolkit;
import sun.awt.CausedFocusEvent;
import sun.awt.KeyboardFocusManagerPeerProvider;
......@@ -148,6 +147,9 @@ public abstract class KeyboardFocusManager
public KeyboardFocusManager getCurrentKeyboardFocusManager(AppContext ctx) {
return KeyboardFocusManager.getCurrentKeyboardFocusManager(ctx);
}
public Container getCurrentFocusCycleRoot() {
return KeyboardFocusManager.currentFocusCycleRoot;
}
}
);
}
......
......@@ -31,6 +31,7 @@ import java.util.Enumeration;
import java.awt.peer.MenuPeer;
import java.awt.event.KeyEvent;
import javax.accessibility.*;
import sun.awt.AWTAccessor;
/**
* A <code>Menu</code> object is a pull-down menu component
......@@ -62,6 +63,13 @@ public class Menu extends MenuItem implements MenuContainer, Accessible {
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
AWTAccessor.setMenuAccessor(
new AWTAccessor.MenuAccessor() {
public Vector getItems(Menu menu) {
return menu.items;
}
});
}
/**
......
......@@ -28,6 +28,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.Vector;
import java.util.Enumeration;
import sun.awt.AWTAccessor;
import java.awt.peer.MenuBarPeer;
import java.awt.event.KeyEvent;
import javax.accessibility.*;
......@@ -74,6 +75,16 @@ public class MenuBar extends MenuComponent implements MenuContainer, Accessible
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
AWTAccessor.setMenuBarAccessor(
new AWTAccessor.MenuBarAccessor() {
public Menu getHelpMenu(MenuBar menuBar) {
return menuBar.helpMenu;
}
public Vector getMenus(MenuBar menuBar) {
return menuBar.menus;
}
});
}
/**
......
......@@ -29,7 +29,6 @@ import java.awt.event.ActionEvent;
import java.io.IOException;
import java.io.ObjectInputStream;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import sun.awt.AWTAccessor;
import javax.accessibility.*;
......@@ -143,6 +142,9 @@ public abstract class MenuComponent implements java.io.Serializable {
public MenuContainer getParent(MenuComponent menuComp) {
return menuComp.parent;
}
public Font getFont_NoClientCode(MenuComponent menuComp) {
return menuComp.getFont_NoClientCode();
}
});
}
......
......@@ -31,7 +31,7 @@ import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;
import javax.accessibility.*;
import sun.awt.AWTAccessor;
/**
* All items in a menu must belong to the class
......@@ -76,6 +76,29 @@ public class MenuItem extends MenuComponent implements Accessible {
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
AWTAccessor.setMenuItemAccessor(
new AWTAccessor.MenuItemAccessor() {
public boolean isEnabled(MenuItem item) {
return item.enabled;
}
public String getLabel(MenuItem item) {
return item.label;
}
public MenuShortcut getShortcut(MenuItem item) {
return item.shortcut;
}
public String getActionCommandImpl(MenuItem item) {
return item.getActionCommandImpl();
}
public boolean isItemEnabled(MenuItem item) {
return item.isItemEnabled();
}
});
}
/**
......
......@@ -33,6 +33,7 @@ import sun.awt.AppContext;
import sun.awt.SunToolkit;
import sun.awt.HeadlessToolkit;
import sun.security.util.SecurityConstants;
import sun.awt.AWTAccessor;
/**
* The <code>SystemTray</code> class represents the system tray for a
......@@ -127,6 +128,18 @@ public class SystemTray {
private static final TrayIcon[] EMPTY_TRAY_ARRAY = new TrayIcon[0];
static {
AWTAccessor.setSystemTrayAccessor(
new AWTAccessor.SystemTrayAccessor() {
public void firePropertyChange(SystemTray tray,
String propertyName,
Object oldValue,
Object newValue) {
tray.firePropertyChange(propertyName, oldValue, newValue);
}
});
}
/**
* Private <code>SystemTray</code> constructor.
*
......
......@@ -25,19 +25,11 @@
package java.awt;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.GraphicsEnvironment;
import java.awt.event.*;
import java.awt.AWTEvent;
import java.awt.AWTEventMulticaster;
import java.awt.EventQueue;
import java.awt.PopupMenu;
import java.awt.Image;
import java.util.EventListener;
import java.awt.peer.TrayIconPeer;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import sun.awt.AWTAccessor;
import sun.awt.HeadlessToolkit;
import java.util.EventObject;
import java.security.AccessControlContext;
......@@ -129,6 +121,16 @@ public class TrayIcon {
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
AWTAccessor.setTrayIconAccessor(
new AWTAccessor.TrayIconAccessor() {
public void addNotify(TrayIcon trayIcon) throws AWTException {
trayIcon.addNotify();
}
public void removeNotify(TrayIcon trayIcon) {
trayIcon.removeNotify();
}
});
}
private TrayIcon()
......
......@@ -25,12 +25,12 @@
package java.awt.event;
import java.awt.Event;
import java.awt.Component;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.io.IOException;
import java.io.ObjectInputStream;
import sun.awt.AWTAccessor;
/**
* An event which indicates that a keystroke occurred in a component.
......@@ -914,6 +914,23 @@ public class KeyEvent extends InputEvent {
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
AWTAccessor.setKeyEventAccessor(
new AWTAccessor.KeyEventAccessor() {
public void setRawCode(KeyEvent ev, long rawCode) {
ev.rawCode = rawCode;
}
public void setPrimaryLevelUnicode(KeyEvent ev,
long primaryLevelUnicode) {
ev.primaryLevelUnicode = primaryLevelUnicode;
}
public void setExtendedKeyCode(KeyEvent ev,
long extendedKeyCode) {
ev.extendedKeyCode = extendedKeyCode;
}
});
}
/**
......
......@@ -657,7 +657,7 @@ public class PropertyDescriptor extends FeatureDescriptor {
throw new IntrospectionException("bad write method arg count: "
+ writeMethod);
}
if (propertyType != null && propertyType != params[0]) {
if (propertyType != null && !params[0].isAssignableFrom(propertyType)) {
throw new IntrospectionException("type mismatch between read and write methods");
}
propertyType = params[0];
......
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, 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
......@@ -31,10 +31,6 @@ import java.util.List;
import java.util.ArrayList;
import java.util.Vector;
import java.util.Collections;
import java.io.ObjectStreamField;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;
import sun.security.util.SecurityConstants;
/**
......@@ -424,7 +420,7 @@ public final class FilePermission extends Permission implements Serializable {
/**
* Converts an actions String to an actions mask.
*
* @param action the action string.
* @param actions the action string.
* @return the actions mask.
*/
private static int getMask(String actions) {
......@@ -435,7 +431,9 @@ public final class FilePermission extends Permission implements Serializable {
if (actions == null) {
return mask;
}
// Check against use of constants (used heavily within the JDK)
// Use object identity comparison against known-interned strings for
// performance benefit (these values are used heavily within the JDK).
if (actions == SecurityConstants.FILE_READ_ACTION) {
return READ;
} else if (actions == SecurityConstants.FILE_WRITE_ACTION) {
......@@ -531,7 +529,7 @@ public final class FilePermission extends Permission implements Serializable {
switch(a[i-matchlen]) {
case ',':
seencomma = true;
/*FALLTHROUGH*/
break;
case ' ': case '\r': case '\n':
case '\f': case '\t':
break;
......@@ -798,7 +796,7 @@ implements Serializable {
* @return an enumeration of all the FilePermission objects.
*/
public Enumeration elements() {
public Enumeration<Permission> elements() {
// Convert Iterator into Enumeration
synchronized (this) {
return Collections.enumeration(perms);
......@@ -843,7 +841,6 @@ implements Serializable {
/*
* Reads in a Vector of FilePermissions and saves them in the perms field.
*/
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
// Don't call defaultReadObject()
......@@ -852,6 +849,7 @@ implements Serializable {
ObjectInputStream.GetField gfields = in.readFields();
// Get the one we want
@SuppressWarnings("unchecked")
Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null);
perms = new ArrayList<>(permissions.size());
perms.addAll(permissions);
......
......@@ -182,7 +182,7 @@ public final class Constructor<T> extends Executable {
* @since 1.5
*/
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public TypeVariable<Constructor<T>>[] getTypeParameters() {
if (getSignature() != null) {
return (TypeVariable<Constructor<T>>[])getGenericInfo().getTypeParameters();
......
......@@ -194,7 +194,7 @@ public final class Method extends Executable {
* @since 1.5
*/
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public TypeVariable<Method>[] getTypeParameters() {
if (getGenericSignature() != null)
return (TypeVariable<Method>[])getGenericInfo().getTypeParameters();
......
......@@ -467,7 +467,6 @@ implements java.io.Serializable
* @param action the action string
* @return the action mask
*/
@SuppressWarnings("fallthrough")
private static int getMask(String action) {
if (action == null) {
......@@ -480,7 +479,8 @@ implements java.io.Serializable
int mask = NONE;
// Check against use of constants (used heavily within the JDK)
// Use object identity comparison against known-interned strings for
// performance benefit (these values are used heavily within the JDK).
if (action == SecurityConstants.SOCKET_RESOLVE_ACTION) {
return RESOLVE;
} else if (action == SecurityConstants.SOCKET_CONNECT_ACTION) {
......@@ -568,7 +568,7 @@ implements java.io.Serializable
switch(a[i-matchlen]) {
case ',':
seencomma = true;
/*FALLTHROUGH*/
break;
case ' ': case '\r': case '\n':
case '\f': case '\t':
break;
......
......@@ -248,7 +248,7 @@ public abstract class AsynchronousFileChannel
return provider.newAsynchronousFileChannel(file, options, executor, attrs);
}
@SuppressWarnings({ "unchecked", "rawtypes" }) // generic array construction
@SuppressWarnings({"unchecked", "rawtypes"}) // generic array construction
private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
/**
......
......@@ -287,7 +287,7 @@ public abstract class FileChannel
return provider.newFileChannel(path, options, attrs);
}
@SuppressWarnings({ "unchecked", "rawtypes" }) // generic array construction
@SuppressWarnings({"unchecked", "rawtypes"}) // generic array construction
private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
/**
......
/*
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, 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
......@@ -62,6 +62,9 @@ import java.security.*;
* interface is all that is needed when you accept defaults for algorithm-specific
* parameters.
*
* <p>Note: Some earlier implementations of this interface may not support
* larger sizes of DSA parameters such as 2048 and 3072-bit.
*
* @see java.security.KeyPairGenerator
*/
public interface DSAKeyPairGenerator {
......@@ -78,7 +81,7 @@ public interface DSAKeyPairGenerator {
* can be null.
*
* @exception InvalidParameterException if the <code>params</code>
* value is invalid or null.
* value is invalid, null, or unsupported.
*/
public void initialize(DSAParams params, SecureRandom random)
throws InvalidParameterException;
......@@ -97,7 +100,7 @@ public interface DSAKeyPairGenerator {
* default parameters for modulus lengths of 512 and 1024 bits.
*
* @param modlen the modulus length in bits. Valid values are any
* multiple of 8 between 512 and 1024, inclusive.
* multiple of 64 between 512 and 1024, inclusive, 2048, and 3072.
*
* @param random the random bit source to use to generate key bits;
* can be null.
......@@ -105,10 +108,9 @@ public interface DSAKeyPairGenerator {
* @param genParams whether or not to generate new parameters for
* the modulus length requested.
*
* @exception InvalidParameterException if <code>modlen</code> is not
* between 512 and 1024, or if <code>genParams</code> is false and
* there are no precomputed parameters for the requested modulus
* length.
* @exception InvalidParameterException if <code>modlen</code> is
* invalid, or unsupported, or if <code>genParams</code> is false and there
* are no precomputed parameters for the requested modulus length.
*/
public void initialize(int modlen, boolean genParams, SecureRandom random)
throws InvalidParameterException;
......
/*
* Copyright (c) 2012, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.security.spec;
/**
* This immutable class specifies the set of parameters used for
* generating DSA parameters as specified in
* <a href="http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf">FIPS 186-3 Digital Signature Standard (DSS)</a>.
*
* @see AlgorithmParameterSpec
*
* @since 8
*/
public final class DSAGenParameterSpec implements AlgorithmParameterSpec {
private final int pLen;
private final int qLen;
private final int seedLen;
/**
* Creates a domain parameter specification for DSA parameter
* generation using <code>primePLen</code> and <code>subprimeQLen</code>.
* The value of <code>subprimeQLen</code> is also used as the default
* length of the domain parameter seed in bits.
* @param primePLen the desired length of the prime P in bits.
* @param subprimeQLen the desired length of the sub-prime Q in bits.
* @exception IllegalArgumentException if <code>primePLen</code>
* or <code>subprimeQLen</code> is illegal per the specification of
* FIPS 186-3.
*/
public DSAGenParameterSpec(int primePLen, int subprimeQLen) {
this(primePLen, subprimeQLen, subprimeQLen);
}
/**
* Creates a domain parameter specification for DSA parameter
* generation using <code>primePLen</code>, <code>subprimeQLen</code>,
* and <code>seedLen</code>.
* @param primePLen the desired length of the prime P in bits.
* @param subprimeQLen the desired length of the sub-prime Q in bits.
* @param seedLen the desired length of the domain parameter seed in bits,
* shall be equal to or greater than <code>subprimeQLen</code>.
* @exception IllegalArgumentException if <code>primePLenLen</code>,
* <code>subprimeQLen</code>, or <code>seedLen</code> is illegal per the
* specification of FIPS 186-3.
*/
public DSAGenParameterSpec(int primePLen, int subprimeQLen, int seedLen) {
switch (primePLen) {
case 1024:
if (subprimeQLen != 160) {
throw new IllegalArgumentException
("subprimeQLen must be 160 when primePLen=1024");
}
break;
case 2048:
if (subprimeQLen != 224 && subprimeQLen != 256) {
throw new IllegalArgumentException
("subprimeQLen must be 224 or 256 when primePLen=2048");
}
break;
case 3072:
if (subprimeQLen != 256) {
throw new IllegalArgumentException
("subprimeQLen must be 256 when primePLen=3072");
}
break;
default:
throw new IllegalArgumentException
("primePLen must be 1024, 2048, or 3072");
}
if (seedLen < subprimeQLen) {
throw new IllegalArgumentException
("seedLen must be equal to or greater than subprimeQLen");
}
this.pLen = primePLen;
this.qLen = subprimeQLen;
this.seedLen = seedLen;
}
/**
* Returns the desired length of the prime P of the
* to-be-generated DSA domain parameters in bits.
* @return the length of the prime P.
*/
public int getPrimePLength() {
return pLen;
}
/**
* Returns the desired length of the sub-prime Q of the
* to-be-generated DSA domain parameters in bits.
* @return the length of the sub-prime Q.
*/
public int getSubprimeQLength() {
return qLen;
}
/**
* Returns the desired length of the domain parameter seed in bits.
* @return the length of the domain parameter seed.
*/
public int getSeedLength() {
return seedLen;
}
}
......@@ -121,6 +121,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
*
* @param numElements the number of elements to hold
*/
@SuppressWarnings("unchecked")
private void allocateElements(int numElements) {
int initialCapacity = MIN_INITIAL_CAPACITY;
// Find the best power of two to hold elements.
......@@ -152,10 +153,11 @@ public class ArrayDeque<E> extends AbstractCollection<E>
int newCapacity = n << 1;
if (newCapacity < 0)
throw new IllegalStateException("Sorry, deque too big");
Object[] a = new Object[newCapacity];
@SuppressWarnings("unchecked")
E[] a = (E[]) new Object[newCapacity];
System.arraycopy(elements, p, a, 0, r);
System.arraycopy(elements, 0, a, r, p);
elements = (E[])a;
elements = a;
head = 0;
tail = n;
}
......@@ -182,6 +184,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
* Constructs an empty array deque with an initial capacity
* sufficient to hold 16 elements.
*/
@SuppressWarnings("unchecked")
public ArrayDeque() {
elements = (E[]) new Object[16];
}
......@@ -793,6 +796,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
* this deque
* @throws NullPointerException if the specified array is null
*/
@SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
int size = size();
if (a.length < size)
......
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, 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
......@@ -560,7 +560,7 @@ public class Arrays {
* off is the offset to generate corresponding low, high in src
* To be removed in a future release.
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
private static void mergeSort(Object[] src,
Object[] dest,
int low,
......@@ -747,7 +747,7 @@ public class Arrays {
* off is the offset into src corresponding to low in dest
* To be removed in a future release.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
private static void mergeSort(Object[] src,
Object[] dest,
int low, int high, int off,
......@@ -2832,6 +2832,7 @@ public class Arrays {
* @return a list view of the specified array
*/
@SafeVarargs
@SuppressWarnings("varargs")
public static <T> List<T> asList(T... a) {
return new ArrayList<>(a);
}
......
......@@ -213,7 +213,7 @@ public class Collections {
* @throws IllegalArgumentException (optional) if the comparator is
* found to violate the {@link Comparator} contract
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
public static <T> void sort(List<T> list, Comparator<? super T> c) {
Object[] a = list.toArray();
Arrays.sort(a, (Comparator)c);
......@@ -418,7 +418,7 @@ public class Collections {
* @throws UnsupportedOperationException if the specified list or
* its list-iterator does not support the <tt>set</tt> operation.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public static void reverse(List<?> list) {
int size = list.size();
if (size < REVERSE_THRESHOLD || list instanceof RandomAccess) {
......@@ -497,7 +497,7 @@ public class Collections {
* @throws UnsupportedOperationException if the specified list or its
* list-iterator does not support the <tt>set</tt> operation.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public static void shuffle(List<?> list, Random rnd) {
int size = list.size();
if (size < SHUFFLE_THRESHOLD || list instanceof RandomAccess) {
......@@ -535,7 +535,7 @@ public class Collections {
* || j &lt; 0 || j &gt;= list.size()).
* @since 1.4
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({"rawtypes", "unchecked"})
public static void swap(List<?> list, int i, int j) {
// instead of using a raw type here, it's possible to capture
// the wildcard but it will require a call to a supplementary
......@@ -669,7 +669,7 @@ public class Collections {
* @throws NoSuchElementException if the collection is empty.
* @see Comparable
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp) {
if (comp==null)
return (T)min((Collection) coll);
......@@ -740,7 +740,7 @@ public class Collections {
* @throws NoSuchElementException if the collection is empty.
* @see Comparable
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp) {
if (comp==null)
return (T)max((Collection) coll);
......@@ -1403,7 +1403,7 @@ public class Collections {
extends UnmodifiableSet<Map.Entry<K,V>> {
private static final long serialVersionUID = 7854390611657943733L;
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
UnmodifiableEntrySet(Set<? extends Map.Entry<? extends K, ? extends V>> s) {
// Need to cast to raw in order to work around a limitation in the type system
super((Set)s);
......@@ -3172,7 +3172,7 @@ public class Collections {
*
* @see #emptySet()
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("rawtypes")
public static final Set EMPTY_SET = new EmptySet<>();
/**
......@@ -3271,10 +3271,13 @@ public class Collections {
return new EmptySortedSet<>();
}
public Comparator comparator() {
@Override
public Comparator<? super E> comparator() {
return null;
}
@Override
@SuppressWarnings("unchecked")
public SortedSet<E> subSet(Object fromElement, Object toElement) {
Objects.requireNonNull(fromElement);
Objects.requireNonNull(toElement);
......@@ -3294,6 +3297,7 @@ public class Collections {
return emptySortedSet();
}
@Override
public SortedSet<E> headSet(Object toElement) {
Objects.requireNonNull(toElement);
......@@ -3304,6 +3308,7 @@ public class Collections {
return emptySortedSet();
}
@Override
public SortedSet<E> tailSet(Object fromElement) {
Objects.requireNonNull(fromElement);
......@@ -3314,10 +3319,12 @@ public class Collections {
return emptySortedSet();
}
@Override
public E first() {
throw new NoSuchElementException();
}
@Override
public E last() {
throw new NoSuchElementException();
}
......@@ -3328,7 +3335,7 @@ public class Collections {
*
* @see #emptyList()
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("rawtypes")
public static final List EMPTY_LIST = new EmptyList<>();
/**
......@@ -3402,7 +3409,7 @@ public class Collections {
* @see #emptyMap()
* @since 1.3
*/
@SuppressWarnings("unchecked")
@SuppressWarnings("rawtypes")
public static final Map EMPTY_MAP = new EmptyMap<>();
/**
......@@ -3685,6 +3692,7 @@ public class Collections {
return a;
}
@SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
final int n = this.n;
if (a.length < n) {
......@@ -3731,6 +3739,7 @@ public class Collections {
* the <tt>Comparable</tt> interface.
* @see Comparable
*/
@SuppressWarnings("unchecked")
public static <T> Comparator<T> reverseOrder() {
return (Comparator<T>) ReverseComparator.REVERSE_ORDER;
}
......
......@@ -208,7 +208,7 @@ class ComparableTimSort {
* @param start the index of the first element in the range that is
* not already known to be sorted ({@code lo <= start <= hi})
*/
@SuppressWarnings({ "fallthrough", "rawtypes", "unchecked" })
@SuppressWarnings({"fallthrough", "rawtypes", "unchecked"})
private static void binarySort(Object[] a, int lo, int hi, int start) {
assert lo <= start && start <= hi;
if (start == lo)
......@@ -277,7 +277,7 @@ class ComparableTimSort {
* @return the length of the run beginning at the specified position in
* the specified array
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
private static int countRunAndMakeAscending(Object[] a, int lo, int hi) {
assert lo < hi;
int runHi = lo + 1;
......@@ -612,7 +612,7 @@ class ComparableTimSort {
* (must be aBase + aLen)
* @param len2 length of second run to be merged (must be > 0)
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
private void mergeLo(int base1, int len1, int base2, int len2) {
assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
......@@ -729,7 +729,7 @@ class ComparableTimSort {
* (must be aBase + aLen)
* @param len2 length of second run to be merged (must be > 0)
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings({"unchecked", "rawtypes"})
private void mergeHi(int base1, int len1, int base2, int len2) {
assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
......
/*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2012, 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
......@@ -34,6 +34,8 @@ import java.io.IOException;
import java.io.Serializable;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.regex.Pattern;
......@@ -60,7 +62,14 @@ import sun.util.logging.PlatformLogger;
* and the ISO 4217 currency data respectively. The value part consists of
* three ISO 4217 values of a currency, i.e., an alphabetic code, a numeric
* code, and a minor unit. Those three ISO 4217 values are separated by commas.
* The lines which start with '#'s are considered comment lines. For example,
* The lines which start with '#'s are considered comment lines. An optional UTC
* timestamp may be specified per currency entry if users need to specify a
* cutover date indicating when the new data comes into effect. The timestamp is
* appended to the end of the currency properties and uses a comma as a separator.
* If a UTC datestamp is present and valid, the JRE will only use the new currency
* properties if the current UTC date is later than the date specified at class
* loading time. The format of the timestamp must be of ISO 8601 format :
* {@code 'yyyy-MM-dd'T'HH:mm:ss'}. For example,
* <p>
* <code>
* #Sample currency properties<br>
......@@ -69,6 +78,20 @@ import sun.util.logging.PlatformLogger;
* <p>
* will supersede the currency data for Japan.
*
* <p>
* <code>
* #Sample currency properties with cutover date<br>
* JP=JPZ,999,0,2014-01-01T00:00:00
* </code>
* <p>
* will supersede the currency data for Japan if {@code Currency} class is loaded after
* 1st January 2014 00:00:00 GMT.
* <p>
* Where syntactically malformed entries are encountered, the entry is ignored
* and the remainder of entries in file are processed. For instances where duplicate
* country code entries exist, the behavior of the Currency information for that
* {@code Currency} is undefined and the remainder of entries in file are processed.
*
* @since 1.4
*/
public final class Currency implements Serializable {
......@@ -100,7 +123,6 @@ public final class Currency implements Serializable {
private static ConcurrentMap<String, Currency> instances = new ConcurrentHashMap<>(7);
private static HashSet<Currency> available;
// Class data: currency data obtained from currency.data file.
// Purpose:
// - determine valid country codes
......@@ -235,7 +257,9 @@ public final class Currency implements Serializable {
}
Set<String> keys = props.stringPropertyNames();
Pattern propertiesPattern =
Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*([0-3])");
Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*" +
"([0-3])\\s*,?\\s*(\\d{4}-\\d{2}-\\d{2}T\\d{2}:" +
"\\d{2}:\\d{2})?");
for (String key : keys) {
replaceCurrencyData(propertiesPattern,
key.toUpperCase(Locale.ROOT),
......@@ -645,29 +669,38 @@ public final class Currency implements Serializable {
* consists of "three-letter alphabet code", "three-digit numeric code",
* and "one-digit (0,1,2, or 3) default fraction digit".
* For example, "JPZ,392,0".
* @throws
* An optional UTC date can be appended to the string (comma separated)
* to allow a currency change take effect after date specified.
* For example, "JP=JPZ,999,0,2014-01-01T00:00:00" has no effect unless
* UTC time is past 1st January 2014 00:00:00 GMT.
*/
private static void replaceCurrencyData(Pattern pattern, String ctry, String curdata) {
if (ctry.length() != 2) {
// ignore invalid country code
String message = new StringBuilder()
.append("The entry in currency.properties for ")
.append(ctry).append(" is ignored because of the invalid country code.")
.toString();
info(message, null);
info("currency.properties entry for " + ctry +
" is ignored because of the invalid country code.", null);
return;
}
Matcher m = pattern.matcher(curdata);
if (!m.find()) {
if (!m.find() || (m.group(4) == null && countOccurrences(curdata, ',') >= 3)) {
// format is not recognized. ignore the data
String message = new StringBuilder()
.append("The entry in currency.properties for ")
.append(ctry)
.append(" is ignored because the value format is not recognized.")
.toString();
info(message, null);
// if group(4) date string is null and we've 4 values, bad date value
info("currency.properties entry for " + ctry +
" ignored because the value format is not recognized.", null);
return;
}
try {
if (m.group(4) != null && !isPastCutoverDate(m.group(4))) {
info("currency.properties entry for " + ctry +
" ignored since cutover date has not passed :" + curdata, null);
return;
}
} catch (IndexOutOfBoundsException | NullPointerException | ParseException ex) {
info("currency.properties entry for " + ctry +
" ignored since exception encountered :" + ex.getMessage(), null);
return;
}
......@@ -695,6 +728,26 @@ public final class Currency implements Serializable {
setMainTableEntry(ctry.charAt(0), ctry.charAt(1), entry);
}
private static boolean isPastCutoverDate(String s)
throws IndexOutOfBoundsException, NullPointerException, ParseException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ROOT);
format.setTimeZone(TimeZone.getTimeZone("UTC"));
format.setLenient(false);
long time = format.parse(s.trim()).getTime();
return System.currentTimeMillis() > time;
}
private static int countOccurrences(String value, char match) {
int count = 0;
for (char c : value.toCharArray()) {
if (c == match) {
++count;
}
}
return count;
}
private static void info(String message, Throwable t) {
PlatformLogger logger = PlatformLogger.getLogger("java.util.Currency");
if (logger.isLoggable(PlatformLogger.INFO)) {
......
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, 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
......@@ -230,7 +230,7 @@ public class HashMap<K,V>
this.loadFactor = loadFactor;
threshold = (int)Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1);
table = new Entry[capacity];
table = new Entry<?,?>[capacity];
init();
}
......@@ -1078,7 +1078,7 @@ public class HashMap<K,V>
capacity <<= 1;
}
table = new Entry[capacity];
table = new Entry<?,?>[capacity];
threshold = (int) Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1);
init(); // Give subclass a chance to do its thing.
......
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2012, 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 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
unseen = elements[0];
}
@Override
public boolean hasNext() {
while (unseen == 0 && unseenIndex < elements.length - 1)
unseen = elements[++unseenIndex];
......@@ -128,6 +129,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
}
@Override
@SuppressWarnings("unchecked")
public E next() {
if (!hasNext())
throw new NoSuchElementException();
......@@ -138,6 +140,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
+ Long.numberOfTrailingZeros(lastReturned)];
}
@Override
public void remove() {
if (lastReturned == 0)
throw new IllegalStateException();
......
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2012, 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
......@@ -330,6 +330,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
return true;
}
@SuppressWarnings("unchecked")
public E peek() {
if (size == 0)
return null;
......
......@@ -246,7 +246,8 @@ public final class PropertyPermission extends BasicPermission {
return mask;
}
// Check against use of constants (used heavily within the JDK)
// Use object identity comparison against known-interned strings for
// performance benefit (these values are used heavily within the JDK).
if (actions == SecurityConstants.PROPERTY_READ_ACTION) {
return READ;
} if (actions == SecurityConstants.PROPERTY_WRITE_ACTION) {
......
/*
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2012, 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
......@@ -125,6 +125,7 @@ public class PropertyResourceBundle extends ResourceBundle {
* @throws IOException if an I/O error occurs
* @throws NullPointerException if <code>stream</code> is null
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public PropertyResourceBundle (InputStream stream) throws IOException {
Properties properties = new Properties();
properties.load(stream);
......@@ -143,6 +144,7 @@ public class PropertyResourceBundle extends ResourceBundle {
* @throws NullPointerException if <code>reader</code> is null
* @since 1.6
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public PropertyResourceBundle (Reader reader) throws IOException {
Properties properties = new Properties();
properties.load(reader);
......
/*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2012, 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
......@@ -325,6 +325,7 @@ class JarVerifier {
* the given file in the jar.
* @deprecated
*/
@Deprecated
public java.security.cert.Certificate[] getCerts(String name)
{
return mapSignersToCertArray(getCodeSigners(name));
......
/*
* Copyright (c) 2003,2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003,2012, 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
......@@ -726,13 +726,13 @@ public abstract class Pack200 {
private static final String PACK_PROVIDER = "java.util.jar.Pack200.Packer";
private static final String UNPACK_PROVIDER = "java.util.jar.Pack200.Unpacker";
private static Class packerImpl;
private static Class unpackerImpl;
private static Class<?> packerImpl;
private static Class<?> unpackerImpl;
private synchronized static Object newInstance(String prop) {
String implName = "(unknown)";
try {
Class impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl;
Class<?> impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl;
if (impl == null) {
// The first time, we must decide which class to use.
implName = java.security.AccessController.doPrivileged(
......
......@@ -25,6 +25,8 @@
package javax.swing;
import sun.awt.AWTAccessor;
/**
* An enumeration for keys used as client properties within the Swing
* implementation.
......@@ -86,6 +88,15 @@ enum ClientPropertyKey {
*/
private final boolean reportValueNotSerializable;
static {
AWTAccessor.setClientPropertyKeyAccessor(
new AWTAccessor.ClientPropertyKeyAccessor() {
public Object getJComponent_TRANSFER_HANDLER() {
return JComponent_TRANSFER_HANDLER;
}
});
}
/**
* Constructs a key with the {@code reportValueNotSerializable} property
* set to {@code false}.
......
......@@ -8590,7 +8590,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* <code>null</code> if this object is not on the screen
*/
public Point getLocationOnScreen() {
if (parent != null) {
if (parent != null && parent.isShowing()) {
Point parentLocation = parent.getLocationOnScreen();
Point componentLocation = getLocation();
componentLocation.translate(parentLocation.x, parentLocation.y);
......@@ -9391,7 +9391,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* <code>null</code> if this object is not on the screen
*/
public Point getLocationOnScreen() {
if (parent != null) {
if (parent != null && parent.isShowing()) {
Point parentLocation = parent.getLocationOnScreen();
Point componentLocation = getLocation();
componentLocation.translate(parentLocation.x, parentLocation.y);
......
/*
* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2012, 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
......@@ -29,12 +29,15 @@ import sun.misc.Unsafe;
import java.awt.*;
import java.awt.KeyboardFocusManager;
import java.awt.DefaultKeyboardFocusManager;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.geom.Point2D;
import java.awt.peer.ComponentPeer;
import java.security.AccessControlContext;
import java.io.File;
import java.util.Vector;
/**
* The AWTAccessor utility class.
......@@ -314,7 +317,7 @@ public final class AWTAccessor {
void setTrayIconWindow(Window w, boolean isTrayIconWindow);
}
/*
/**
* An accessor for the AWTEvent class.
*/
public interface AWTEventAccessor {
......@@ -334,12 +337,20 @@ public final class AWTAccessor {
*/
boolean isSystemGenerated(AWTEvent ev);
/*
/**
* Returns the acc this event was constructed with.
*/
AccessControlContext getAccessControlContext(AWTEvent ev);
/**
* Returns binary data associated with this event;
*/
byte[] getBData(AWTEvent ev);
/**
* Associates binary data with this event;
*/
void setBData(AWTEvent ev, byte[] bdata);
}
public interface InputEventAccessor {
......@@ -367,11 +378,11 @@ public final class AWTAccessor {
Rectangle getMaximizedBounds(Frame frame);
}
/*
/**
* An interface of accessor for the java.awt.KeyboardFocusManager class.
*/
public interface KeyboardFocusManagerAccessor {
/*
/**
* Indicates whether the native implementation should
* proceed with a pending focus request for the heavyweight.
*/
......@@ -381,7 +392,7 @@ public final class AWTAccessor {
boolean focusedWindowChangeAllowed,
long time,
CausedFocusEvent.Cause cause);
/*
/**
* Delivers focus for the lightweight descendant of the heavyweight
* synchronously.
*/
......@@ -390,23 +401,28 @@ public final class AWTAccessor {
boolean temporary,
boolean focusedWindowChangeAllowed,
long time);
/*
/**
* Removes the last focus request for the heavyweight from the queue.
*/
void removeLastFocusRequest(Component heavyweight);
/*
/**
* Sets the most recent focus owner in the window.
*/
void setMostRecentFocusOwner(Window window, Component component);
/*
/**
* Returns current KFM of the specified AppContext.
*/
KeyboardFocusManager getCurrentKeyboardFocusManager(AppContext ctx);
/**
* Return the current focus cycle root
*/
Container getCurrentFocusCycleRoot();
}
/*
/**
* An accessor for the MenuComponent class.
*/
public interface MenuComponentAccessor {
......@@ -424,20 +440,42 @@ public final class AWTAccessor {
* Returns the menu container of the menu component
*/
MenuContainer getParent(MenuComponent menuComp);
/**
* Gets the font used for this menu component.
*/
Font getFont_NoClientCode(MenuComponent menuComp);
}
/*
/**
* An accessor for the EventQueue class
*/
public interface EventQueueAccessor {
/*
/**
* Gets the event dispatch thread.
*/
Thread getDispatchThread(EventQueue eventQueue);
/*
/**
* Checks if the current thread is EDT for the given EQ.
*/
public boolean isDispatchThreadImpl(EventQueue eventQueue);
/**
* Removes any pending events for the specified source object.
*/
void removeSourceEvents(EventQueue eventQueue, Object source, boolean removeAllEvents);
/**
* Returns whether an event is pending on any of the separate Queues.
*/
boolean noEvents(EventQueue eventQueue);
/**
* Called from PostEventQueue.postEvent to notify that a new event
* appeared.
*/
void wakeup(EventQueue eventQueue, boolean isShutdown);
}
/*
......@@ -486,6 +524,148 @@ public final class AWTAccessor {
final int type);
}
/**
* An accessor for the CheckboxMenuItem class
*/
public interface CheckboxMenuItemAccessor {
/**
* Returns whether menu item is checked
*/
boolean getState(CheckboxMenuItem cmi);
}
/**
* An accessor for the Cursor class
*/
public interface CursorAccessor {
/**
* Returns pData of the Cursor class
*/
long getPData(Cursor cursor);
/**
* Sets pData to the Cursor class
*/
void setPData(Cursor cursor, long pData);
/**
* Return type of the Cursor class
*/
int getType(Cursor cursor);
}
/**
* An accessor for the MenuBar class
*/
public interface MenuBarAccessor {
/**
* Returns help menu
*/
Menu getHelpMenu(MenuBar menuBar);
/**
* Returns menus
*/
Vector getMenus(MenuBar menuBar);
}
/**
* An accessor for the MenuItem class
*/
public interface MenuItemAccessor {
/**
* Returns whether menu item is enabled
*/
boolean isEnabled(MenuItem item);
/**
* Gets the command name of the action event that is fired
* by this menu item.
*/
String getActionCommandImpl(MenuItem item);
/**
* Returns true if the item and all its ancestors are
* enabled, false otherwise
*/
boolean isItemEnabled(MenuItem item);
/**
* Returns label
*/
String getLabel(MenuItem item);
/**
* Returns shortcut
*/
MenuShortcut getShortcut(MenuItem item);
}
/**
* An accessor for the Menu class
*/
public interface MenuAccessor {
/**
* Returns vector of the items that are part of the Menu
*/
Vector getItems(Menu menu);
}
/**
* An accessor for the KeyEvent class
*/
public interface KeyEventAccessor {
/**
* Sets rawCode field for KeyEvent
*/
void setRawCode(KeyEvent ev, long rawCode);
/**
* Sets primaryLevelUnicode field for KeyEvent
*/
void setPrimaryLevelUnicode(KeyEvent ev, long primaryLevelUnicode);
/**
* Sets extendedKeyCode field for KeyEvent
*/
void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode);
}
/**
* An accessor for the ClientPropertyKey class
*/
public interface ClientPropertyKeyAccessor {
/**
* Retrieves JComponent_TRANSFER_HANDLER enum object
*/
Object getJComponent_TRANSFER_HANDLER();
}
/**
* An accessor for the SystemTray class
*/
public interface SystemTrayAccessor {
/**
* Support for reporting bound property changes for Object properties.
*/
void firePropertyChange(SystemTray tray, String propertyName, Object oldValue, Object newValue);
}
/**
* An accessor for the TrayIcon class
*/
public interface TrayIconAccessor {
void addNotify(TrayIcon trayIcon) throws AWTException;
void removeNotify(TrayIcon trayIcon);
}
/**
* An accessor for the DefaultKeyboardFocusManager class
*/
public interface DefaultKeyboardFocusManagerAccessor {
public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e);
}
/*
* Accessor instances are initialized in the static initializers of
* corresponding AWT classes by using setters defined below.
......@@ -502,6 +682,16 @@ public final class AWTAccessor {
private static PopupMenuAccessor popupMenuAccessor;
private static FileDialogAccessor fileDialogAccessor;
private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor;
private static CheckboxMenuItemAccessor checkboxMenuItemAccessor;
private static CursorAccessor cursorAccessor;
private static MenuBarAccessor menuBarAccessor;
private static MenuItemAccessor menuItemAccessor;
private static MenuAccessor menuAccessor;
private static KeyEventAccessor keyEventAccessor;
private static ClientPropertyKeyAccessor clientPropertyKeyAccessor;
private static SystemTrayAccessor systemTrayAccessor;
private static TrayIconAccessor trayIconAccessor;
private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor;
/*
* Set an accessor object for the java.awt.Component class.
......@@ -709,4 +899,174 @@ public final class AWTAccessor {
}
return scrollPaneAdjustableAccessor;
}
/**
* Set an accessor object for the java.awt.CheckboxMenuItem class.
*/
public static void setCheckboxMenuItemAccessor(CheckboxMenuItemAccessor cmia) {
checkboxMenuItemAccessor = cmia;
}
/**
* Retrieve the accessor object for the java.awt.CheckboxMenuItem class.
*/
public static CheckboxMenuItemAccessor getCheckboxMenuItemAccessor() {
if (checkboxMenuItemAccessor == null) {
unsafe.ensureClassInitialized(CheckboxMenuItemAccessor.class);
}
return checkboxMenuItemAccessor;
}
/**
* Set an accessor object for the java.awt.Cursor class.
*/
public static void setCursorAccessor(CursorAccessor ca) {
cursorAccessor = ca;
}
/**
* Retrieve the accessor object for the java.awt.Cursor class.
*/
public static CursorAccessor getCursorAccessor() {
if (cursorAccessor == null) {
unsafe.ensureClassInitialized(CursorAccessor.class);
}
return cursorAccessor;
}
/**
* Set an accessor object for the java.awt.MenuBar class.
*/
public static void setMenuBarAccessor(MenuBarAccessor mba) {
menuBarAccessor = mba;
}
/**
* Retrieve the accessor object for the java.awt.MenuBar class.
*/
public static MenuBarAccessor getMenuBarAccessor() {
if (menuBarAccessor == null) {
unsafe.ensureClassInitialized(MenuBarAccessor.class);
}
return menuBarAccessor;
}
/**
* Set an accessor object for the java.awt.MenuItem class.
*/
public static void setMenuItemAccessor(MenuItemAccessor mia) {
menuItemAccessor = mia;
}
/**
* Retrieve the accessor object for the java.awt.MenuItem class.
*/
public static MenuItemAccessor getMenuItemAccessor() {
if (menuItemAccessor == null) {
unsafe.ensureClassInitialized(MenuItemAccessor.class);
}
return menuItemAccessor;
}
/**
* Set an accessor object for the java.awt.Menu class.
*/
public static void setMenuAccessor(MenuAccessor ma) {
menuAccessor = ma;
}
/**
* Retrieve the accessor object for the java.awt.Menu class.
*/
public static MenuAccessor getMenuAccessor() {
if (menuAccessor == null) {
unsafe.ensureClassInitialized(MenuAccessor.class);
}
return menuAccessor;
}
/**
* Set an accessor object for the java.awt.event.KeyEvent class.
*/
public static void setKeyEventAccessor(KeyEventAccessor kea) {
keyEventAccessor = kea;
}
/**
* Retrieve the accessor object for the java.awt.event.KeyEvent class.
*/
public static KeyEventAccessor getKeyEventAccessor() {
if (keyEventAccessor == null) {
unsafe.ensureClassInitialized(KeyEventAccessor.class);
}
return keyEventAccessor;
}
/**
* Set an accessor object for the javax.swing.ClientPropertyKey class.
*/
public static void setClientPropertyKeyAccessor(ClientPropertyKeyAccessor cpka) {
clientPropertyKeyAccessor = cpka;
}
/**
* Retrieve the accessor object for the javax.swing.ClientPropertyKey class.
*/
public static ClientPropertyKeyAccessor getClientPropertyKeyAccessor() {
if (clientPropertyKeyAccessor == null) {
unsafe.ensureClassInitialized(ClientPropertyKeyAccessor.class);
}
return clientPropertyKeyAccessor;
}
/**
* Set an accessor object for the java.awt.SystemTray class.
*/
public static void setSystemTrayAccessor(SystemTrayAccessor sta) {
systemTrayAccessor = sta;
}
/**
* Retrieve the accessor object for the java.awt.SystemTray class.
*/
public static SystemTrayAccessor getSystemTrayAccessor() {
if (systemTrayAccessor == null) {
unsafe.ensureClassInitialized(SystemTrayAccessor.class);
}
return systemTrayAccessor;
}
/**
* Set an accessor object for the java.awt.TrayIcon class.
*/
public static void setTrayIconAccessor(TrayIconAccessor tia) {
trayIconAccessor = tia;
}
/**
* Retrieve the accessor object for the java.awt.TrayIcon class.
*/
public static TrayIconAccessor getTrayIconAccessor() {
if (trayIconAccessor == null) {
unsafe.ensureClassInitialized(TrayIconAccessor.class);
}
return trayIconAccessor;
}
/**
* Set an accessor object for the java.awt.DefaultKeyboardFocusManager class.
*/
public static void setDefaultKeyboardFocusManagerAccessor(DefaultKeyboardFocusManagerAccessor dkfma) {
defaultKeyboardFocusManagerAccessor = dkfma;
}
/**
* Retrieve the accessor object for the java.awt.DefaultKeyboardFocusManager class.
*/
public static DefaultKeyboardFocusManagerAccessor getDefaultKeyboardFocusManagerAccessor() {
if (defaultKeyboardFocusManagerAccessor == null) {
unsafe.ensureClassInitialized(DefaultKeyboardFocusManagerAccessor.class);
}
return defaultKeyboardFocusManagerAccessor;
}
}
......@@ -29,12 +29,6 @@ import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.peer.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.lang.reflect.Field;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
import java.util.Set;
......@@ -66,8 +60,6 @@ public abstract class EmbeddedFrame extends Frame
implements KeyEventDispatcher, PropertyChangeListener {
private boolean isCursorAllowed = true;
private static Field fieldPeer;
private static Field currentCycleRoot;
private boolean supportsXEmbed = false;
private KeyboardFocusManager appletKFM;
// JDK 1.1 compatibility
......@@ -213,39 +205,8 @@ public abstract class EmbeddedFrame extends Frame
*/
public boolean dispatchKeyEvent(KeyEvent e) {
// We can't guarantee that this is called on the same AppContext as EmbeddedFrame
// belongs to. That's why we can't use public methods to find current focus cycle
// root. Instead, we access KFM's private field directly.
if (currentCycleRoot == null) {
currentCycleRoot = AccessController.doPrivileged(new PrivilegedAction<Field>() {
public Field run() {
try {
Field unaccessibleRoot = KeyboardFocusManager.class.
getDeclaredField("currentFocusCycleRoot");
if (unaccessibleRoot != null) {
unaccessibleRoot.setAccessible(true);
}
return unaccessibleRoot;
} catch (NoSuchFieldException e1) {
assert false;
} catch (SecurityException e2) {
assert false;
}
return null;
}
});
}
Container currentRoot = null;
if (currentCycleRoot != null) {
try {
// The field is static, so we can pass null to Field.get() as the argument.
currentRoot = (Container)currentCycleRoot.get(null);
} catch (IllegalAccessException e3) {
// This is impossible: currentCycleRoot would be null if setAccessible failed.
assert false;
}
}
Container currentRoot = AWTAccessor.getKeyboardFocusManagerAccessor()
.getCurrentFocusCycleRoot();
// if we are not in EmbeddedFrame's cycle, we should not try to leave.
if (this != currentRoot) {
......@@ -389,32 +350,8 @@ public abstract class EmbeddedFrame extends Frame
@SuppressWarnings("deprecation")
protected void setPeer(final ComponentPeer p){
if (fieldPeer == null) {
fieldPeer = AccessController.doPrivileged(new PrivilegedAction<Field>() {
public Field run() {
try {
Field lnkPeer = Component.class.getDeclaredField("peer");
if (lnkPeer != null) {
lnkPeer.setAccessible(true);
}
return lnkPeer;
} catch (NoSuchFieldException e) {
assert false;
} catch (SecurityException e) {
assert false;
}
return null;
}//run
});
}
try{
if (fieldPeer != null){
fieldPeer.set(EmbeddedFrame.this, p);
}
} catch (IllegalAccessException e) {
assert false;
}
}; //setPeer method ends
AWTAccessor.getComponentAccessor().setPeer(EmbeddedFrame.this, p);
};
/**
* Synthesize native message to activate or deactivate EmbeddedFrame window
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册