# HG changeset patch # User lana # Date 1346871567 25200 # Node ID c1b9cf3dd7be84d47944b03aaa67603acb6daedd # Parent 3d6ac85b33be1ade73d4718b63fc08282f332875# Parent 72a3850a4c5e829c369c784f4f2bcd18bea93013 Merge diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/.hgtags --- a/jdk/.hgtags Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/.hgtags Wed Sep 05 11:59:27 2012 -0700 @@ -175,3 +175,4 @@ e865efbc71059a414b3b2dd2e0adfcb3d2ab6ff9 jdk8-b51 e8569a473cee7f4955bd9e76a9bdf6c6a07ced27 jdk8-b52 2c6933c5106b81a8578b70996fe5b735fb3adb60 jdk8-b53 +70ad0ed1d6cef0e7712690d1bab21e4769708aad jdk8-b54 diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/make/common/Program.gmk --- a/jdk/make/common/Program.gmk Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/make/common/Program.gmk Wed Sep 05 11:59:27 2012 -0700 @@ -126,6 +126,26 @@ 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. # FILES_o = $(OBJDIR)/main.$(OBJECT_SUFFIX) diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/make/sun/Makefile --- a/jdk/make/sun/Makefile Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/make/sun/Makefile Wed Sep 05 11:59:27 2012 -0700 @@ -87,7 +87,7 @@ 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 diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/make/sun/beans/Makefile --- a/jdk/make/sun/beans/Makefile Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -# -# 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 diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/make/sun/jawt/Makefile --- a/jdk/make/sun/jawt/Makefile Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/make/sun/jawt/Makefile Wed Sep 05 11:59:27 2012 -0700 @@ -31,6 +31,13 @@ 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 # ifeq ($(PLATFORM), windows) diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/com/apple/laf/ScreenMenuItem.java --- a/jdk/src/macosx/classes/com/apple/laf/ScreenMenuItem.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/com/apple/laf/ScreenMenuItem.java Wed Sep 05 11:59:27 2012 -0700 @@ -34,7 +34,7 @@ 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,19 +96,29 @@ 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 CMenuItem cmi = (CMenuItem) peer; + if (ks == null) { + cmi.setLabel(label); + } else { + cmi.setLabel(label, ks.getKeyChar(), ks.getKeyCode(), + ks.getModifiers()); + } + } - 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 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) { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/com/apple/laf/ScreenMenuItemCheckbox.java --- a/jdk/src/macosx/classes/com/apple/laf/ScreenMenuItemCheckbox.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/com/apple/laf/ScreenMenuItemCheckbox.java Wed Sep 05 11:59:27 2012 -0700 @@ -36,7 +36,7 @@ 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 @@ 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) { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java --- a/jdk/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java Wed Sep 05 11:59:27 2012 -0700 @@ -31,8 +31,12 @@ 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 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.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 @@ } finally { rq.unlock(); } + + updateTotalDisplayBounds(); } @Override @@ -478,4 +485,50 @@ 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()); + } } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java --- a/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/sun/lwawt/LWComponentPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -282,7 +282,7 @@ * 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()); } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java --- a/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/sun/lwawt/LWWindowPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -338,6 +338,18 @@ 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 @@ @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; } - platformWindow.setMinimumSize(d.width, d.height); + + 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.setSizeConstraints(min.width, min.height, max.width, max.height); } @Override diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/sun/lwawt/PlatformComponent.java --- a/jdk/src/macosx/classes/sun/lwawt/PlatformComponent.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/sun/lwawt/PlatformComponent.java Wed Sep 05 11:59:27 2012 -0700 @@ -23,15 +23,38 @@ * questions. */ + package sun.lwawt; -import java.awt.Component; - +/** + * 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(); } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/sun/lwawt/PlatformWindow.java --- a/jdk/src/macosx/classes/sun/lwawt/PlatformWindow.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/sun/lwawt/PlatformWindow.java Wed Sep 05 11:59:27 2012 -0700 @@ -131,7 +131,10 @@ 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 diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CFRetainedResource.java Wed Sep 05 11:59:27 2012 -0700 @@ -33,8 +33,8 @@ 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 diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CFileDialog.java Wed Sep 05 11:59:27 2012 -0700 @@ -30,12 +30,14 @@ 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 @@ 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 @@ } 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 diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformComponent.java Wed Sep 05 11:59:27 2012 -0700 @@ -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 @@ 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); } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Wed Sep 05 11:59:27 2012 -0700 @@ -180,7 +180,7 @@ 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) { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java --- a/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Wed Sep 05 11:59:27 2012 -0700 @@ -672,20 +672,15 @@ // 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 diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java --- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Sep 05 11:59:27 2012 -0700 @@ -42,7 +42,7 @@ 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 @@ } } - static String getSystemProperty(final String name, final String deflt) { - return AccessController.doPrivileged (new PrivilegedAction() { - public String run() { - return System.getProperty(name, deflt); - } - }); - } - public LWCToolkit() { SunToolkit.setDataTransfererClassName("sun.lwawt.macosx.CDataTransferer"); @@ -700,8 +692,8 @@ */ public synchronized static boolean getSunAwtDisableCALayers() { if (sunAwtDisableCALayers == null) { - sunAwtDisableCALayers = - getBooleanSystemProperty("sun.awt.disableCALayers"); + sunAwtDisableCALayers = AccessController.doPrivileged( + new GetBooleanAction("sun.awt.disableCALayers")); } return sunAwtDisableCALayers.booleanValue(); } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.m --- a/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.m Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/native/sun/awt/AWTSurfaceLayers.m Wed Sep 05 11:59:27 2012 -0700 @@ -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]; } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/native/sun/awt/CFileDialog.h --- a/jdk/src/macosx/native/sun/awt/CFileDialog.h Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/native/sun/awt/CFileDialog.h Wed Sep 05 11:59:27 2012 -0700 @@ -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 diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/native/sun/awt/CFileDialog.m --- a/jdk/src/macosx/native/sun/awt/CFileDialog.m Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/native/sun/awt/CFileDialog.m Wed Sep 05 11:59:27 2012 -0700 @@ -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 @@ mode:mode multipleMode:multipleMode shouldNavigate:navigateApps + canChooseDirectories:chooseDirectories withEnv:env]; [JNFRunLoop performOnMainThread:@selector(safeSaveOrLoad) diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m --- a/jdk/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/native/sun/java2d/opengl/CGLGraphicsConfig.m Wed Sep 05 11:59:27 2012 -0700 @@ -447,3 +447,20 @@ 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; +} + diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/native/sun/osxapp/NSApplicationAWT.h --- a/jdk/src/macosx/native/sun/osxapp/NSApplicationAWT.h Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/native/sun/osxapp/NSApplicationAWT.h Wed Sep 05 11:59:27 2012 -0700 @@ -28,7 +28,6 @@ @interface NSApplicationAWT : NSApplication { NSString *fApplicationName; - BOOL fUseDefaultIcon; NSWindow *eventTransparentWindow; } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/macosx/native/sun/osxapp/NSApplicationAWT.m --- a/jdk/src/macosx/native/sun/osxapp/NSApplicationAWT.m Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/macosx/native/sun/osxapp/NSApplicationAWT.m Wed Sep 05 11:59:27 2012 -0700 @@ -52,7 +52,6 @@ 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 @@ 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 @@ 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 @@ // 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. diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/decoder/MethodElementHandler.java --- a/jdk/src/share/classes/com/sun/beans/decoder/MethodElementHandler.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/com/sun/beans/decoder/MethodElementHandler.java Wed Sep 05 11:59:27 2012 -0700 @@ -1,5 +1,5 @@ /* - * 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 java.lang.reflect.Method; +import sun.reflect.misc.MethodUtil; + /** * This class is intended to handle <method> element. * It describes invocation of the method. @@ -101,7 +103,7 @@ 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); diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/BooleanEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/BooleanEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,76 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +/** + * Property editor for a java builtin "boolean" type. + */ + +import java.beans.*; + +public class BooleanEditor extends PropertyEditorSupport { + + + public String getJavaInitializationString() { + Object value = getValue(); + return (value != null) + ? value.toString() + : "null"; + } + + public String getAsText() { + Object value = getValue(); + return (value instanceof Boolean) + ? getValidName((Boolean) value) + : null; + } + + public void setAsText(String text) throws java.lang.IllegalArgumentException { + if (text == null) { + setValue(null); + } else if (isValidName(true, text)) { + setValue(Boolean.TRUE); + } else if (isValidName(false, text)) { + setValue(Boolean.FALSE); + } else { + throw new java.lang.IllegalArgumentException(text); + } + } + + public String[] getTags() { + return new String[] {getValidName(true), getValidName(false)}; + } + + // the following method should be localized (4890258) + + private String getValidName(boolean value) { + return value ? "True" : "False"; + } + + private boolean isValidName(boolean value, String name) { + return getValidName(value).equalsIgnoreCase(name); + } +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/ByteEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/ByteEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,48 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +/** + * Property editor for a java builtin "byte" type. + * + */ + +import java.beans.*; + +public class ByteEditor extends NumberEditor { + + public String getJavaInitializationString() { + Object value = getValue(); + return (value != null) + ? "((byte)" + value + ")" + : "null"; + } + + public void setAsText(String text) throws IllegalArgumentException { + setValue((text == null) ? null : Byte.decode(text)); + } + +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/ColorEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/ColorEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,214 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +import java.awt.*; +import java.beans.*; + +public class ColorEditor extends Panel implements PropertyEditor { + private static final long serialVersionUID = 1781257185164716054L; + + public ColorEditor() { + setLayout(null); + + ourWidth = hPad; + + // Create a sample color block bordered in black + Panel p = new Panel(); + p.setLayout(null); + p.setBackground(Color.black); + sample = new Canvas(); + p.add(sample); + sample.reshape(2, 2, sampleWidth, sampleHeight); + add(p); + p.reshape(ourWidth, 2, sampleWidth+4, sampleHeight+4); + ourWidth += sampleWidth + 4 + hPad; + + text = new TextField("", 14); + add(text); + text.reshape(ourWidth,0,100,30); + ourWidth += 100 + hPad; + + choser = new Choice(); + int active = 0; + for (int i = 0; i < colorNames.length; i++) { + choser.addItem(colorNames[i]); + } + add(choser); + choser.reshape(ourWidth,0,100,30); + ourWidth += 100 + hPad; + + resize(ourWidth,40); + } + + public void setValue(Object o) { + Color c = (Color)o; + changeColor(c); + } + + public Dimension preferredSize() { + return new Dimension(ourWidth, 40); + } + + public boolean keyUp(Event e, int key) { + if (e.target == text) { + try { + setAsText(text.getText()); + } catch (IllegalArgumentException ex) { + // Quietly ignore. + } + } + return (false); + } + + public void setAsText(String s) throws java.lang.IllegalArgumentException { + if (s == null) { + changeColor(null); + return; + } + int c1 = s.indexOf(','); + int c2 = s.indexOf(',', c1+1); + if (c1 < 0 || c2 < 0) { + // Invalid string. + throw new IllegalArgumentException(s); + } + try { + int r = Integer.parseInt(s.substring(0,c1)); + int g = Integer.parseInt(s.substring(c1+1, c2)); + int b = Integer.parseInt(s.substring(c2+1)); + Color c = new Color(r,g,b); + changeColor(c); + } catch (Exception ex) { + throw new IllegalArgumentException(s); + } + + } + + public boolean action(Event e, Object arg) { + if (e.target == choser) { + changeColor(colors[choser.getSelectedIndex()]); + } + return false; + } + + public String getJavaInitializationString() { + return (this.color != null) + ? "new java.awt.Color(" + this.color.getRGB() + ",true)" + : "null"; + } + + + private void changeColor(Color c) { + + if (c == null) { + this.color = null; + this.text.setText(""); + return; + } + + color = c; + + text.setText("" + c.getRed() + "," + c.getGreen() + "," + c.getBlue()); + + int active = 0; + for (int i = 0; i < colorNames.length; i++) { + if (color.equals(colors[i])) { + active = i; + } + } + choser.select(active); + + sample.setBackground(color); + sample.repaint(); + + support.firePropertyChange("", null, null); + } + + public Object getValue() { + return color; + } + + public boolean isPaintable() { + return true; + } + + public void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box) { + Color oldColor = gfx.getColor(); + gfx.setColor(Color.black); + gfx.drawRect(box.x, box.y, box.width-3, box.height-3); + gfx.setColor(color); + gfx.fillRect(box.x+1, box.y+1, box.width-4, box.height-4); + gfx.setColor(oldColor); + } + + public String getAsText() { + return (this.color != null) + ? this.color.getRed() + "," + this.color.getGreen() + "," + this.color.getBlue() + : null; + } + + public String[] getTags() { + return null; + } + + public java.awt.Component getCustomEditor() { + return this; + } + + public boolean supportsCustomEditor() { + return true; + } + + public void addPropertyChangeListener(PropertyChangeListener l) { + support.addPropertyChangeListener(l); + } + + public void removePropertyChangeListener(PropertyChangeListener l) { + support.removePropertyChangeListener(l); + } + + + private String colorNames[] = { " ", "white", "lightGray", "gray", "darkGray", + "black", "red", "pink", "orange", + "yellow", "green", "magenta", "cyan", + "blue"}; + private Color colors[] = { null, Color.white, Color.lightGray, Color.gray, Color.darkGray, + Color.black, Color.red, Color.pink, Color.orange, + Color.yellow, Color.green, Color.magenta, Color.cyan, + Color.blue}; + + private Canvas sample; + private int sampleHeight = 20; + private int sampleWidth = 40; + private int hPad = 5; + private int ourWidth; + + private Color color; + private TextField text; + private Choice choser; + + private PropertyChangeSupport support = new PropertyChangeSupport(this); +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/DoubleEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/DoubleEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,41 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +/** + * Property editor for a java builtin "double" type. + * + */ + +import java.beans.*; + +public class DoubleEditor extends NumberEditor { + + public void setAsText(String text) throws IllegalArgumentException { + setValue((text == null) ? null : Double.valueOf(text)); + } + +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/EnumEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/EnumEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,143 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Rectangle; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.beans.PropertyEditor; +import java.util.ArrayList; +import java.util.List; + +/** + * Property editor for java.lang.Enum subclasses. + * + * @see PropertyEditor + * + * @since 1.7 + * + * @author Sergey A. Malenkov + */ +public final class EnumEditor implements PropertyEditor { + private final List listeners = new ArrayList(); + + private final Class type; + private final String[] tags; + + private Object value; + + public EnumEditor( Class type ) { + Object[] values = type.getEnumConstants(); + if ( values == null ) { + throw new IllegalArgumentException( "Unsupported " + type ); + } + this.type = type; + this.tags = new String[values.length]; + for ( int i = 0; i < values.length; i++ ) { + this.tags[i] = ( ( Enum )values[i] ).name(); + } + } + + public Object getValue() { + return this.value; + } + + public void setValue( Object value ) { + if ( ( value != null ) && !this.type.isInstance( value ) ) { + throw new IllegalArgumentException( "Unsupported value: " + value ); + } + Object oldValue; + PropertyChangeListener[] listeners; + synchronized ( this.listeners ) { + oldValue = this.value; + this.value = value; + + if ( ( value == null ) ? oldValue == null : value.equals( oldValue ) ) { + return; // do not fire event if value is not changed + } + int size = this.listeners.size(); + if ( size == 0 ) { + return; // do not fire event if there are no any listener + } + listeners = this.listeners.toArray( new PropertyChangeListener[size] ); + } + PropertyChangeEvent event = new PropertyChangeEvent( this, null, oldValue, value ); + for ( PropertyChangeListener listener : listeners ) { + listener.propertyChange( event ); + } + } + + public String getAsText() { + return ( this.value != null ) + ? ( ( Enum )this.value ).name() + : null; + } + + public void setAsText( String text ) { + setValue( ( text != null ) + ? Enum.valueOf( this.type, text ) + : null ); + } + + public String[] getTags() { + return this.tags.clone(); + } + + public String getJavaInitializationString() { + String name = getAsText(); + return ( name != null ) + ? this.type.getName() + '.' + name + : "null"; + } + + public boolean isPaintable() { + return false; + } + + public void paintValue( Graphics gfx, Rectangle box ) { + } + + public boolean supportsCustomEditor() { + return false; + } + + public Component getCustomEditor() { + return null; + } + + public void addPropertyChangeListener( PropertyChangeListener listener ) { + synchronized ( this.listeners ) { + this.listeners.add( listener ); + } + } + + public void removePropertyChangeListener( PropertyChangeListener listener ) { + synchronized ( this.listeners ) { + this.listeners.remove( listener ); + } + } +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/FloatEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/FloatEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,48 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +/** + * Property editor for a java builtin "float" type. + * + */ + +import java.beans.*; + +public class FloatEditor extends NumberEditor { + + public String getJavaInitializationString() { + Object value = getValue(); + return (value != null) + ? value + "F" + : "null"; + } + + public void setAsText(String text) throws IllegalArgumentException { + setValue((text == null) ? null : Float.valueOf(text)); + } + +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/FontEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/FontEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,219 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +import java.awt.*; +import java.beans.*; + +public class FontEditor extends Panel implements java.beans.PropertyEditor { + private static final long serialVersionUID = 6732704486002715933L; + + public FontEditor() { + setLayout(null); + + toolkit = Toolkit.getDefaultToolkit(); + fonts = toolkit.getFontList(); + + familyChoser = new Choice(); + for (int i = 0; i < fonts.length; i++) { + familyChoser.addItem(fonts[i]); + } + add(familyChoser); + familyChoser.reshape(20, 5, 100, 30); + + styleChoser = new Choice(); + for (int i = 0; i < styleNames.length; i++) { + styleChoser.addItem(styleNames[i]); + } + add(styleChoser); + styleChoser.reshape(145, 5, 70, 30); + + sizeChoser = new Choice(); + for (int i = 0; i < pointSizes.length; i++) { + sizeChoser.addItem("" + pointSizes[i]); + } + add(sizeChoser); + sizeChoser.reshape(220, 5, 70, 30); + + resize(300,40); + } + + + public Dimension preferredSize() { + return new Dimension(300, 40); + } + + public void setValue(Object o) { + font = (Font) o; + if (this.font == null) + return; + + changeFont(font); + // Update the current GUI choices. + for (int i = 0; i < fonts.length; i++) { + if (fonts[i].equals(font.getFamily())) { + familyChoser.select(i); + break; + } + } + for (int i = 0; i < styleNames.length; i++) { + if (font.getStyle() == styles[i]) { + styleChoser.select(i); + break; + } + } + for (int i = 0; i < pointSizes.length; i++) { + if (font.getSize() <= pointSizes[i]) { + sizeChoser.select(i); + break; + } + } + } + + private void changeFont(Font f) { + font = f; + if (sample != null) { + remove(sample); + } + sample = new Label(sampleText); + sample.setFont(font); + add(sample); + Component p = getParent(); + if (p != null) { + p.invalidate(); + p.layout(); + } + invalidate(); + layout(); + repaint(); + support.firePropertyChange("", null, null); + } + + public Object getValue() { + return (font); + } + + public String getJavaInitializationString() { + if (this.font == null) + return "null"; + + return "new java.awt.Font(\"" + font.getName() + "\", " + + font.getStyle() + ", " + font.getSize() + ")"; + } + + public boolean action(Event e, Object arg) { + String family = familyChoser.getSelectedItem(); + int style = styles[styleChoser.getSelectedIndex()]; + int size = pointSizes[sizeChoser.getSelectedIndex()]; + try { + Font f = new Font(family, style, size); + changeFont(f); + } catch (Exception ex) { + System.err.println("Couldn't create font " + family + "-" + + styleNames[style] + "-" + size); + } + return (false); + } + + + public boolean isPaintable() { + return true; + } + + public void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box) { + // Silent noop. + Font oldFont = gfx.getFont(); + gfx.setFont(font); + FontMetrics fm = gfx.getFontMetrics(); + int vpad = (box.height - fm.getAscent())/2; + gfx.drawString(sampleText, 0, box.height-vpad); + gfx.setFont(oldFont); + } + + public String getAsText() { + if (this.font == null) { + return null; + } + StringBuilder sb = new StringBuilder(); + sb.append(this.font.getName()); + sb.append(' '); + + boolean b = this.font.isBold(); + if (b) { + sb.append("BOLD"); + } + boolean i = this.font.isItalic(); + if (i) { + sb.append("ITALIC"); + } + if (b || i) { + sb.append(' '); + } + sb.append(this.font.getSize()); + return sb.toString(); + } + + public void setAsText(String text) throws IllegalArgumentException { + setValue((text == null) ? null : Font.decode(text)); + } + + public String[] getTags() { + return null; + } + + public java.awt.Component getCustomEditor() { + return this; + } + + public boolean supportsCustomEditor() { + return true; + } + + public void addPropertyChangeListener(PropertyChangeListener l) { + support.addPropertyChangeListener(l); + } + + public void removePropertyChangeListener(PropertyChangeListener l) { + support.removePropertyChangeListener(l); + } + + private Font font; + private Toolkit toolkit; + private String sampleText = "Abcde..."; + + private Label sample; + private Choice familyChoser; + private Choice styleChoser; + private Choice sizeChoser; + + private String fonts[]; + private String[] styleNames = { "plain", "bold", "italic" }; + private int[] styles = { Font.PLAIN, Font.BOLD, Font.ITALIC }; + private int[] pointSizes = { 3, 5, 8, 10, 12, 14, 18, 24, 36, 48 }; + + private PropertyChangeSupport support = new PropertyChangeSupport(this); + +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/IntegerEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/IntegerEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,42 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +/** + * Property editor for a java builtin "int" type. + * + */ + +import java.beans.*; + +public class IntegerEditor extends NumberEditor { + + + public void setAsText(String text) throws IllegalArgumentException { + setValue((text == null) ? null : Integer.decode(text)); + } + +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/LongEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/LongEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,48 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +/** + * Property editor for a java builtin "long" type. + * + */ + +import java.beans.*; + +public class LongEditor extends NumberEditor { + + public String getJavaInitializationString() { + Object value = getValue(); + return (value != null) + ? value + "L" + : "null"; + } + + public void setAsText(String text) throws IllegalArgumentException { + setValue((text == null) ? null : Long.decode(text)); + } + +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/NumberEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/NumberEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,44 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +/** + * Abstract Property editor for a java builtin number types. + * + */ + +import java.beans.*; + +abstract public class NumberEditor extends PropertyEditorSupport { + + public String getJavaInitializationString() { + Object value = getValue(); + return (value != null) + ? value.toString() + : "null"; + } + +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/ShortEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/ShortEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,49 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +/** + * Property editor for a java builtin "short" type. + * + */ + +import java.beans.*; + +public class ShortEditor extends NumberEditor { + + public String getJavaInitializationString() { + Object value = getValue(); + return (value != null) + ? "((short)" + value + ")" + : "null"; + } + + public void setAsText(String text) throws IllegalArgumentException { + setValue((text == null) ? null : Short.decode(text)); + } + +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/editors/StringEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/editors/StringEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,74 @@ +/* + * 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 + * 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 com.sun.beans.editors; + +import java.beans.*; + +public class StringEditor extends PropertyEditorSupport { + + public String getJavaInitializationString() { + Object value = getValue(); + if (value == null) + return "null"; + + String str = value.toString(); + int length = str.length(); + StringBuilder sb = new StringBuilder(length + 2); + sb.append('"'); + for (int i = 0; i < length; i++) { + char ch = str.charAt(i); + switch (ch) { + case '\b': sb.append("\\b"); break; + case '\t': sb.append("\\t"); break; + case '\n': sb.append("\\n"); break; + case '\f': sb.append("\\f"); break; + case '\r': sb.append("\\r"); break; + case '\"': sb.append("\\\""); break; + case '\\': sb.append("\\\\"); break; + default: + if ((ch < ' ') || (ch > '~')) { + sb.append("\\u"); + String hex = Integer.toHexString((int) ch); + for (int len = hex.length(); len < 4; len++) { + sb.append('0'); + } + sb.append(hex); + } else { + sb.append(ch); + } + break; + } + } + sb.append('"'); + return sb.toString(); + } + + public void setAsText(String text) { + setValue(text); + } + +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/finder/BeanInfoFinder.java --- a/jdk/src/share/classes/com/sun/beans/finder/BeanInfoFinder.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/com/sun/beans/finder/BeanInfoFinder.java Wed Sep 05 11:59:27 2012 -0700 @@ -1,5 +1,5 @@ /* - * 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 @@ extends InstanceFinder { 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 @@ @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; diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/finder/ClassFinder.java --- a/jdk/src/share/classes/com/sun/beans/finder/ClassFinder.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/com/sun/beans/finder/ClassFinder.java Wed Sep 05 11:59:27 2012 -0700 @@ -1,5 +1,5 @@ /* - * 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 @@ * @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 @@ * @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); diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java --- a/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java Wed Sep 05 11:59:27 2012 -0700 @@ -1,5 +1,5 @@ /* - * 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 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 @@ 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); diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/finder/FieldFinder.java --- a/jdk/src/share/classes/com/sun/beans/finder/FieldFinder.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/com/sun/beans/finder/FieldFinder.java Wed Sep 05 11:59:27 2012 -0700 @@ -1,5 +1,5 @@ /* - * 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 @@ 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 @@ 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; diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java --- a/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java Wed Sep 05 11:59:27 2012 -0700 @@ -1,5 +1,5 @@ /* - * 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.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 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())) { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/finder/PropertyEditorFinder.java --- a/jdk/src/share/classes/com/sun/beans/finder/PropertyEditorFinder.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/com/sun/beans/finder/PropertyEditorFinder.java Wed Sep 05 11:59:27 2012 -0700 @@ -1,5 +1,5 @@ /* - * 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 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 @@ public final class PropertyEditorFinder extends InstanceFinder { + private static final String DEFAULT = "sun.beans.editors"; + private static final String DEFAULT_NEW = "com.sun.beans.editors"; + private final WeakCache, Class> registry; public PropertyEditorFinder() { - super(PropertyEditor.class, false, "Editor", "sun.beans.editors"); + super(PropertyEditor.class, false, "Editor", DEFAULT); this.registry = new WeakCache, Class>(); this.registry.put(Byte.TYPE, ByteEditor.class); @@ -84,4 +87,9 @@ } return editor; } + + @Override + protected PropertyEditor instantiate(Class type, String prefix, String name) { + return super.instantiate(type, DEFAULT.equals(prefix) ? DEFAULT_NEW : prefix, name); + } } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/com/sun/beans/infos/ComponentBeanInfo.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/com/sun/beans/infos/ComponentBeanInfo.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,62 @@ +/* + * 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 + * 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 com.sun.beans.infos; + +import java.beans.*; + +/** + * BeanInfo descriptor for a standard AWT component. + */ + +public class ComponentBeanInfo extends SimpleBeanInfo { + private static final Class beanClass = java.awt.Component.class; + + public PropertyDescriptor[] getPropertyDescriptors() { + try { + PropertyDescriptor + name = new PropertyDescriptor("name", beanClass), + background = new PropertyDescriptor("background", beanClass), + foreground = new PropertyDescriptor("foreground", beanClass), + font = new PropertyDescriptor("font", beanClass), + enabled = new PropertyDescriptor("enabled", beanClass), + visible = new PropertyDescriptor("visible", beanClass), + focusable = new PropertyDescriptor("focusable", beanClass); + + enabled.setExpert(true); + visible.setHidden(true); + + background.setBound(true); + foreground.setBound(true); + font.setBound(true); + focusable.setBound(true); + + PropertyDescriptor[] rv = {name, background, foreground, font, enabled, visible, focusable }; + return rv; + } catch (IntrospectionException e) { + throw new Error(e.toString()); + } + } +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/AWTEvent.java --- a/jdk/src/share/classes/java/awt/AWTEvent.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/AWTEvent.java Wed Sep 05 11:59:27 2012 -0700 @@ -35,8 +35,6 @@ 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 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 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; + } + }); } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/CheckboxMenuItem.java --- a/jdk/src/share/classes/java/awt/CheckboxMenuItem.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/CheckboxMenuItem.java Wed Sep 05 11:59:27 2012 -0700 @@ -31,6 +31,7 @@ import java.io.ObjectInputStream; import java.io.IOException; import javax.accessibility.*; +import sun.awt.AWTAccessor; /** @@ -68,6 +69,13 @@ if (!GraphicsEnvironment.isHeadless()) { initIDs(); } + + AWTAccessor.setCheckboxMenuItemAccessor( + new AWTAccessor.CheckboxMenuItemAccessor() { + public boolean getState(CheckboxMenuItem cmi) { + return cmi.state; + } + }); } /** diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/Component.java --- a/jdk/src/share/classes/java/awt/Component.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/Component.java Wed Sep 05 11:59:27 2012 -0700 @@ -150,7 +150,7 @@ * 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(); diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/Cursor.java --- a/jdk/src/share/classes/java/awt/Cursor.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/Cursor.java Wed Sep 05 11:59:27 2012 -0700 @@ -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.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 @@ 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; + } + }); } /** diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java --- a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java Wed Sep 05 11:59:27 2012 -0700 @@ -39,6 +39,7 @@ import sun.awt.AppContext; import sun.awt.SunToolkit; +import sun.awt.AWTAccessor; import sun.awt.CausedFocusEvent; /** @@ -75,6 +76,15 @@ 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; diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/EventQueue.java --- a/jdk/src/share/classes/java/awt/EventQueue.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/EventQueue.java Wed Sep 05 11:59:27 2012 -0700 @@ -36,6 +36,8 @@ 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.atomic.AtomicInteger; import java.security.AccessControlContext; -import java.security.ProtectionDomain; import sun.misc.SharedSecrets; import sun.misc.JavaSecurityAccess; @@ -186,6 +187,17 @@ 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 @@ 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; } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/KeyboardFocusManager.java --- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java Wed Sep 05 11:59:27 2012 -0700 @@ -56,7 +56,6 @@ 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 KeyboardFocusManager getCurrentKeyboardFocusManager(AppContext ctx) { return KeyboardFocusManager.getCurrentKeyboardFocusManager(ctx); } + public Container getCurrentFocusCycleRoot() { + return KeyboardFocusManager.currentFocusCycleRoot; + } } ); } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/Menu.java --- a/jdk/src/share/classes/java/awt/Menu.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/Menu.java Wed Sep 05 11:59:27 2012 -0700 @@ -31,6 +31,7 @@ import java.awt.peer.MenuPeer; import java.awt.event.KeyEvent; import javax.accessibility.*; +import sun.awt.AWTAccessor; /** * A Menu object is a pull-down menu component @@ -62,6 +63,13 @@ if (!GraphicsEnvironment.isHeadless()) { initIDs(); } + + AWTAccessor.setMenuAccessor( + new AWTAccessor.MenuAccessor() { + public Vector getItems(Menu menu) { + return menu.items; + } + }); } /** diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/MenuBar.java --- a/jdk/src/share/classes/java/awt/MenuBar.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/MenuBar.java Wed Sep 05 11:59:27 2012 -0700 @@ -28,6 +28,7 @@ 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 @@ 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; + } + }); } /** diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/MenuComponent.java --- a/jdk/src/share/classes/java/awt/MenuComponent.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/MenuComponent.java Wed Sep 05 11:59:27 2012 -0700 @@ -29,7 +29,6 @@ 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 MenuContainer getParent(MenuComponent menuComp) { return menuComp.parent; } + public Font getFont_NoClientCode(MenuComponent menuComp) { + return menuComp.getFont_NoClientCode(); + } }); } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/MenuItem.java --- a/jdk/src/share/classes/java/awt/MenuItem.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/MenuItem.java Wed Sep 05 11:59:27 2012 -0700 @@ -31,7 +31,7 @@ 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 @@ 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(); + } + }); } /** diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/SystemTray.java --- a/jdk/src/share/classes/java/awt/SystemTray.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/SystemTray.java Wed Sep 05 11:59:27 2012 -0700 @@ -33,6 +33,7 @@ import sun.awt.SunToolkit; import sun.awt.HeadlessToolkit; import sun.security.util.SecurityConstants; +import sun.awt.AWTAccessor; /** * The SystemTray class represents the system tray for a @@ -127,6 +128,18 @@ 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 SystemTray constructor. * diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/TrayIcon.java --- a/jdk/src/share/classes/java/awt/TrayIcon.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/TrayIcon.java Wed Sep 05 11:59:27 2012 -0700 @@ -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 @@ 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() diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/awt/event/KeyEvent.java --- a/jdk/src/share/classes/java/awt/event/KeyEvent.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/awt/event/KeyEvent.java Wed Sep 05 11:59:27 2012 -0700 @@ -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 @@ 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; + } + }); } /** diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/java/beans/PropertyDescriptor.java --- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java Wed Sep 05 11:59:27 2012 -0700 @@ -657,7 +657,7 @@ 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]; diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/javax/swing/ClientPropertyKey.java --- a/jdk/src/share/classes/javax/swing/ClientPropertyKey.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/javax/swing/ClientPropertyKey.java Wed Sep 05 11:59:27 2012 -0700 @@ -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 @@ */ 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}. diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/javax/swing/JTable.java --- a/jdk/src/share/classes/javax/swing/JTable.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/javax/swing/JTable.java Wed Sep 05 11:59:27 2012 -0700 @@ -8590,7 +8590,7 @@ * null 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 @@ * null 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); diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/awt/AWTAccessor.java --- a/jdk/src/share/classes/sun/awt/AWTAccessor.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java Wed Sep 05 11:59:27 2012 -0700 @@ -1,5 +1,5 @@ /* - * 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 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 @@ void setTrayIconWindow(Window w, boolean isTrayIconWindow); } - /* + /** * An accessor for the AWTEvent class. */ public interface AWTEventAccessor { @@ -334,12 +337,20 @@ */ 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 @@ 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 @@ boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause); - /* + /** * Delivers focus for the lightweight descendant of the heavyweight * synchronously. */ @@ -390,23 +401,28 @@ 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 @@ * 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 @@ 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 @@ 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 @@ } 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; + } } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/awt/EmbeddedFrame.java --- a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java Wed Sep 05 11:59:27 2012 -0700 @@ -29,12 +29,6 @@ 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 @@ 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 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() { - 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 @@ @SuppressWarnings("deprecation") protected void setPeer(final ComponentPeer p){ - if (fieldPeer == null) { - fieldPeer = AccessController.doPrivileged(new PrivilegedAction() { - 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 diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/awt/SunToolkit.java --- a/jdk/src/share/classes/sun/awt/SunToolkit.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/classes/sun/awt/SunToolkit.java Wed Sep 05 11:59:27 2012 -0700 @@ -51,14 +51,8 @@ import sun.awt.image.*; import sun.security.action.GetPropertyAction; import sun.security.action.GetBooleanAction; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; public abstract class SunToolkit extends Toolkit implements WindowClosingSupport, WindowClosingListener, @@ -80,7 +74,6 @@ */ public static final int GRAB_EVENT_MASK = 0x80000000; - private static Method wakeupMethod; /* The key to put()/get() the PostEventQueue into/from the AppContext. */ private static final String POST_EVENT_QUEUE_KEY = "PostEventQueue"; @@ -295,52 +288,8 @@ return appContext; } - public static Field getField(final Class klass, final String fieldName) { - return AccessController.doPrivileged(new PrivilegedAction() { - public Field run() { - try { - Field field = klass.getDeclaredField(fieldName); - assert (field != null); - field.setAccessible(true); - return field; - } catch (SecurityException e) { - assert false; - } catch (NoSuchFieldException e) { - assert false; - } - return null; - }//run - }); - } - static void wakeupEventQueue(EventQueue q, boolean isShutdown){ - if (wakeupMethod == null){ - wakeupMethod = AccessController.doPrivileged(new PrivilegedAction() { - public Method run() { - try { - Method method = EventQueue.class.getDeclaredMethod("wakeup",new Class [] {Boolean.TYPE} ); - if (method != null) { - method.setAccessible(true); - } - return method; - } catch (NoSuchMethodException e) { - assert false; - } catch (SecurityException e) { - assert false; - } - return null; - }//run - }); - } - try{ - if (wakeupMethod != null){ - wakeupMethod.invoke(q, new Object[]{Boolean.valueOf(isShutdown)}); - } - } catch (InvocationTargetException e){ - assert false; - } catch (IllegalAccessException e) { - assert false; - } + AWTAccessor.getEventQueueAccessor().wakeup(q, isShutdown); } /* @@ -1460,22 +1409,6 @@ || comp instanceof Window); } - public static Method getMethod(final Class clz, final String methodName, final Class[] params) { - Method res = null; - try { - res = AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Method run() throws Exception { - Method m = clz.getDeclaredMethod(methodName, params); - m.setAccessible(true); - return m; - } - }); - } catch (PrivilegedActionException ex) { - ex.printStackTrace(); - } - return res; - } - @SuppressWarnings("serial") public static class OperationTimedOut extends RuntimeException { public OperationTimedOut(String msg) { @@ -1622,21 +1555,9 @@ private boolean queueEmpty = false; private final Object waitLock = "Wait Lock"; - static Method eqNoEvents; - private boolean isEQEmpty() { EventQueue queue = getSystemEventQueueImpl(); - synchronized(SunToolkit.class) { - if (eqNoEvents == null) { - eqNoEvents = getMethod(java.awt.EventQueue.class, "noEvents", null); - } - } - try { - return (Boolean)eqNoEvents.invoke(queue); - } catch (Exception e) { - e.printStackTrace(); - return false; - } + return AWTAccessor.getEventQueueAccessor().noEvents(queue); } /** @@ -1892,20 +1813,14 @@ * consumeNextKeyTyped() method is not currently used, * however Swing could use it in the future. */ - private static Method consumeNextKeyTypedMethod = null; public static synchronized void consumeNextKeyTyped(KeyEvent keyEvent) { - if (consumeNextKeyTypedMethod == null) { - consumeNextKeyTypedMethod = getMethod(DefaultKeyboardFocusManager.class, - "consumeNextKeyTyped", - new Class[] {KeyEvent.class}); - } try { - consumeNextKeyTypedMethod.invoke(KeyboardFocusManager.getCurrentKeyboardFocusManager(), - keyEvent); - } catch (IllegalAccessException iae) { - iae.printStackTrace(); - } catch (InvocationTargetException ite) { - ite.printStackTrace(); + AWTAccessor.getDefaultKeyboardFocusManagerAccessor().consumeNextKeyTyped( + (DefaultKeyboardFocusManager)KeyboardFocusManager. + getCurrentKeyboardFocusManager(), + keyEvent); + } catch (ClassCastException cce) { + cce.printStackTrace(); } } @@ -1925,24 +1840,6 @@ return (Window)comp; } - /** - * Returns the value of the system property indicated by the specified key. - */ - public static String getSystemProperty(final String key) { - return AccessController.doPrivileged(new PrivilegedAction() { - public String run() { - return System.getProperty(key); - } - }); - } - - /** - * Returns the boolean value of the system property indicated by the specified key. - */ - protected static Boolean getBooleanSystemProperty(String key) { - return AccessController.doPrivileged(new GetBooleanAction(key)); - } - private static Boolean sunAwtDisableMixing = null; /** @@ -1951,7 +1848,8 @@ */ public synchronized static boolean getSunAwtDisableMixing() { if (sunAwtDisableMixing == null) { - sunAwtDisableMixing = getBooleanSystemProperty("sun.awt.disableMixing"); + sunAwtDisableMixing = AccessController.doPrivileged( + new GetBooleanAction("sun.awt.disableMixing")); } return sunAwtDisableMixing.booleanValue(); } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/awt/TextureSizeConstraining.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/share/classes/sun/awt/TextureSizeConstraining.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,45 @@ +/* + * 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 sun.awt; + +/** + * A GraphicsConfiguration implements the TextureSizeConstraining + * interface to indicate that it imposes certain limitations on the + * maximum size of supported textures. + */ +public interface TextureSizeConstraining { + + /** + * Returns the maximum width of any texture image. + */ + public int getMaxTextureWidth(); + + /** + * Returns the maximum height of any texture image. + */ + public int getMaxTextureHeight(); + +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/BooleanEditor.java --- a/jdk/src/share/classes/sun/beans/editors/BooleanEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2006, 2007, 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 sun.beans.editors; - -/** - * Property editor for a java builtin "boolean" type. - */ - -import java.beans.*; - -public class BooleanEditor extends PropertyEditorSupport { - - - public String getJavaInitializationString() { - Object value = getValue(); - return (value != null) - ? value.toString() - : "null"; - } - - public String getAsText() { - Object value = getValue(); - return (value instanceof Boolean) - ? getValidName((Boolean) value) - : null; - } - - public void setAsText(String text) throws java.lang.IllegalArgumentException { - if (text == null) { - setValue(null); - } else if (isValidName(true, text)) { - setValue(Boolean.TRUE); - } else if (isValidName(false, text)) { - setValue(Boolean.FALSE); - } else { - throw new java.lang.IllegalArgumentException(text); - } - } - - public String[] getTags() { - return new String[] {getValidName(true), getValidName(false)}; - } - - // the following method should be localized (4890258) - - private String getValidName(boolean value) { - return value ? "True" : "False"; - } - - private boolean isValidName(boolean value, String name) { - return getValidName(value).equalsIgnoreCase(name); - } -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/ByteEditor.java --- a/jdk/src/share/classes/sun/beans/editors/ByteEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1996, 2007, 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 sun.beans.editors; - -/** - * Property editor for a java builtin "byte" type. - * - */ - -import java.beans.*; - -public class ByteEditor extends NumberEditor { - - public String getJavaInitializationString() { - Object value = getValue(); - return (value != null) - ? "((byte)" + value + ")" - : "null"; - } - - public void setAsText(String text) throws IllegalArgumentException { - setValue((text == null) ? null : Byte.decode(text)); - } - -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/ColorEditor.java --- a/jdk/src/share/classes/sun/beans/editors/ColorEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +0,0 @@ -/* - * Copyright (c) 1996, 2009, 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 sun.beans.editors; - -import java.awt.*; -import java.beans.*; - -public class ColorEditor extends Panel implements PropertyEditor { - private static final long serialVersionUID = 1781257185164716054L; - - public ColorEditor() { - setLayout(null); - - ourWidth = hPad; - - // Create a sample color block bordered in black - Panel p = new Panel(); - p.setLayout(null); - p.setBackground(Color.black); - sample = new Canvas(); - p.add(sample); - sample.reshape(2, 2, sampleWidth, sampleHeight); - add(p); - p.reshape(ourWidth, 2, sampleWidth+4, sampleHeight+4); - ourWidth += sampleWidth + 4 + hPad; - - text = new TextField("", 14); - add(text); - text.reshape(ourWidth,0,100,30); - ourWidth += 100 + hPad; - - choser = new Choice(); - int active = 0; - for (int i = 0; i < colorNames.length; i++) { - choser.addItem(colorNames[i]); - } - add(choser); - choser.reshape(ourWidth,0,100,30); - ourWidth += 100 + hPad; - - resize(ourWidth,40); - } - - public void setValue(Object o) { - Color c = (Color)o; - changeColor(c); - } - - public Dimension preferredSize() { - return new Dimension(ourWidth, 40); - } - - public boolean keyUp(Event e, int key) { - if (e.target == text) { - try { - setAsText(text.getText()); - } catch (IllegalArgumentException ex) { - // Quietly ignore. - } - } - return (false); - } - - public void setAsText(String s) throws java.lang.IllegalArgumentException { - if (s == null) { - changeColor(null); - return; - } - int c1 = s.indexOf(','); - int c2 = s.indexOf(',', c1+1); - if (c1 < 0 || c2 < 0) { - // Invalid string. - throw new IllegalArgumentException(s); - } - try { - int r = Integer.parseInt(s.substring(0,c1)); - int g = Integer.parseInt(s.substring(c1+1, c2)); - int b = Integer.parseInt(s.substring(c2+1)); - Color c = new Color(r,g,b); - changeColor(c); - } catch (Exception ex) { - throw new IllegalArgumentException(s); - } - - } - - public boolean action(Event e, Object arg) { - if (e.target == choser) { - changeColor(colors[choser.getSelectedIndex()]); - } - return false; - } - - public String getJavaInitializationString() { - return (this.color != null) - ? "new java.awt.Color(" + this.color.getRGB() + ",true)" - : "null"; - } - - - private void changeColor(Color c) { - - if (c == null) { - this.color = null; - this.text.setText(""); - return; - } - - color = c; - - text.setText("" + c.getRed() + "," + c.getGreen() + "," + c.getBlue()); - - int active = 0; - for (int i = 0; i < colorNames.length; i++) { - if (color.equals(colors[i])) { - active = i; - } - } - choser.select(active); - - sample.setBackground(color); - sample.repaint(); - - support.firePropertyChange("", null, null); - } - - public Object getValue() { - return color; - } - - public boolean isPaintable() { - return true; - } - - public void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box) { - Color oldColor = gfx.getColor(); - gfx.setColor(Color.black); - gfx.drawRect(box.x, box.y, box.width-3, box.height-3); - gfx.setColor(color); - gfx.fillRect(box.x+1, box.y+1, box.width-4, box.height-4); - gfx.setColor(oldColor); - } - - public String getAsText() { - return (this.color != null) - ? this.color.getRed() + "," + this.color.getGreen() + "," + this.color.getBlue() - : null; - } - - public String[] getTags() { - return null; - } - - public java.awt.Component getCustomEditor() { - return this; - } - - public boolean supportsCustomEditor() { - return true; - } - - public void addPropertyChangeListener(PropertyChangeListener l) { - support.addPropertyChangeListener(l); - } - - public void removePropertyChangeListener(PropertyChangeListener l) { - support.removePropertyChangeListener(l); - } - - - private String colorNames[] = { " ", "white", "lightGray", "gray", "darkGray", - "black", "red", "pink", "orange", - "yellow", "green", "magenta", "cyan", - "blue"}; - private Color colors[] = { null, Color.white, Color.lightGray, Color.gray, Color.darkGray, - Color.black, Color.red, Color.pink, Color.orange, - Color.yellow, Color.green, Color.magenta, Color.cyan, - Color.blue}; - - private Canvas sample; - private int sampleHeight = 20; - private int sampleWidth = 40; - private int hPad = 5; - private int ourWidth; - - private Color color; - private TextField text; - private Choice choser; - - private PropertyChangeSupport support = new PropertyChangeSupport(this); -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/DoubleEditor.java --- a/jdk/src/share/classes/sun/beans/editors/DoubleEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 1996, 2007, 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 sun.beans.editors; - -/** - * Property editor for a java builtin "double" type. - * - */ - -import java.beans.*; - -public class DoubleEditor extends NumberEditor { - - public void setAsText(String text) throws IllegalArgumentException { - setValue((text == null) ? null : Double.valueOf(text)); - } - -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/EnumEditor.java --- a/jdk/src/share/classes/sun/beans/editors/EnumEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2006, 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 sun.beans.editors; - -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.beans.PropertyEditor; -import java.util.ArrayList; -import java.util.List; - -/** - * Property editor for java.lang.Enum subclasses. - * - * @see PropertyEditor - * - * @since 1.7 - * - * @author Sergey A. Malenkov - */ -public final class EnumEditor implements PropertyEditor { - private final List listeners = new ArrayList(); - - private final Class type; - private final String[] tags; - - private Object value; - - public EnumEditor( Class type ) { - Object[] values = type.getEnumConstants(); - if ( values == null ) { - throw new IllegalArgumentException( "Unsupported " + type ); - } - this.type = type; - this.tags = new String[values.length]; - for ( int i = 0; i < values.length; i++ ) { - this.tags[i] = ( ( Enum )values[i] ).name(); - } - } - - public Object getValue() { - return this.value; - } - - public void setValue( Object value ) { - if ( ( value != null ) && !this.type.isInstance( value ) ) { - throw new IllegalArgumentException( "Unsupported value: " + value ); - } - Object oldValue; - PropertyChangeListener[] listeners; - synchronized ( this.listeners ) { - oldValue = this.value; - this.value = value; - - if ( ( value == null ) ? oldValue == null : value.equals( oldValue ) ) { - return; // do not fire event if value is not changed - } - int size = this.listeners.size(); - if ( size == 0 ) { - return; // do not fire event if there are no any listener - } - listeners = this.listeners.toArray( new PropertyChangeListener[size] ); - } - PropertyChangeEvent event = new PropertyChangeEvent( this, null, oldValue, value ); - for ( PropertyChangeListener listener : listeners ) { - listener.propertyChange( event ); - } - } - - public String getAsText() { - return ( this.value != null ) - ? ( ( Enum )this.value ).name() - : null; - } - - public void setAsText( String text ) { - setValue( ( text != null ) - ? Enum.valueOf( this.type, text ) - : null ); - } - - public String[] getTags() { - return this.tags.clone(); - } - - public String getJavaInitializationString() { - String name = getAsText(); - return ( name != null ) - ? this.type.getName() + '.' + name - : "null"; - } - - public boolean isPaintable() { - return false; - } - - public void paintValue( Graphics gfx, Rectangle box ) { - } - - public boolean supportsCustomEditor() { - return false; - } - - public Component getCustomEditor() { - return null; - } - - public void addPropertyChangeListener( PropertyChangeListener listener ) { - synchronized ( this.listeners ) { - this.listeners.add( listener ); - } - } - - public void removePropertyChangeListener( PropertyChangeListener listener ) { - synchronized ( this.listeners ) { - this.listeners.remove( listener ); - } - } -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/FloatEditor.java --- a/jdk/src/share/classes/sun/beans/editors/FloatEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1996, 2007, 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 sun.beans.editors; - -/** - * Property editor for a java builtin "float" type. - * - */ - -import java.beans.*; - -public class FloatEditor extends NumberEditor { - - public String getJavaInitializationString() { - Object value = getValue(); - return (value != null) - ? value + "F" - : "null"; - } - - public void setAsText(String text) throws IllegalArgumentException { - setValue((text == null) ? null : Float.valueOf(text)); - } - -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/FontEditor.java --- a/jdk/src/share/classes/sun/beans/editors/FontEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,219 +0,0 @@ -/* - * Copyright (c) 1996, 2009, 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 sun.beans.editors; - -import java.awt.*; -import java.beans.*; - -public class FontEditor extends Panel implements java.beans.PropertyEditor { - private static final long serialVersionUID = 6732704486002715933L; - - public FontEditor() { - setLayout(null); - - toolkit = Toolkit.getDefaultToolkit(); - fonts = toolkit.getFontList(); - - familyChoser = new Choice(); - for (int i = 0; i < fonts.length; i++) { - familyChoser.addItem(fonts[i]); - } - add(familyChoser); - familyChoser.reshape(20, 5, 100, 30); - - styleChoser = new Choice(); - for (int i = 0; i < styleNames.length; i++) { - styleChoser.addItem(styleNames[i]); - } - add(styleChoser); - styleChoser.reshape(145, 5, 70, 30); - - sizeChoser = new Choice(); - for (int i = 0; i < pointSizes.length; i++) { - sizeChoser.addItem("" + pointSizes[i]); - } - add(sizeChoser); - sizeChoser.reshape(220, 5, 70, 30); - - resize(300,40); - } - - - public Dimension preferredSize() { - return new Dimension(300, 40); - } - - public void setValue(Object o) { - font = (Font) o; - if (this.font == null) - return; - - changeFont(font); - // Update the current GUI choices. - for (int i = 0; i < fonts.length; i++) { - if (fonts[i].equals(font.getFamily())) { - familyChoser.select(i); - break; - } - } - for (int i = 0; i < styleNames.length; i++) { - if (font.getStyle() == styles[i]) { - styleChoser.select(i); - break; - } - } - for (int i = 0; i < pointSizes.length; i++) { - if (font.getSize() <= pointSizes[i]) { - sizeChoser.select(i); - break; - } - } - } - - private void changeFont(Font f) { - font = f; - if (sample != null) { - remove(sample); - } - sample = new Label(sampleText); - sample.setFont(font); - add(sample); - Component p = getParent(); - if (p != null) { - p.invalidate(); - p.layout(); - } - invalidate(); - layout(); - repaint(); - support.firePropertyChange("", null, null); - } - - public Object getValue() { - return (font); - } - - public String getJavaInitializationString() { - if (this.font == null) - return "null"; - - return "new java.awt.Font(\"" + font.getName() + "\", " + - font.getStyle() + ", " + font.getSize() + ")"; - } - - public boolean action(Event e, Object arg) { - String family = familyChoser.getSelectedItem(); - int style = styles[styleChoser.getSelectedIndex()]; - int size = pointSizes[sizeChoser.getSelectedIndex()]; - try { - Font f = new Font(family, style, size); - changeFont(f); - } catch (Exception ex) { - System.err.println("Couldn't create font " + family + "-" + - styleNames[style] + "-" + size); - } - return (false); - } - - - public boolean isPaintable() { - return true; - } - - public void paintValue(java.awt.Graphics gfx, java.awt.Rectangle box) { - // Silent noop. - Font oldFont = gfx.getFont(); - gfx.setFont(font); - FontMetrics fm = gfx.getFontMetrics(); - int vpad = (box.height - fm.getAscent())/2; - gfx.drawString(sampleText, 0, box.height-vpad); - gfx.setFont(oldFont); - } - - public String getAsText() { - if (this.font == null) { - return null; - } - StringBuilder sb = new StringBuilder(); - sb.append(this.font.getName()); - sb.append(' '); - - boolean b = this.font.isBold(); - if (b) { - sb.append("BOLD"); - } - boolean i = this.font.isItalic(); - if (i) { - sb.append("ITALIC"); - } - if (b || i) { - sb.append(' '); - } - sb.append(this.font.getSize()); - return sb.toString(); - } - - public void setAsText(String text) throws IllegalArgumentException { - setValue((text == null) ? null : Font.decode(text)); - } - - public String[] getTags() { - return null; - } - - public java.awt.Component getCustomEditor() { - return this; - } - - public boolean supportsCustomEditor() { - return true; - } - - public void addPropertyChangeListener(PropertyChangeListener l) { - support.addPropertyChangeListener(l); - } - - public void removePropertyChangeListener(PropertyChangeListener l) { - support.removePropertyChangeListener(l); - } - - private Font font; - private Toolkit toolkit; - private String sampleText = "Abcde..."; - - private Label sample; - private Choice familyChoser; - private Choice styleChoser; - private Choice sizeChoser; - - private String fonts[]; - private String[] styleNames = { "plain", "bold", "italic" }; - private int[] styles = { Font.PLAIN, Font.BOLD, Font.ITALIC }; - private int[] pointSizes = { 3, 5, 8, 10, 12, 14, 18, 24, 36, 48 }; - - private PropertyChangeSupport support = new PropertyChangeSupport(this); - -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/IntegerEditor.java --- a/jdk/src/share/classes/sun/beans/editors/IntegerEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2006, 2007, 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 sun.beans.editors; - -/** - * Property editor for a java builtin "int" type. - * - */ - -import java.beans.*; - -public class IntegerEditor extends NumberEditor { - - - public void setAsText(String text) throws IllegalArgumentException { - setValue((text == null) ? null : Integer.decode(text)); - } - -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/LongEditor.java --- a/jdk/src/share/classes/sun/beans/editors/LongEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 1996, 2007, 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 sun.beans.editors; - -/** - * Property editor for a java builtin "long" type. - * - */ - -import java.beans.*; - -public class LongEditor extends NumberEditor { - - public String getJavaInitializationString() { - Object value = getValue(); - return (value != null) - ? value + "L" - : "null"; - } - - public void setAsText(String text) throws IllegalArgumentException { - setValue((text == null) ? null : Long.decode(text)); - } - -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/NumberEditor.java --- a/jdk/src/share/classes/sun/beans/editors/NumberEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1996, 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 sun.beans.editors; - -/** - * Abstract Property editor for a java builtin number types. - * - */ - -import java.beans.*; - -abstract public class NumberEditor extends PropertyEditorSupport { - - public String getJavaInitializationString() { - Object value = getValue(); - return (value != null) - ? value.toString() - : "null"; - } - -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/ShortEditor.java --- a/jdk/src/share/classes/sun/beans/editors/ShortEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1996, 2007, 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 sun.beans.editors; - -/** - * Property editor for a java builtin "short" type. - * - */ - -import java.beans.*; - -public class ShortEditor extends NumberEditor { - - public String getJavaInitializationString() { - Object value = getValue(); - return (value != null) - ? "((short)" + value + ")" - : "null"; - } - - public void setAsText(String text) throws IllegalArgumentException { - setValue((text == null) ? null : Short.decode(text)); - } - -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/editors/StringEditor.java --- a/jdk/src/share/classes/sun/beans/editors/StringEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 1996, 2006, 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 sun.beans.editors; - -import java.beans.*; - -public class StringEditor extends PropertyEditorSupport { - - public String getJavaInitializationString() { - Object value = getValue(); - if (value == null) - return "null"; - - String str = value.toString(); - int length = str.length(); - StringBuilder sb = new StringBuilder(length + 2); - sb.append('"'); - for (int i = 0; i < length; i++) { - char ch = str.charAt(i); - switch (ch) { - case '\b': sb.append("\\b"); break; - case '\t': sb.append("\\t"); break; - case '\n': sb.append("\\n"); break; - case '\f': sb.append("\\f"); break; - case '\r': sb.append("\\r"); break; - case '\"': sb.append("\\\""); break; - case '\\': sb.append("\\\\"); break; - default: - if ((ch < ' ') || (ch > '~')) { - sb.append("\\u"); - String hex = Integer.toHexString((int) ch); - for (int len = hex.length(); len < 4; len++) { - sb.append('0'); - } - sb.append(hex); - } else { - sb.append(ch); - } - break; - } - } - sb.append('"'); - return sb.toString(); - } - - public void setAsText(String text) { - setValue(text); - } - -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/classes/sun/beans/infos/ComponentBeanInfo.java --- a/jdk/src/share/classes/sun/beans/infos/ComponentBeanInfo.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 1996, 2002, 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 sun.beans.infos; - -import java.beans.*; - -/** - * BeanInfo descriptor for a standard AWT component. - */ - -public class ComponentBeanInfo extends SimpleBeanInfo { - private static final Class beanClass = java.awt.Component.class; - - public PropertyDescriptor[] getPropertyDescriptors() { - try { - PropertyDescriptor - name = new PropertyDescriptor("name", beanClass), - background = new PropertyDescriptor("background", beanClass), - foreground = new PropertyDescriptor("foreground", beanClass), - font = new PropertyDescriptor("font", beanClass), - enabled = new PropertyDescriptor("enabled", beanClass), - visible = new PropertyDescriptor("visible", beanClass), - focusable = new PropertyDescriptor("focusable", beanClass); - - enabled.setExpert(true); - visible.setHidden(true); - - background.setBound(true); - foreground.setBound(true); - font.setBound(true); - focusable.setBound(true); - - PropertyDescriptor[] rv = {name, background, foreground, font, enabled, visible, focusable }; - return rv; - } catch (IntrospectionException e) { - throw new Error(e.toString()); - } - } -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/share/native/sun/awt/medialib/mlib_sys.c --- a/jdk/src/share/native/sun/awt/medialib/mlib_sys.c Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/share/native/sun/awt/medialib/mlib_sys.c Wed Sep 05 11:59:27 2012 -0700 @@ -29,6 +29,8 @@ #ifdef MACOSX #include #include +#else +#include #endif #include #include diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XCheckboxMenuItemPeer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XCheckboxMenuItemPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XCheckboxMenuItemPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -29,27 +29,12 @@ import java.awt.peer.*; import java.awt.event.*; -import java.lang.reflect.Field; -import sun.awt.SunToolkit; +import sun.awt.AWTAccessor; class XCheckboxMenuItemPeer extends XMenuItemPeer implements CheckboxMenuItemPeer { /************************************************ * - * Data members - * - ************************************************/ - - /* - * CheckboxMenuItem's fields - */ - private final static Field f_state; - static { - f_state = SunToolkit.getField(CheckboxMenuItem.class, "state"); - } - - /************************************************ - * * Construction * ************************************************/ @@ -74,16 +59,8 @@ * ************************************************/ boolean getTargetState() { - MenuItem target = getTarget(); - if (target == null) { - return false; - } - try { - return f_state.getBoolean(target); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return false; + return AWTAccessor.getCheckboxMenuItemAccessor() + .getState((CheckboxMenuItem)getTarget()); } /************************************************ diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -29,13 +29,8 @@ import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetListener; import java.awt.event.*; -import java.awt.image.ColorModel; -import java.awt.image.ImageObserver; -import java.awt.image.ImageProducer; -import java.awt.image.VolatileImage; -import java.awt.peer.*; import sun.awt.*; -import java.lang.reflect.*; +import sun.awt.AWTAccessor; import sun.util.logging.PlatformLogger; import java.util.*; import static sun.awt.X11.XEmbedHelper.*; @@ -454,16 +449,8 @@ } } - static Field bdataField; static byte[] getBData(KeyEvent e) { - try { - if (bdataField == null) { - bdataField = SunToolkit.getField(java.awt.AWTEvent.class, "bdata"); - } - return (byte[])bdataField.get(e); - } catch (IllegalAccessException ex) { - return null; - } + return AWTAccessor.getAWTEventAccessor().getBData(e); } void forwardKeyEvent(KeyEvent e) { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbeddingContainer.java Wed Sep 05 11:59:27 2012 -0700 @@ -29,7 +29,7 @@ import java.util.HashMap; import java.awt.event.KeyEvent; import java.lang.reflect.*; -import sun.awt.SunToolkit; +import sun.awt.AWTAccessor; public class XEmbeddingContainer extends XEmbedHelper implements XEventDispatcher { HashMap children = new HashMap(); @@ -127,20 +127,8 @@ } } - static Field bdata; - byte[] getBData(KeyEvent e) { - try { - if (bdata == null) { - bdata = SunToolkit.getField(java.awt.AWTEvent.class, "bdata"); - } - return (byte[])bdata.get(e); - } catch (IllegalAccessException ex) { - return null; - } - } - void forwardKeyEvent(long child, KeyEvent e) { - byte[] bdata = getBData(e); + byte[] bdata = AWTAccessor.getAWTEventAccessor().getBData(e); long data = Native.toData(bdata); if (data == 0) { return; diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java --- a/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XGlobalCursorManager.java Wed Sep 05 11:59:27 2012 -0700 @@ -27,10 +27,7 @@ import java.awt.*; import java.awt.peer.ComponentPeer; -import java.awt.peer.LightweightPeer; import java.lang.ref.WeakReference; -import java.lang.reflect.Field; -import java.lang.reflect.Method; import sun.awt.AWTAccessor; import sun.awt.GlobalCursorManager; @@ -38,23 +35,6 @@ public final class XGlobalCursorManager extends GlobalCursorManager { - private static Field field_pData; - private static Field field_type; - private static Class cursorClass; - private static Method method_setPData; - static { - cursorClass = java.awt.Cursor.class; - field_pData = SunToolkit.getField(cursorClass, "pData"); - field_type = SunToolkit.getField(cursorClass, "type"); - method_setPData = SunToolkit.getMethod(cursorClass, "setPData", new Class[] {long.class}); - if (field_pData == null || field_type == null || method_setPData == null) { - System.out.println("Unable to initialize XGlobalCursorManager: "); - Thread.dumpStack(); - - } - } - - // cached nativeContainer private WeakReference nativeContainer; @@ -213,8 +193,8 @@ long pData = 0; int type = 0; try { - pData = field_pData.getLong(c); - type = field_type.getInt(c); + pData = AWTAccessor.getCursorAccessor().getPData(c); + type = AWTAccessor.getCursorAccessor().getType(c); } catch (Exception e) { @@ -284,7 +264,7 @@ static void setPData(Cursor c, long pData) { try { - method_setPData.invoke(c, pData); + AWTAccessor.getCursorAccessor().setPData(c, pData); } catch (Exception e) { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuBarPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -28,10 +28,9 @@ import java.awt.peer.*; import java.awt.event.*; -import java.lang.reflect.Field; import java.util.Vector; import sun.util.logging.PlatformLogger; -import sun.awt.SunToolkit; +import sun.awt.AWTAccessor; public class XMenuBarPeer extends XBaseMenuWindow implements MenuBarPeer { @@ -67,15 +66,6 @@ private final static int BAR_ITEM_MARGIN_TOP = 2; private final static int BAR_ITEM_MARGIN_BOTTOM = 2; - //fields - private static Field f_helpMenu; - private static Field f_menus; - - static { - f_helpMenu = SunToolkit.getField(MenuBar.class, "helpMenu"); - f_menus = SunToolkit.getField(MenuBar.class, "menus"); - } - /************************************************ * * Mapping data @@ -204,16 +194,12 @@ */ void postInit(XCreateWindowParams params) { super.postInit(params); - Vector targetMenuVector = null; - Menu targetHelpMenu = null; - try { - // Get menus from the target. - targetMenuVector = (Vector)f_menus.get(menuBarTarget); - targetHelpMenu = (Menu)f_helpMenu.get(menuBarTarget); - reloadItems(targetMenuVector); - } catch (IllegalAccessException iae) { - iae.printStackTrace(); - } + // Get menus from the target. + Vector targetMenuVector = AWTAccessor.getMenuBarAccessor() + .getMenus(menuBarTarget); + Menu targetHelpMenu = AWTAccessor.getMenuBarAccessor() + .getHelpMenu(menuBarTarget); + reloadItems(targetMenuVector); if (targetHelpMenu != null) { addHelpMenu(targetHelpMenu); } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuItemPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -28,10 +28,7 @@ import java.awt.peer.*; import java.awt.event.*; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; -import sun.awt.SunToolkit; +import sun.awt.AWTAccessor; public class XMenuItemPeer implements MenuItemPeer { @@ -81,24 +78,6 @@ private final static int SEPARATOR_WIDTH = 20; private final static int SEPARATOR_HEIGHT = 5; - /* - * MenuItem's fields & methods - */ - private final static Field f_enabled; - private final static Field f_label; - private final static Field f_shortcut; - private final static Method m_getFont; - private final static Method m_isItemEnabled; - private final static Method m_getActionCommand; - static { - f_enabled = SunToolkit.getField(MenuItem.class, "enabled"); - f_label = SunToolkit.getField(MenuItem.class, "label"); - f_shortcut = SunToolkit.getField(MenuItem.class, "shortcut"); - - m_getFont = SunToolkit.getMethod(MenuComponent.class, "getFont_NoClientCode", null); - m_getActionCommand = SunToolkit.getMethod(MenuItem.class, "getActionCommandImpl", null); - m_isItemEnabled = SunToolkit.getMethod(MenuItem.class, "isItemEnabled", null); - } /************************************************ * * Text Metrics @@ -216,39 +195,22 @@ if (target == null) { return XWindow.getDefaultFont(); } - try { - return (Font)m_getFont.invoke(target, new Object[0]); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - return XWindow.getDefaultFont(); + return AWTAccessor.getMenuComponentAccessor().getFont_NoClientCode(target); } String getTargetLabel() { if (target == null) { return ""; } - try { - String label = (String)f_label.get(target); - return (label == null) ? "" : label; - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return ""; + String label = AWTAccessor.getMenuItemAccessor().getLabel(target); + return (label == null) ? "" : label; } boolean isTargetEnabled() { if (target == null) { return false; } - try { - return f_enabled.getBoolean(target); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return false; + return AWTAccessor.getMenuItemAccessor().isEnabled(target); } /** @@ -260,40 +222,21 @@ if (target == null) { return false; } - try { - return ((Boolean)m_isItemEnabled.invoke(target, new Object[0])).booleanValue(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - return false; + return AWTAccessor.getMenuItemAccessor().isItemEnabled(target); } String getTargetActionCommand() { if (target == null) { return ""; } - try { - return (String) m_getActionCommand.invoke(target,(Object[]) null); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - return ""; + return AWTAccessor.getMenuItemAccessor().getActionCommandImpl(target); } MenuShortcut getTargetShortcut() { if (target == null) { return null; } - try { - return (MenuShortcut)f_shortcut.get(target); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return null; + return AWTAccessor.getMenuItemAccessor().getShortcut(target); } String getShortcutText() { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XMenuPeer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XMenuPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XMenuPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -27,10 +27,9 @@ import java.awt.*; import java.awt.peer.*; -import java.lang.reflect.Field; import java.util.Vector; import sun.util.logging.PlatformLogger; -import sun.awt.SunToolkit; +import sun.awt.AWTAccessor; public class XMenuPeer extends XMenuItemPeer implements MenuPeer { @@ -46,16 +45,6 @@ */ XMenuWindow menuWindow; - - /* - * Menu's fields & methods - */ - private final static Field f_items; - - static { - f_items = SunToolkit.getField(Menu.class, "items"); - } - /************************************************ * * Construction @@ -153,12 +142,7 @@ * ************************************************/ Vector getTargetItems() { - try { - return (Vector)f_items.get(getTarget()); - } catch (IllegalAccessException iae) { - iae.printStackTrace(); - return null; - } + return AWTAccessor.getMenuAccessor().getItems((Menu)getTarget()); } /************************************************ diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XPopupMenuPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -28,15 +28,10 @@ import java.awt.peer.*; import java.awt.event.*; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; - import java.util.Vector; +import sun.awt.AWTAccessor; import sun.util.logging.PlatformLogger; -import sun.awt.SunToolkit; - public class XPopupMenuPeer extends XMenuWindow implements PopupMenuPeer { /************************************************ @@ -66,24 +61,6 @@ private final static int CAPTION_MARGIN_TOP = 4; private final static int CAPTION_SEPARATOR_HEIGHT = 6; - /* - * Menu's fields & methods - */ - //Fix for 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false) - private final static Field f_enabled; - //Fix for 6267144: PIT: Popup menu label is not shown, XToolkit - private final static Field f_label; - private final static Method m_getFont; - private final static Field f_items; - - static { - f_enabled = SunToolkit.getField(MenuItem.class, "enabled"); - f_label = SunToolkit.getField(MenuItem.class, "label"); - f_items = SunToolkit.getField(Menu.class, "items"); - m_getFont = SunToolkit.getMethod(MenuComponent.class, "getFont_NoClientCode", null); - } - - /************************************************ * * Construction @@ -96,7 +73,7 @@ /************************************************ * - * Implementaion of interface methods + * Implementation of interface methods * ************************************************/ /* @@ -189,27 +166,16 @@ if (popupMenuTarget == null) { return XWindow.getDefaultFont(); } - try { - return (Font)m_getFont.invoke(popupMenuTarget, new Object[0]); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - return XWindow.getDefaultFont(); + return AWTAccessor.getMenuComponentAccessor() + .getFont_NoClientCode(popupMenuTarget); } + //Fix for 6267144: PIT: Popup menu label is not shown, XToolkit String getTargetLabel() { if (target == null) { return ""; } - try { - String label = (String)f_label.get(popupMenuTarget); - return (label == null) ? "" : label; - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return ""; + return AWTAccessor.getMenuItemAccessor().getLabel(popupMenuTarget); } //Fix for 6184485: Popup menu is not disabled on XToolkit even when calling setEnabled (false) @@ -217,21 +183,14 @@ if (popupMenuTarget == null) { return false; } - try { - return f_enabled.getBoolean(popupMenuTarget); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return false; + return AWTAccessor.getMenuItemAccessor().isEnabled(popupMenuTarget); } Vector getMenuTargetItems() { - try { - return (Vector)f_items.get(popupMenuTarget); - } catch (IllegalAccessException iae) { - iae.printStackTrace(); + if (popupMenuTarget == null) { return null; } + return AWTAccessor.getMenuAccessor().getItems(popupMenuTarget); } /************************************************ diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XScrollPanePeer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XScrollPanePeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XScrollPanePeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -31,7 +31,6 @@ import java.lang.reflect.*; import sun.awt.AWTAccessor; -import sun.awt.SunToolkit; class XScrollPanePeer extends XComponentPeer implements ScrollPanePeer, XScrollbarClient { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XSystemTrayPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -27,10 +27,9 @@ import java.awt.*; import java.awt.peer.SystemTrayPeer; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; import sun.awt.SunToolkit; import sun.awt.AppContext; +import sun.awt.AWTAccessor; import sun.util.logging.PlatformLogger; public class XSystemTrayPeer implements SystemTrayPeer, XMSelectionListener { @@ -42,11 +41,6 @@ private volatile boolean available; private final XMSelection selection = new XMSelection("_NET_SYSTEM_TRAY"); - private static final Method firePropertyChangeMethod = - XToolkit.getMethod(SystemTray.class, "firePropertyChange", new Class[] {String.class, Object.class, Object.class}); - private static final Method addNotifyMethod = XToolkit.getMethod(TrayIcon.class, "addNotify", null); - private static final Method removeNotifyMethod = XToolkit.getMethod(TrayIcon.class, "removeNotify", null); - private static final int SCREEN = 0; private static final String SYSTEM_TRAY_PROPERTY_NAME = "systemTray"; private static final XAtom _NET_SYSTEM_TRAY = XAtom.get("_NET_SYSTEM_TRAY_S" + SCREEN); @@ -157,44 +151,43 @@ return peerInstance; } - private void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) { + private void firePropertyChange(final String propertyName, + final Object oldValue, + final Object newValue) { Runnable runnable = new Runnable() { public void run() { - Object[] args = new Object[] {propertyName, oldValue, newValue}; - invokeMethod(firePropertyChangeMethod, target, args); + AWTAccessor.getSystemTrayAccessor() + .firePropertyChange(target, propertyName, oldValue, newValue); } }; invokeOnEachAppContext(runnable); } private void createTrayPeers() { - invokeOnEachTrayIcon(addNotifyMethod); - } - - private void removeTrayPeers() { - invokeOnEachTrayIcon(removeNotifyMethod); - } - - private void invokeOnEachTrayIcon(final Method method) { Runnable runnable = new Runnable() { public void run() { TrayIcon[] icons = target.getTrayIcons(); - for (TrayIcon ti : icons) { - invokeMethod(method, ti, (Object[]) null); + try { + for (TrayIcon ti : icons) { + AWTAccessor.getTrayIconAccessor().addNotify(ti); + } + } catch (AWTException e) { } } }; invokeOnEachAppContext(runnable); } - private void invokeMethod(Method method, Object obj, Object[] args) { - try{ - method.invoke(obj, args); - } catch (InvocationTargetException e){ - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } + private void removeTrayPeers() { + Runnable runnable = new Runnable() { + public void run() { + TrayIcon[] icons = target.getTrayIcons(); + for (TrayIcon ti : icons) { + AWTAccessor.getTrayIconAccessor().removeNotify(ti); + } + } + }; + invokeOnEachAppContext(runnable); } private void invokeOnEachAppContext(Runnable runnable) { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -1008,8 +1008,10 @@ // loading SystemFlavorMap and associated classes. public void setTransferHandler(TransferHandler newHandler) { TransferHandler oldHandler = (TransferHandler) - getClientProperty(XTextTransferHelper.getTransferHandlerKey()); - putClientProperty(XTextTransferHelper.getTransferHandlerKey(), + getClientProperty(AWTAccessor.getClientPropertyKeyAccessor() + .getJComponent_TRANSFER_HANDLER()); + putClientProperty(AWTAccessor.getClientPropertyKeyAccessor() + .getJComponent_TRANSFER_HANDLER(), newHandler); firePropertyChange("transferHandler", oldHandler, newHandler); diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XTextFieldPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -691,8 +691,10 @@ // loading SystemFlavorMap and associated classes. public void setTransferHandler(TransferHandler newHandler) { TransferHandler oldHandler = (TransferHandler) - getClientProperty(XTextTransferHelper.getTransferHandlerKey()); - putClientProperty(XTextTransferHelper.getTransferHandlerKey(), + getClientProperty(AWTAccessor.getClientPropertyKeyAccessor() + .getJComponent_TRANSFER_HANDLER()); + putClientProperty(AWTAccessor.getClientPropertyKeyAccessor() + .getJComponent_TRANSFER_HANDLER(), newHandler); firePropertyChange("transferHandler", oldHandler, newHandler); diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XTextTransferHelper.java --- a/jdk/src/solaris/classes/sun/awt/X11/XTextTransferHelper.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2003, 2007, 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 sun.awt.X11; - -import java.lang.reflect.Field; -import sun.awt.SunToolkit; - -class XTextTransferHelper { - private static Object transferHandlerKey = null; - static Object getTransferHandlerKey() { - if (transferHandlerKey == null) { - try { - Class clazz = Class.forName("javax.swing.ClientPropertyKey"); - Field field = SunToolkit.getField(clazz, "JComponent_TRANSFER_HANDLER"); - transferHandlerKey = field.get(null); - } catch (IllegalAccessException ex) { - return null; - } catch (ClassNotFoundException cnfe) { - cnfe.printStackTrace(); - } - } - return transferHandlerKey; - } -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XToolkit.java --- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Wed Sep 05 11:59:27 2012 -0700 @@ -41,8 +41,6 @@ import java.awt.image.ColorModel; import java.awt.peer.*; import java.beans.PropertyChangeListener; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.*; @@ -50,10 +48,10 @@ import javax.swing.UIDefaults; import sun.awt.*; import sun.font.FontConfigManager; -import sun.font.FontManager; import sun.java2d.SunGraphicsEnvironment; import sun.misc.PerformanceLogger; import sun.print.PrintJob2D; +import sun.security.action.GetPropertyAction; import sun.security.action.GetBooleanAction; import sun.util.logging.PlatformLogger; @@ -113,7 +111,6 @@ private static volatile int screenWidth = -1, screenHeight = -1; // Dimensions of default screen static long awt_defaultFg; // Pixel private static XMouseInfoPeer xPeer; - private static Method m_removeSourceEvents; static { initSecurityWarning(); @@ -131,8 +128,6 @@ initIDs(); setBackingStoreType(); } - m_removeSourceEvents = SunToolkit.getMethod(EventQueue.class, "removeSourceEvents", new Class[] {Object.class, Boolean.TYPE}) ; - noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler")); } @@ -223,7 +218,8 @@ static void initSecurityWarning() { // Enable warning only for internal builds - String runtime = getSystemProperty("java.runtime.version"); + String runtime = AccessController.doPrivileged( + new GetPropertyAction("java.runtime.version")); securityWarningEnabled = (runtime != null && runtime.contains("internal")); } @@ -1101,8 +1097,8 @@ */ public synchronized static boolean getSunAwtDisableGtkFileDialogs() { if (sunAwtDisableGtkFileDialogs == null) { - sunAwtDisableGtkFileDialogs = - getBooleanSystemProperty("sun.awt.disableGtkFileDialogs"); + sunAwtDisableGtkFileDialogs = AccessController.doPrivileged( + new GetBooleanAction("sun.awt.disableGtkFileDialogs")); } return sunAwtDisableGtkFileDialogs.booleanValue(); } @@ -2090,17 +2086,11 @@ return null; } - static void removeSourceEvents(EventQueue queue, Object source, boolean removeAllEvents) { - try { - m_removeSourceEvents.invoke(queue, source, removeAllEvents); - } - catch (IllegalAccessException e) - { - e.printStackTrace(); - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } + static void removeSourceEvents(EventQueue queue, + Object source, + boolean removeAllEvents) { + AWTAccessor.getEventQueueAccessor() + .removeSourceEvents(queue, source, removeAllEvents); } public boolean isAlwaysOnTopSupported() { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XWindow.java --- a/jdk/src/solaris/classes/sun/awt/X11/XWindow.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XWindow.java Wed Sep 05 11:59:27 2012 -0700 @@ -126,10 +126,6 @@ native void getWindowBounds(long window, long x, long y, long width, long height); private native static void initIDs(); - private static Field isPostedField; - private static Field rawCodeField; - private static Field primaryLevelUnicodeField; - private static Field extendedKeyCodeField; static { initIDs(); } @@ -398,20 +394,11 @@ static Method m_sendMessage; static void sendEvent(final AWTEvent e) { - if (isPostedField == null) { - isPostedField = SunToolkit.getField(AWTEvent.class, "isPosted"); - } // The uses of this method imply that the incoming event is system-generated SunToolkit.setSystemGenerated(e); PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() { public void run() { - try { - isPostedField.setBoolean(e, true); - } catch (IllegalArgumentException e) { - assert(false); - } catch (IllegalAccessException e) { - assert(false); - } + AWTAccessor.getAWTEventAccessor().setPosted(e); ((Component)e.getSource()).dispatchEvent(e); } }, PeerEvent.ULTIMATE_PRIORITY_EVENT); @@ -1428,16 +1415,8 @@ } - static Field bdata; static void setBData(KeyEvent e, byte[] data) { - try { - if (bdata == null) { - bdata = SunToolkit.getField(java.awt.AWTEvent.class, "bdata"); - } - bdata.set(e, data); - } catch (IllegalAccessException ex) { - assert false; - } + AWTAccessor.getAWTEventAccessor().setBData(e, data); } public void postKeyEvent(int id, long when, int keyCode, int keyChar, @@ -1447,15 +1426,6 @@ { long jWhen = XToolkit.nowMillisUTC_offset(when); int modifiers = getModifiers(state, 0, keyCode); - if (rawCodeField == null) { - rawCodeField = XToolkit.getField(KeyEvent.class, "rawCode"); - } - if (primaryLevelUnicodeField == null) { - primaryLevelUnicodeField = XToolkit.getField(KeyEvent.class, "primaryLevelUnicode"); - } - if (extendedKeyCodeField == null) { - extendedKeyCodeField = XToolkit.getField(KeyEvent.class, "extendedKeyCode"); - } KeyEvent ke = new KeyEvent((Component)getEventSource(), id, jWhen, modifiers, keyCode, (char)keyChar, keyLocation); @@ -1463,15 +1433,11 @@ byte[] data = Native.toBytes(event, eventSize); setBData(ke, data); } - try { - rawCodeField.set(ke, rawCode); - primaryLevelUnicodeField.set(ke, (long)unicodeFromPrimaryKeysym); - extendedKeyCodeField.set(ke, (long)extendedKeyCode); - } catch (IllegalArgumentException e) { - assert(false); - } catch (IllegalAccessException e) { - assert(false); - } + + AWTAccessor.KeyEventAccessor kea = AWTAccessor.getKeyEventAccessor(); + kea.setRawCode(ke, rawCode); + kea.setPrimaryLevelUnicode(ke, (long)unicodeFromPrimaryKeysym); + kea.setExtendedKeyCode(ke, (long)extendedKeyCode); postEventToEventQueue(ke); } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java --- a/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java Wed Sep 05 11:59:27 2012 -0700 @@ -27,6 +27,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; +import sun.security.action.GetPropertyAction; import sun.misc.*; final public class XlibWrapper @@ -590,12 +591,8 @@ static final boolean isBuildInternal; static { - String dataModelProp = (String)AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - return System.getProperty("sun.arch.data.model"); - } - }); + String dataModelProp = AccessController.doPrivileged( + new GetPropertyAction("sun.arch.data.model")); try { dataModel = Integer.parseInt(dataModelProp); } catch (Exception e) { @@ -647,7 +644,8 @@ } private static boolean getBuildInternal() { - String javaVersion = XToolkit.getSystemProperty("java.version"); + String javaVersion = AccessController.doPrivileged( + new GetPropertyAction("java.version")); return javaVersion != null && javaVersion.contains("internal"); } diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/windows/classes/sun/awt/windows/WCanvasPeer.java --- a/jdk/src/windows/classes/sun/awt/windows/WCanvasPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/windows/classes/sun/awt/windows/WCanvasPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -27,7 +27,6 @@ import java.awt.*; import java.awt.peer.*; import java.lang.ref.WeakReference; -import java.lang.reflect.Method; import sun.awt.SunToolkit; import sun.awt.Win32GraphicsDevice; import sun.awt.PaintEventDispatcher; diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/windows/classes/sun/awt/windows/WMouseDragGestureRecognizer.java --- a/jdk/src/windows/classes/sun/awt/windows/WMouseDragGestureRecognizer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/windows/classes/sun/awt/windows/WMouseDragGestureRecognizer.java Wed Sep 05 11:59:27 2012 -0700 @@ -39,8 +39,6 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; -import java.lang.reflect.*; - import sun.awt.dnd.SunDragSourceContextPeer; /** diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/windows/classes/sun/awt/windows/WPopupMenuPeer.java --- a/jdk/src/windows/classes/sun/awt/windows/WPopupMenuPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/windows/classes/sun/awt/windows/WPopupMenuPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -26,9 +26,7 @@ import java.awt.*; import java.awt.peer.*; -import java.lang.reflect.Field; -import sun.awt.SunToolkit; import sun.awt.AWTAccessor; public class WPopupMenuPeer extends WMenuPeer implements PopupMenuPeer { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java --- a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java Wed Sep 05 11:59:27 2012 -0700 @@ -31,8 +31,6 @@ import java.beans.*; -import java.lang.reflect.*; - import java.util.*; import java.util.List; import sun.util.logging.PlatformLogger; diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/test/java/awt/Frame/HugeFrame/HugeFrame.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/Frame/HugeFrame/HugeFrame.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,49 @@ +/* + * 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. + * + * 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. + */ + +/* + @test + @bug 7160609 + @summary A window with huge dimensions shouldn't crash JVM + @author anthony.petrov@oracle.com: area=awt.toplevel + @run main HugeFrame +*/ + +import java.awt.*; + +public class HugeFrame { + public static void main(String[] args) throws Exception { + Frame f = new Frame("Huge"); + + // 8193+ should already produce a crash, but let's go extreme... + f.setBounds(10, 10, 30000, 500000); + f.setVisible(true); + + // We would crash by now if the bug wasn't fixed + Thread.sleep(1000); + System.err.println(f.getBounds()); + + // Cleanup + f.dispose(); + } +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/test/java/beans/Introspector/4520754/Test4520754.java --- a/jdk/test/java/beans/Introspector/4520754/Test4520754.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/test/java/beans/Introspector/4520754/Test4520754.java Wed Sep 05 11:59:27 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, 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 @@ -58,7 +58,7 @@ public static void main(String[] args) { // ensure that 4168475 does not regress test4168475(Component.class); - // AWT classes (sun.beans.infos.ComponentBeanInfo) + // AWT classes (com.sun.beans.infos.ComponentBeanInfo) test(null, Button.class, Component.class, List.class, Menu.class, Panel.class); // Swing classes (dt.jar) test(null, JApplet.class, JButton.class, JCheckBox.class); diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/test/java/beans/Introspector/Test7189112.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/beans/Introspector/Test7189112.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,64 @@ +/* + * 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. + * + * 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. + */ + +/* + * @test + * @bug 7189112 + * @summary Tests overridden getter + * @author Sergey Malenkov + */ + +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; + +public class Test7189112 { + + public static void main(String[] args) throws IntrospectionException { + for (PropertyDescriptor pd : Introspector.getBeanInfo(MyBean.class).getPropertyDescriptors()) { + if (pd.getName().equals("value") && (null == pd.getWriteMethod())) { + throw new Error("The property setter is not found"); + } + } + } + + public static class BaseBean { + + private Object value; + + public Object getValue() { + return this.value; + } + + public void setValue(Object value) { + this.value = value; + } + } + + public static class MyBean extends BaseBean { + @Override + public String getValue() { + return (String) super.getValue(); + } + } +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java --- a/jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java Wed Sep 05 11:59:27 2012 -0700 @@ -1,5 +1,5 @@ /** - * 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 @@ -26,6 +26,8 @@ * @bug 6380849 * @summary Tests PropertyEditor finder * @author Sergey Malenkov + * @compile -XDignore.symbol.file TestPropertyEditor.java + * @run main TestPropertyEditor */ import editors.SecondBeanEditor; @@ -36,17 +38,17 @@ import java.beans.PropertyEditor; import java.beans.PropertyEditorManager; -import sun.beans.editors.BooleanEditor; -import sun.beans.editors.ByteEditor; -import sun.beans.editors.ColorEditor; -import sun.beans.editors.DoubleEditor; -import sun.beans.editors.EnumEditor; -import sun.beans.editors.FloatEditor; -import sun.beans.editors.FontEditor; -import sun.beans.editors.IntegerEditor; -import sun.beans.editors.LongEditor; -import sun.beans.editors.ShortEditor; -import sun.beans.editors.StringEditor; +import com.sun.beans.editors.BooleanEditor; +import com.sun.beans.editors.ByteEditor; +import com.sun.beans.editors.ColorEditor; +import com.sun.beans.editors.DoubleEditor; +import com.sun.beans.editors.EnumEditor; +import com.sun.beans.editors.FloatEditor; +import com.sun.beans.editors.FontEditor; +import com.sun.beans.editors.IntegerEditor; +import com.sun.beans.editors.LongEditor; +import com.sun.beans.editors.ShortEditor; +import com.sun.beans.editors.StringEditor; public class TestPropertyEditor implements Runnable { diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/test/java/beans/PropertyEditor/Test6963811.java --- a/jdk/test/java/beans/PropertyEditor/Test6963811.java Wed Sep 05 10:26:54 2012 -0700 +++ b/jdk/test/java/beans/PropertyEditor/Test6963811.java Wed Sep 05 11:59:27 2012 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -26,10 +26,12 @@ * @bug 6963811 * @summary Tests deadlock in PropertyEditorManager * @author Sergey Malenkov + * @compile -XDignore.symbol.file Test6963811.java + * @run main Test6963811 */ import java.beans.PropertyEditorManager; -import sun.beans.editors.StringEditor; +import com.sun.beans.editors.StringEditor; public class Test6963811 implements Runnable { private final long time; diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/test/javax/swing/JColorChooser/Test4380468.html --- a/jdk/test/javax/swing/JColorChooser/Test4380468.html Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ - - -1. Click the HSB tab at the ColorChooser. -2. Click in the lower left corner of the gradient palette - in order to select a color such that all three RGB values - are single digit colors (such as 0, 0, 0 or 5, 3, 1). -3. Click another tab, then click back to the HSB tab. -4. Now click the lighter colors that should have - 2 and 3 digit RGB values (in the upper right corner). - -If all digits of each RGB value are shown then test passes. -If only the last digit of their values are shown then test fails. - - - - - diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/test/javax/swing/JColorChooser/Test4380468.java --- a/jdk/test/javax/swing/JColorChooser/Test4380468.java Wed Sep 05 10:26:54 2012 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2000, 2008, 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. - * - * 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. - */ - -/* - * @test - * @bug 4380468 - * @summary JColorChooser's HSB panel should display all RGB digits - * @author Andrey Pikalev - * @run applet/manual=yesno Test4380468.html - */ - -import java.awt.Color; -import javax.swing.JApplet; -import javax.swing.JColorChooser; - -public class Test4380468 extends JApplet { - public void init() { - add(new JColorChooser(Color.GREEN)); - } -} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/test/javax/swing/JSplitPane/4201995/bug4201995.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JSplitPane/4201995/bug4201995.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,47 @@ +/* + * 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. + * + * 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. + */ + +/* + * @test + * @bug 4201995 + * @summary Tests that JSplitPane is opaque + * @author Scott Violet + */ + +import javax.swing.*; + +public class bug4201995 { + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + boolean expectedOpaqueValue = !"Nimbus".equals(UIManager.getLookAndFeel().getName()); + JSplitPane sp = new JSplitPane(); + + if (sp.isOpaque() != expectedOpaqueValue) { + throw new RuntimeException("JSplitPane has incorrect default opaque value"); + } + } + }); + } +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/test/javax/swing/JTable/4235420/bug4235420.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JTable/4235420/bug4235420.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,87 @@ +/* + * 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. + * + * 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. + */ + +/* @test + @bug 4235420 + @summary Tests that JTable delays creating Renderers and Editors + @author Peter Zhelezniakov +*/ + +import javax.swing.*; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +public class bug4235420 { + + public static void main(String[] argv) throws Exception { + if ("Nimbus".equals(UIManager.getLookAndFeel().getName())) { + System.out.println("The test is skipped for Nimbus"); + + return; + } + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + Table table = new Table(); + + table.test(); + } + }); + } + + private static class Table extends JTable { + public void test() { + // Renderers + Class[] rendererClasses = {Object.class, Number.class, Date.class, ImageIcon.class, Boolean.class}; + + Map copy = new HashMap(defaultRenderersByColumnClass); + + for (Class rendererClass : rendererClasses) { + Object obj = copy.get(rendererClass); + + if (obj instanceof TableCellRenderer) { + throw new Error("Failed: TableCellRenderer created for " + + rendererClass.getClass().getName()); + } + } + + // Editors + Class[] editorClasses = {Object.class, Number.class, Boolean.class}; + + copy = new HashMap(defaultEditorsByColumnClass); + + for (Class editorClass : editorClasses) { + Object obj = copy.get(editorClass); + + if (obj instanceof TableCellEditor) { + throw new Error("Failed: TableCellEditor created for " + + editorClass.getClass().getName()); + } + } + } + } +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/test/javax/swing/JTable/7188612/JTableAccessibleGetLocationOnScreen.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JTable/7188612/JTableAccessibleGetLocationOnScreen.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,106 @@ +/* + * 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. + * + * 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. + */ + +/* + * Portions Copyright (c) 2012 IBM Corporation + */ + +/* @test + * @bug 7188612 + * @summary AccessibleTableHeader and AccessibleJTableCell should stick to + * AccessibleComponent.getLocationOnScreen api. + * @author Frank Ding + */ + +import javax.accessibility.AccessibleComponent; +import javax.accessibility.AccessibleTable; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.SwingUtilities; + +public class JTableAccessibleGetLocationOnScreen { + private static JFrame frame; + private static JTable table; + + public static void main(String[] args) throws Exception { + + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + constructInEDT(); + try { + assertGetLocation(); + } finally { + frame.dispose(); + } + } + }); + + } + + private static void constructInEDT() { + String[] columnNames = { "col1", "col2", }; + Object[][] data = { { "row1, col1", "row1, col2" }, + { "row2, col1", "row2, col2" }, }; + + frame = new JFrame( + "JTable AccessibleTableHeader and AccessibleJTableCell test"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + table = new JTable(data, columnNames); + frame.add(table); + frame.pack(); + } + + private static void assertGetLocation() { + // the frame is now invisible + // test getLocationOnScreen() of + // JTable$AccessibleJTable$AccessibleJTableHeaderCell + // and JTable$AccessibleJTable$AccessibleJTableCell + AccessibleTable accessibleTable = (AccessibleTable) table + .getAccessibleContext(); + AccessibleTable header = accessibleTable.getAccessibleColumnHeader(); + AccessibleComponent accessibleComp1 = (AccessibleComponent) header + .getAccessibleAt(0, 0); + // getLocation() must be null according to its javadoc and no exception + // is thrown + if (null != accessibleComp1.getLocationOnScreen()) { + throw new RuntimeException( + "JTable$AccessibleJTable$AccessibleJTableHeaderCell." + + "getLocation() must be null"); + } + + JComponent.AccessibleJComponent accessibleJComponent = + (JComponent.AccessibleJComponent) table.getAccessibleContext(); + AccessibleComponent accessibleComp2 = (AccessibleComponent) + accessibleJComponent.getAccessibleChild(3); + // getLocation() must be null according to its javadoc and no exception + // is thrown + if (null != accessibleComp2.getLocationOnScreen()) { + throw new RuntimeException("JTable$AccessibleJTable$" + + "AccessibleJTableCell.getLocation() must be null"); + } + + } +} diff -r 3d6ac85b33be -r c1b9cf3dd7be jdk/test/tools/launcher/RunpathTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/tools/launcher/RunpathTest.java Wed Sep 05 11:59:27 2012 -0700 @@ -0,0 +1,84 @@ +/* + * 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. + * + * 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. + */ + +/* + * @test + * @bug 7190813 + * @summary Check for extended RPATHs on *nixes + * @compile -XDignore.symbol.file RunpathTest.java + * @run main RunpathTest + * @author ksrini + */ + +import java.io.File; + +public class RunpathTest extends TestHelper { + + final String elfreaderCmd; + RunpathTest() { + elfreaderCmd = findElfReader(); + } + + final String findElfReader() { + String[] paths = {"/bin", "/sbin", "/usr/bin", "/usr/sbin", "/usr/ccs/bin"}; + final String cmd = isSolaris ? "elfdump" : "readelf"; + for (String x : paths) { + File p = new File(x); + File e = new File(p, cmd); + if (e.canExecute()) { + return e.getAbsolutePath(); + } + } + System.err.println("Warning: no suitable elf reader!"); + return null; + } + + void elfCheck(String javacmd, String expectedRpath) { + final TestResult tr = doExec(elfreaderCmd, "-d", javacmd); + if (!tr.matches(expectedRpath)) { + System.out.println(tr); + throw new RuntimeException("FAILED: RPATH strings " + + expectedRpath + " not found in " + javaCmd); + } + System.out.println(javacmd + " contains expected RPATHS"); + } + + void testRpath() { + if (isDualMode && is64Bit) { + String expectedRpath = ".*RPATH.*\\$ORIGIN/../../lib/" + getJreArch() + + ":\\$ORIGIN/../../jre/lib/" + getJreArch() + ".*"; + elfCheck(java64Cmd, expectedRpath); + } else { + String expectedRpath = ".*RPATH.*\\$ORIGIN/../lib/" + getJreArch() + + ":\\$ORIGIN/../jre/lib/" + getJreArch() + ".*"; + elfCheck(javaCmd, expectedRpath); + } + } + + public static void main(String... args) throws Exception { + if (isSolaris || isLinux) { + RunpathTest rp = new RunpathTest(); + rp.testRpath(); + } + } +}