# HG changeset patch # User andrew # Date 1346243098 -3600 # Node ID 5a2688a731845a10cad70e942fddc76951143f65 # Parent db7b5a2b5b11761d63f312c2a9df4d83d61c7998# Parent 1c3a91a1dabdcd7e4407f9e7be08718339eafaad Merge jdk7u8-b04 diff -r db7b5a2b5b11 -r 5a2688a73184 .hgtags --- a/.hgtags Wed Aug 29 12:57:49 2012 +0100 +++ b/.hgtags Wed Aug 29 13:24:58 2012 +0100 @@ -201,4 +201,10 @@ 4a6917092af80481c1fa5b9ec8ccae75411bb72c jdk7u6-b18 a263f787ced5bc7c14078ae552c82de6bd011611 jdk7u6-b19 09145b546a2b6ae1f44d5c8a7d2a37d48e4b39e2 jdk7u6-b20 +243717d7fe9589148951ffb5551264af0e446314 jdk7u6-b21 +d78f2b600d393f45d6ace8ca0f29ad677624a775 jdk7u6-b22 +0ae89e53f5300da1961984a7d81c220c7cf717d7 jdk7u6-b23 df945ef30444adf08f3ef14b0c49c8bda6dda587 jdk7u8-b01 +dd1e513c05b8b8c8402e9ecf9c0d5bdbebb1a089 jdk7u8-b02 +355cf1937d0824b54ac38ee5a5496197647840f9 jdk7u8-b03 +d099fc840e6c0f07e7b6f52d11fae98ae217bc9a jdk7u8-b04 diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/com/apple/laf/AquaPanelUI.java --- a/src/macosx/classes/com/apple/laf/AquaPanelUI.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/com/apple/laf/AquaPanelUI.java Wed Aug 29 13:24:58 2012 +0100 @@ -32,10 +32,20 @@ import com.apple.laf.AquaUtils.RecyclableSingleton; import com.apple.laf.AquaUtils.RecyclableSingletonFromDefaultConstructor; +import java.awt.Graphics; + public class AquaPanelUI extends BasicPanelUI { static RecyclableSingleton instance = new RecyclableSingletonFromDefaultConstructor(AquaPanelUI.class); public static ComponentUI createUI(final JComponent c) { return instance.get(); } + + @Override + public final void update(final Graphics g, final JComponent c) { + if (c.isOpaque()) { + AquaUtils.fillRect(g, c); + } + paint(g, c); + } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/com/apple/laf/AquaRootPaneUI.java --- a/src/macosx/classes/com/apple/laf/AquaRootPaneUI.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/com/apple/laf/AquaRootPaneUI.java Wed Aug 29 13:24:58 2012 +0100 @@ -319,4 +319,12 @@ updateComponentTreeUIActivation(element, active); } } + + @Override + public final void update(final Graphics g, final JComponent c) { + if (c.isOpaque()) { + AquaUtils.fillRect(g, c); + } + paint(g, c); + } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/com/apple/laf/AquaToolBarUI.java --- a/src/macosx/classes/com/apple/laf/AquaToolBarUI.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/com/apple/laf/AquaToolBarUI.java Wed Aug 29 13:24:58 2012 +0100 @@ -73,9 +73,7 @@ g.translate(x, y); if (c.isOpaque()) { - final Color background = c.getBackground(); - g.setColor(background); - g.fillRect(0, 0, w - 1, h - 1); + AquaUtils.fillRect(g, c, c.getBackground(), 0, 0, w - 1, h - 1); } final Color oldColor = g.getColor(); @@ -137,4 +135,12 @@ return true; } } + + @Override + public final void update(final Graphics g, final JComponent c) { + if (c.isOpaque()) { + AquaUtils.fillRect(g, c); + } + paint(g, c); + } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/com/apple/laf/AquaUtils.java --- a/src/macosx/classes/com/apple/laf/AquaUtils.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/com/apple/laf/AquaUtils.java Wed Aug 29 13:24:58 2012 +0100 @@ -28,18 +28,19 @@ import java.awt.*; import java.awt.image.*; import java.lang.ref.SoftReference; -import java.lang.ref.WeakReference; import java.lang.reflect.Method; import java.security.PrivilegedAction; import java.util.*; import javax.swing.*; import javax.swing.border.Border; +import javax.swing.plaf.UIResource; import sun.awt.AppContext; import sun.lwawt.macosx.CImage; import sun.lwawt.macosx.CImage.Creator; +import sun.lwawt.macosx.CPlatformWindow; import sun.swing.SwingUtilities2; import com.apple.laf.AquaImageFactory.SlicedImageControl; @@ -389,4 +390,51 @@ return false; } } + + protected static boolean isWindowTextured(final Component c) { + if (!(c instanceof JComponent)) { + return false; + } + final JRootPane pane = ((JComponent) c).getRootPane(); + if (pane == null) { + return false; + } + Object prop = pane.getClientProperty( + CPlatformWindow.WINDOW_BRUSH_METAL_LOOK); + if (prop != null) { + return Boolean.parseBoolean(prop.toString()); + } + prop = pane.getClientProperty(CPlatformWindow.WINDOW_STYLE); + return prop != null && "textured".equals(prop); + } + + private static Color resetAlpha(final Color color) { + return new Color(color.getRed(), color.getGreen(), color.getBlue(), 0); + } + + protected static void fillRect(final Graphics g, final Component c) { + fillRect(g, c, c.getBackground(), 0, 0, c.getWidth(), c.getHeight()); + } + + protected static void fillRect(final Graphics g, final Component c, + final Color color, final int x, final int y, + final int w, final int h) { + if (!(g instanceof Graphics2D)) { + return; + } + final Graphics2D cg = (Graphics2D) g.create(); + try { + if (color instanceof UIResource && isWindowTextured(c) + && color.equals(SystemColor.window)) { + cg.setComposite(AlphaComposite.Src); + cg.setColor(resetAlpha(color)); + } else { + cg.setColor(color); + } + cg.fillRect(x, y, w, h); + } finally { + cg.dispose(); + } + } } + diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/awt/CGraphicsDevice.java --- a/src/macosx/classes/sun/awt/CGraphicsDevice.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/awt/CGraphicsDevice.java Wed Aug 29 13:24:58 2012 +0100 @@ -48,6 +48,9 @@ private static AWTPermission fullScreenExclusivePermission; + // Save/restore DisplayMode for the Full Screen mode + private DisplayMode originalMode; + public CGraphicsDevice(int displayID) { this.displayID = displayID; configs = new GraphicsConfiguration[] { @@ -124,18 +127,22 @@ } boolean fsSupported = isFullScreenSupported(); + if (fsSupported && old != null) { // enter windowed mode (and restore original display mode) exitFullScreenExclusive(old); - - // TODO: restore display mode + if (originalMode != null) { + setDisplayMode(originalMode); + originalMode = null; + } } super.setFullScreenWindow(w); if (fsSupported && w != null) { - // TODO: save current display mode - + if (isDisplayChangeSupported()) { + originalMode = getDisplayMode(); + } // enter fullscreen mode enterFullScreenExclusive(w); } diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/java2d/opengl/CGLLayer.java --- a/src/macosx/classes/sun/java2d/opengl/CGLLayer.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/java2d/opengl/CGLLayer.java Wed Aug 29 13:24:58 2012 +0100 @@ -68,11 +68,12 @@ } public boolean isOpaque() { - return peer.isOpaque(); + return !peer.isTranslucent(); } public int getTransparency() { - return (peer.isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT); + return peer.isTranslucent() ? Transparency.TRANSLUCENT : + Transparency.OPAQUE; } public Object getDestination() { diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/LWComponentPeer.java --- a/src/macosx/classes/sun/lwawt/LWComponentPeer.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/LWComponentPeer.java Wed Aug 29 13:24:58 2012 +0100 @@ -424,8 +424,7 @@ @Override public final Graphics getGraphics() { - Graphics g = getWindowPeerOrSelf().isOpaque() ? getOnscreenGraphics() - : getOffscreenGraphics(); + final Graphics g = getOnscreenGraphics(); if (g != null) { synchronized (getPeerTreeLock()){ applyConstrain(g); @@ -443,13 +442,7 @@ final LWWindowPeer wp = getWindowPeerOrSelf(); return wp.getOnscreenGraphics(getForeground(), getBackground(), getFont()); - } - public final Graphics getOffscreenGraphics() { - final LWWindowPeer wp = getWindowPeerOrSelf(); - - return wp.getOffscreenGraphics(getForeground(), getBackground(), - getFont()); } private void applyConstrain(final Graphics g) { @@ -463,7 +456,7 @@ } //TODO Move this method to SG2D? - private void SG2DConstraint(final SunGraphics2D sg2d, Region r) { + void SG2DConstraint(final SunGraphics2D sg2d, Region r) { sg2d.constrainX = sg2d.transX; sg2d.constrainY = sg2d.transY; @@ -710,7 +703,7 @@ // Obtain the metrics from the offscreen window where this peer is // mostly drawn to. // TODO: check for "use platform metrics" settings - Graphics g = getWindowPeer().getOffscreenGraphics(); + Graphics g = getWindowPeer().getGraphics(); try { if (g != null) { return g.getFontMetrics(f); @@ -1011,14 +1004,33 @@ @Override public final void applyShape(final Region shape) { synchronized (getStateLock()) { - region = shape; + if (region == shape || (region != null && region.equals(shape))) { + return; + } + } + applyShapeImpl(shape); + } + + void applyShapeImpl(final Region shape) { + synchronized (getStateLock()) { + if (shape != null) { + region = Region.WHOLE_REGION.getIntersection(shape); + } else { + region = null; + } } repaintParent(getBounds()); } protected final Region getRegion() { synchronized (getStateLock()) { - return region == null ? Region.getInstance(getSize()) : region; + return isShaped() ? region : Region.getInstance(getSize()); + } + } + + public boolean isShaped() { + synchronized (getStateLock()) { + return region != null; } } @@ -1386,11 +1398,6 @@ } } - // Just a helper method, thus final - protected final void flushOffscreenGraphics() { - flushOffscreenGraphics(getSize()); - } - protected static final void flushOnscreenGraphics(){ final OGLRenderQueue rq = OGLRenderQueue.getInstance(); rq.lock(); @@ -1401,36 +1408,6 @@ } } - /* - * Flushes the given rectangle from the back buffer to the screen. - */ - protected void flushOffscreenGraphics(Rectangle r) { - flushOffscreenGraphics(r.x, r.y, r.width, r.height); - } - - private void flushOffscreenGraphics(int x, int y, int width, int height) { - Image bb = getWindowPeerOrSelf().getBackBuffer(); - if (bb != null) { - // g is a screen Graphics from the delegate - final Graphics g = getOnscreenGraphics(); - - if (g != null && g instanceof Graphics2D) { - try { - Graphics2D g2d = (Graphics2D)g; - Point p = localToWindow(new Point(0, 0)); - Composite composite = g2d.getComposite(); - g2d.setComposite(AlphaComposite.Src); - g.drawImage(bb, x, y, x + width, y + height, p.x + x, - p.y + y, p.x + x + width, p.y + y + height, - null); - g2d.setComposite(composite); - } finally { - g.dispose(); - } - } - } - } - /** * Used by ContainerPeer to skip all the paint events during layout. * diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/LWRepaintArea.java --- a/src/macosx/classes/sun/lwawt/LWRepaintArea.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/LWRepaintArea.java Wed Aug 29 13:24:58 2012 +0100 @@ -58,9 +58,6 @@ private static void flushBuffers(final LWComponentPeer peer) { if (peer != null) { - if (!peer.getWindowPeerOrSelf().isOpaque()) { - peer.flushOffscreenGraphics(); - } peer.flushOnscreenGraphics(); } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/LWTextAreaPeer.java --- a/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/LWTextAreaPeer.java Wed Aug 29 13:24:58 2012 +0100 @@ -129,16 +129,6 @@ } @Override - public void setText(final String l) { - // Please note that we do not want to post an event - // if TextArea.setText() replaces an empty text by an empty text, - // that is, if component's text remains unchanged. - if (!l.isEmpty() || getTextComponent().getDocument().getLength() != 0) { - super.setText(l); - } - } - - @Override public void replaceRange(final String text, final int start, final int end) { synchronized (getDelegateLock()) { diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/LWTextComponentPeer.java --- a/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/LWTextComponentPeer.java Wed Aug 29 13:24:58 2012 +0100 @@ -124,7 +124,7 @@ } @Override - public void setText(final String l) { + public final void setText(final String l) { synchronized (getDelegateLock()) { // JTextArea.setText() posts two different events (remove & insert). // Since we make no differences between text events, diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/LWToolkit.java --- a/src/macosx/classes/sun/lwawt/LWToolkit.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/LWToolkit.java Wed Aug 29 13:24:58 2012 +0100 @@ -522,12 +522,6 @@ postEvent(targetToAppContext(event.getSource()), event); } - // use peer's back buffer to implement non-opaque windows. - @Override - public boolean needUpdateWindow() { - return true; - } - @Override public void grab(Window w) { if (w.getPeer() != null) { diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/LWWindowPeer.java --- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java Wed Aug 29 13:24:58 2012 +0100 @@ -37,6 +37,7 @@ import sun.java2d.*; import sun.java2d.loops.Blit; import sun.java2d.loops.CompositeType; +import sun.java2d.pipe.Region; import sun.util.logging.PlatformLogger; public class LWWindowPeer @@ -109,6 +110,10 @@ private volatile boolean skipNextFocusChange; + private static final Color nonOpaqueBackground = new Color(0, 0, 0, 0); + + private volatile boolean textured; + /** * Current modal blocker or null. * @@ -169,6 +174,11 @@ setAlwaysOnTop(getTarget().isAlwaysOnTop()); updateMinimumSize(); + final Shape shape = getTarget().getShape(); + if (shape != null) { + applyShape(Region.getInstance(shape, null)); + } + final float opacity = getTarget().getOpacity(); if (opacity < 1.0f) { setOpacity(opacity); @@ -178,7 +188,7 @@ updateInsets(platformWindow.getInsets()); if (getSurfaceData() == null) { - replaceSurfaceData(); + replaceSurfaceData(false); } } @@ -279,7 +289,7 @@ // "buffer", that's why numBuffers - 1 assert numBuffers > 1; - replaceSurfaceData(numBuffers - 1, caps); + replaceSurfaceData(numBuffers - 1, caps, false); } catch (InvalidPipeException z) { throw new AWTException(z.toString()); } @@ -441,19 +451,44 @@ public final void setOpaque(final boolean isOpaque) { if (this.isOpaque != isOpaque) { this.isOpaque = isOpaque; - getPlatformWindow().setOpaque(isOpaque); - replaceSurfaceData(); - repaintPeer(); + updateOpaque(); } } - public final boolean isOpaque() { - return isOpaque; + private void updateOpaque() { + getPlatformWindow().setOpaque(!isTranslucent()); + replaceSurfaceData(false); + repaintPeer(); } @Override public void updateWindow() { - flushOffscreenGraphics(); + } + + public final boolean isTextured() { + return textured; + } + + public final void setTextured(final boolean isTextured) { + textured = isTextured; + } + + public final boolean isTranslucent() { + synchronized (getStateLock()) { + /* + * Textured window is a special case of translucent window. + * The difference is only in nswindow background. So when we set + * texture property our peer became fully translucent. It doesn't + * fill background, create non opaque backbuffers and layer etc. + */ + return !isOpaque || isShaped() || isTextured(); + } + } + + @Override + final void applyShapeImpl(final Region shape) { + super.applyShapeImpl(shape); + updateOpaque(); } @Override @@ -608,7 +643,20 @@ getFont()); if (g != null) { try { - g.clearRect(0, 0, w, h); + if (g instanceof Graphics2D) { + ((Graphics2D) g).setComposite(AlphaComposite.Src); + } + if (isTranslucent()) { + g.setColor(nonOpaqueBackground); + g.fillRect(0, 0, w, h); + } + if (!isTextured()) { + if (g instanceof SunGraphics2D) { + SG2DConstraint((SunGraphics2D) g, getRegion()); + } + g.setColor(getBackground()); + g.fillRect(0, 0, w, h); + } } finally { g.dispose(); } @@ -915,35 +963,6 @@ }); } - /** - * This method returns a back buffer Graphics to render all the - * peers to. After the peer is painted, the back buffer contents - * should be flushed to the screen. All the target painting - * (Component.paint() method) should be done directly to the screen. - */ - protected final Graphics getOffscreenGraphics(Color fg, Color bg, Font f) { - final Image bb = getBackBuffer(); - if (bb == null) { - return null; - } - if (fg == null) { - fg = SystemColor.windowText; - } - if (bg == null) { - bg = SystemColor.window; - } - if (f == null) { - f = DEFAULT_FONT; - } - final Graphics2D g = (Graphics2D) bb.getGraphics(); - if (g != null) { - g.setColor(fg); - g.setBackground(bg); - g.setFont(f); - } - return g; - } - /* * May be called by delegate to provide SD to Java2D code. */ @@ -954,11 +973,16 @@ } private void replaceSurfaceData() { - replaceSurfaceData(backBufferCount, backBufferCaps); + replaceSurfaceData(true); + } + + private void replaceSurfaceData(boolean blit) { + replaceSurfaceData(backBufferCount, backBufferCaps, blit); } private void replaceSurfaceData(int newBackBufferCount, - BufferCapabilities newBackBufferCaps) { + BufferCapabilities newBackBufferCaps, + boolean blit) { synchronized (surfaceDataLock) { final SurfaceData oldData = getSurfaceData(); surfaceData = platformWindow.replaceSurfaceData(); @@ -971,7 +995,10 @@ if (getSurfaceData() != null && oldData != getSurfaceData()) { clearBackground(size.width, size.height); } - blitSurfaceData(oldData, getSurfaceData()); + + if (blit) { + blitSurfaceData(oldData, getSurfaceData()); + } if (oldData != null && oldData != getSurfaceData()) { // TODO: drop oldData for D3D/WGL pipelines @@ -986,11 +1013,18 @@ Graphics g = backBuffer.getGraphics(); try { Rectangle r = getBounds(); - g.setColor(getBackground()); if (g instanceof Graphics2D) { ((Graphics2D) g).setComposite(AlphaComposite.Src); } + g.setColor(nonOpaqueBackground); g.fillRect(0, 0, r.width, r.height); + if (g instanceof SunGraphics2D) { + SG2DConstraint((SunGraphics2D) g, getRegion()); + } + if (!isTextured()) { + g.setColor(getBackground()); + g.fillRect(0, 0, r.width, r.height); + } if (oldBB != null) { // Draw the old back buffer to the new one g.drawImage(oldBB, 0, 0, null); @@ -1014,7 +1048,7 @@ CompositeType.Src, dst.getSurfaceType()); if (blit != null) { - blit.Blit(src, dst, ((Graphics2D) getGraphics()).getComposite(), + blit.Blit(src, dst, AlphaComposite.Src, getRegion(), 0, 0, 0, 0, size.width, size.height); } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java --- a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java Wed Aug 29 13:24:58 2012 +0100 @@ -182,6 +182,10 @@ Long format = predefinedClipboardNameMap.get(str); if (format == null) { + if (java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().isHeadlessInstance()) { + // Do not try to access GUI manager for unknown format + return new Long(-1); + } format = new Long(registerFormatWithPasteboard(str)); predefinedClipboardNameMap.put(str, format); predefinedClipboardFormatMap.put(format, str); diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Wed Aug 29 13:24:58 2012 +0100 @@ -117,7 +117,7 @@ Rectangle r = peer.getBounds(); Image im = null; if (!r.isEmpty()) { - int transparency = (peer.isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT); + int transparency = peer.isTranslucent() ? Transparency.TRANSLUCENT : Transparency.OPAQUE; im = peer.getGraphicsConfiguration().createCompatibleImage(r.width, r.height, transparency); } return im; diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/macosx/CPlatformView.java --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java Wed Aug 29 13:24:58 2012 +0100 @@ -64,7 +64,7 @@ } public boolean isOpaque() { - return peer.isOpaque(); + return !peer.isTranslucent(); } /* diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java --- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Wed Aug 29 13:24:58 2012 +0100 @@ -299,7 +299,7 @@ // If the target is a dialog, popup or tooltip we want it to ignore the brushed metal look. if (isPopup) { - styleBits = SET(styleBits, TEXTURED, true); + styleBits = SET(styleBits, TEXTURED, false); // Popups in applets don't activate applet's process styleBits = SET(styleBits, NONACTIVATING, true); } @@ -373,6 +373,8 @@ } } + peer.setTextured(IS(TEXTURED, styleBits)); + return styleBits; } @@ -740,10 +742,19 @@ @Override public void setOpaque(boolean isOpaque) { CWrapper.NSWindow.setOpaque(getNSWindowPtr(), isOpaque); - if (!isOpaque) { + if (!isOpaque && !peer.isTextured()) { long clearColor = CWrapper.NSColor.clearColor(); CWrapper.NSWindow.setBackgroundColor(getNSWindowPtr(), clearColor); } + + //This is a temporary workaround. Looks like after 7124236 will be fixed + //the correct place for invalidateShadow() is CGLayer.drawInCGLContext. + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + invalidateShadow(); + } + }); } @Override @@ -813,6 +824,10 @@ } + public final void invalidateShadow(){ + nativeRevalidateNSWindowShadow(getNSWindowPtr()); + } + // ---------------------------------------------------------------------- // UTILITY METHODS // ---------------------------------------------------------------------- diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java --- a/src/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CToolkitThreadBlockedHandler.java Wed Aug 29 13:24:58 2012 +0100 @@ -28,7 +28,10 @@ import sun.awt.datatransfer.ToolkitThreadBlockedHandler; final class CToolkitThreadBlockedHandler implements ToolkitThreadBlockedHandler { - private final LWCToolkit toolkit = (LWCToolkit)java.awt.Toolkit.getDefaultToolkit(); + private final LWCToolkit toolkit = + java.awt.Toolkit.getDefaultToolkit() instanceof LWCToolkit + ? (LWCToolkit)java.awt.Toolkit.getDefaultToolkit() + : null; public void lock() { } @@ -44,7 +47,9 @@ // Despite the naming of this method, on MacOS only one // event is read and dispatched before this method returns. // This call is non-blocking and does not wait for an event - toolkit.startNativeNestedEventLoop(); + if (toolkit != null) { + toolkit.startNativeNestedEventLoop(); + } } public void exit() { diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java --- a/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Aug 29 13:24:58 2012 +0100 @@ -759,6 +759,11 @@ } @Override + public boolean isWindowShapingSupported() { + return true; + } + + @Override public boolean isWindowTranslucencySupported() { return true; } @@ -768,6 +773,10 @@ return true; } + public boolean isSwingBackbufferTranslucencySupported() { + return true; + } + @Override public boolean enableInputMethodsForTextComponent() { return true; diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/native/sun/awt/AWTWindow.m --- a/src/macosx/native/sun/awt/AWTWindow.m Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/native/sun/awt/AWTWindow.m Wed Aug 29 13:24:58 2012 +0100 @@ -1017,14 +1017,17 @@ (JNIEnv *env, jclass clazz, jlong windowPtr) { JNF_COCOA_ENTER(env); -AWT_ASSERT_NOT_APPKIT_THREAD; NSWindow *nsWindow = OBJC(windowPtr); - [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ - AWT_ASSERT_APPKIT_THREAD; + if ([NSThread isMainThread]) { + [nsWindow invalidateShadow]; + } else { + [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){ + AWT_ASSERT_APPKIT_THREAD; - [nsWindow invalidateShadow]; - }]; + [nsWindow invalidateShadow]; + }]; + } JNF_COCOA_EXIT(env); } diff -r db7b5a2b5b11 -r 5a2688a73184 src/macosx/native/sun/awt/CGraphicsDevice.m --- a/src/macosx/native/sun/awt/CGraphicsDevice.m Wed Aug 29 12:57:49 2012 +0100 +++ b/src/macosx/native/sun/awt/CGraphicsDevice.m Wed Aug 29 13:24:58 2012 +0100 @@ -28,7 +28,7 @@ /* * Convert the mode string to the more convinient bits per pixel value */ -static int getBPPFromModeString(CFStringRef mode) +static int getBPPFromModeString(CFStringRef mode) { if ((CFStringCompare(mode, CFSTR(kIO30BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)) { // This is a strange mode, where we using 10 bits per RGB component and pack it into 32 bits @@ -44,7 +44,7 @@ else if (CFStringCompare(mode, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) { return 8; } - + return 0; } @@ -68,6 +68,11 @@ // One of the key parameters does not match continue; } + + if (refrate == 0) { // REFRESH_RATE_UNKNOWN + return cRef; + } + // Refresh rate might be 0 in display mode and we ask for specific display rate // but if we do not find exact match then 0 refresh rate might be just Ok if (CGDisplayModeGetRefreshRate(cRef) == refrate) { @@ -165,7 +170,10 @@ } } }]; + } else { + [JNFException raise:env as:kIllegalArgumentException reason:"Invalid display mode"]; } + CFRelease(allModes); JNF_COCOA_EXIT(env); } diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/com/sun/beans/TypeResolver.java --- a/src/share/classes/com/sun/beans/TypeResolver.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/com/sun/beans/TypeResolver.java Wed Aug 29 13:24:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,9 @@ * @author Sergey Malenkov */ public final class TypeResolver { + + private static final WeakCache> CACHE = new WeakCache<>(); + /** * Replaces the given {@code type} in an inherited method * with the actual type it has in the given {@code inClass}. @@ -149,12 +152,55 @@ * @param formal the type where occurrences of the variables * in {@code actual} will be replaced by the corresponding bound values * @return a resolved type - * - * @see #TypeResolver(Type) - * @see #resolve(Type) */ public static Type resolve(Type actual, Type formal) { - return getTypeResolver(actual).resolve(formal); + if (formal instanceof Class) { + return formal; + } + if (formal instanceof GenericArrayType) { + Type comp = ((GenericArrayType) formal).getGenericComponentType(); + comp = resolve(actual, comp); + return (comp instanceof Class) + ? Array.newInstance((Class) comp, 0).getClass() + : GenericArrayTypeImpl.make(comp); + } + if (formal instanceof ParameterizedType) { + ParameterizedType fpt = (ParameterizedType) formal; + Type[] actuals = resolve(actual, fpt.getActualTypeArguments()); + return ParameterizedTypeImpl.make( + (Class) fpt.getRawType(), actuals, fpt.getOwnerType()); + } + if (formal instanceof WildcardType) { + WildcardType fwt = (WildcardType) formal; + Type[] upper = resolve(actual, fwt.getUpperBounds()); + Type[] lower = resolve(actual, fwt.getLowerBounds()); + return new WildcardTypeImpl(upper, lower); + } + if (formal instanceof TypeVariable) { + Map map; + synchronized (CACHE) { + map = CACHE.get(actual); + if (map == null) { + map = new HashMap<>(); + prepare(map, actual); + CACHE.put(actual, map); + } + } + Type result = map.get(formal); + if (result == null || result.equals(formal)) { + return formal; + } + result = fixGenericArray(result); + // A variable can be bound to another variable that is itself bound + // to something. For example, given: + // class Super {...} + // class Mid extends Super {...} + // class Sub extends Mid + // the variable T is bound to X, which is in turn bound to String. + // So if we have to resolve T, we need the tail recursion here. + return resolve(actual, result); + } + throw new IllegalArgumentException("Bad Type kind: " + formal.getClass()); } /** @@ -164,12 +210,14 @@ * @param actual the type that supplies bindings for type variables * @param formals the array of types to resolve * @return an array of resolved types - * - * @see #TypeResolver(Type) - * @see #resolve(Type[]) */ public static Type[] resolve(Type actual, Type[] formals) { - return getTypeResolver(actual).resolve(formals); + int length = formals.length; + Type[] actuals = new Type[length]; + for (int i = 0; i < length; i++) { + actuals[i] = resolve(actual, formals[i]); + } + return actuals; } /** @@ -228,32 +276,6 @@ return classes; } - public static TypeResolver getTypeResolver(Type type) { - synchronized (CACHE) { - TypeResolver resolver = CACHE.get(type); - if (resolver == null) { - resolver = new TypeResolver(type); - CACHE.put(type, resolver); - } - return resolver; - } - } - - private static final WeakCache CACHE = new WeakCache<>(); - - private final Map, Type> map = new HashMap<>(); - - /** - * Constructs the type resolver for the given actual type. - * - * @param actual the type that supplies bindings for type variables - * - * @see #prepare(Type) - */ - private TypeResolver(Type actual) { - prepare(actual); - } - /** * Fills the map from type parameters * to types as seen by the given {@code type}. @@ -265,9 +287,10 @@ * to a {@link ParameterizedType ParameterizedType} with no parameters, * or it represents the erasure of a {@link ParameterizedType ParameterizedType}. * + * @param map the mappings of all type variables * @param type the next type in the hierarchy */ - private void prepare(Type type) { + private static void prepare(Map map, Type type) { Class raw = (Class)((type instanceof Class) ? type : ((ParameterizedType)type).getRawType()); @@ -280,91 +303,25 @@ assert formals.length == actuals.length; for (int i = 0; i < formals.length; i++) { - this.map.put(formals[i], actuals[i]); + map.put(formals[i], actuals[i]); } Type gSuperclass = raw.getGenericSuperclass(); if (gSuperclass != null) { - prepare(gSuperclass); + prepare(map, gSuperclass); } for (Type gInterface : raw.getGenericInterfaces()) { - prepare(gInterface); + prepare(map, gInterface); } // If type is the raw version of a parameterized class, we type-erase // all of its type variables, including inherited ones. if (type instanceof Class && formals.length > 0) { - for (Map.Entry, Type> entry : this.map.entrySet()) { + for (Map.Entry entry : map.entrySet()) { entry.setValue(erase(entry.getValue())); } } } /** - * Replaces the given {@code formal} type - * with the type it stand for in this type resolver. - * - * @param formal the array of types to resolve - * @return a resolved type - */ - private Type resolve(Type formal) { - if (formal instanceof Class) { - return formal; - } - if (formal instanceof GenericArrayType) { - Type comp = ((GenericArrayType)formal).getGenericComponentType(); - comp = resolve(comp); - return (comp instanceof Class) - ? Array.newInstance((Class)comp, 0).getClass() - : GenericArrayTypeImpl.make(comp); - } - if (formal instanceof ParameterizedType) { - ParameterizedType fpt = (ParameterizedType)formal; - Type[] actuals = resolve(fpt.getActualTypeArguments()); - return ParameterizedTypeImpl.make( - (Class)fpt.getRawType(), actuals, fpt.getOwnerType()); - } - if (formal instanceof WildcardType) { - WildcardType fwt = (WildcardType)formal; - Type[] upper = resolve(fwt.getUpperBounds()); - Type[] lower = resolve(fwt.getLowerBounds()); - return new WildcardTypeImpl(upper, lower); - } - if (!(formal instanceof TypeVariable)) { - throw new IllegalArgumentException("Bad Type kind: " + formal.getClass()); - } - Type actual = this.map.get((TypeVariable) formal); - if (actual == null || actual.equals(formal)) { - return formal; - } - actual = fixGenericArray(actual); - return resolve(actual); - // A variable can be bound to another variable that is itself bound - // to something. For example, given: - // class Super {...} - // class Mid extends Super {...} - // class Sub extends Mid - // the variable T is bound to X, which is in turn bound to String. - // So if we have to resolve T, we need the tail recursion here. - } - - /** - * Replaces all formal types in the given array - * with the types they stand for in this type resolver. - * - * @param formals the array of types to resolve - * @return an array of resolved types - * - * @see #resolve(Type) - */ - private Type[] resolve(Type[] formals) { - int length = formals.length; - Type[] actuals = new Type[length]; - for (int i = 0; i < length; i++) { - actuals[i] = resolve(formals[i]); - } - return actuals; - } - - /** * Replaces a {@link GenericArrayType GenericArrayType} * with plain array class where it is possible. * Bug 5041784 diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/com/sun/beans/finder/MethodFinder.java --- a/src/share/classes/com/sun/beans/finder/MethodFinder.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/com/sun/beans/finder/MethodFinder.java Wed Aug 29 13:24:58 2012 +0100 @@ -167,8 +167,10 @@ return findAccessibleMethod(m); } Type[] gpts = m.getGenericParameterTypes(); - if (Arrays.equals(params, TypeResolver.erase(TypeResolver.resolve(pt, gpts)))) { - return findAccessibleMethod(m); + if (params.length == gpts.length) { + if (Arrays.equals(params, TypeResolver.erase(TypeResolver.resolve(pt, gpts)))) { + return findAccessibleMethod(m); + } } } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java --- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java Wed Aug 29 13:24:58 2012 +0100 @@ -796,9 +796,10 @@ "Menu.margin", zeroInsets, "Menu.cancelMode", "hideMenuTree", "Menu.alignAcceleratorText", Boolean.FALSE, + "Menu.useMenuBarForTopLevelMenus", Boolean.TRUE, - "MenuBar.windowBindings", new Object[] { + "MenuBar.windowBindings", new Object[] { "F10", "takeFocus" }, "MenuBar.font", new FontLazyValue(Region.MENU_BAR), diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java --- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKStyleFactory.java Wed Aug 29 13:24:58 2012 +0100 @@ -92,7 +92,13 @@ boolean defaultCapable = btn.isDefaultCapable(); key = new ComplexKey(wt, toolButton, defaultCapable); } + } else if (id == Region.MENU) { + if (c instanceof JMenu && ((JMenu) c).isTopLevelMenu() && + UIManager.getBoolean("Menu.useMenuBarForTopLevelMenus")) { + wt = WidgetType.MENU_BAR; + } } + if (key == null) { // Otherwise, just use the WidgetType as the key. key = wt; diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/java/awt/EventQueue.java --- a/src/share/classes/java/awt/EventQueue.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/java/awt/EventQueue.java Wed Aug 29 13:24:58 2012 +0100 @@ -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; @@ -348,6 +350,10 @@ } private boolean coalesceMouseEvent(MouseEvent e) { + if (e instanceof SunDropTargetEvent) { + // SunDropTargetEvent should not coalesce with MouseEvent + return false; + } EventQueueItem[] cache = ((Component)e.getSource()).eventCache; if (cache == null) { return false; @@ -427,6 +433,10 @@ } private void cacheEQItem(EventQueueItem entry) { + if(entry.event instanceof SunDropTargetEvent) { + // Do not cache SunDropTargetEvent, it should not coalesce + return; + } int index = eventToCacheIndex(entry.event); if (index != -1 && entry.event.getSource() instanceof Component) { Component source = (Component)entry.event.getSource(); diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/java/awt/GraphicsEnvironment.java --- a/src/share/classes/java/awt/GraphicsEnvironment.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/java/awt/GraphicsEnvironment.java Wed Aug 29 13:24:58 2012 +0100 @@ -170,12 +170,12 @@ if (System.getProperty("javaplugin.version") != null) { headless = defaultHeadless = Boolean.FALSE; } else { - if ("sun.awt.HeadlessGraphicsEnvironment".equals( - System.getProperty("java.awt.graphicsenv"))) + String osName = System.getProperty("os.name"); + if (osName.contains("OS X") && "sun.awt.HToolkit".equals( + System.getProperty("awt.toolkit"))) { headless = defaultHeadless = Boolean.TRUE; } else { - String osName = System.getProperty("os.name"); headless = defaultHeadless = Boolean.valueOf(("Linux".equals(osName) || "SunOS".equals(osName) || diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/java/awt/TextComponent.java --- a/src/share/classes/java/awt/TextComponent.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/java/awt/TextComponent.java Wed Aug 29 13:24:58 2012 +0100 @@ -233,9 +233,14 @@ * @see java.awt.TextComponent#getText */ public synchronized void setText(String t) { + boolean skipTextEvent = (text == null || text.isEmpty()) + && (t == null || t.isEmpty()); text = (t != null) ? t : ""; TextComponentPeer peer = (TextComponentPeer)this.peer; - if (peer != null) { + // Please note that we do not want to post an event + // if TextArea.setText() or TextField.setText() replaces an empty text + // by an empty text, that is, if component's text remains unchanged. + if (peer != null && !skipTextEvent) { peer.setText(text); } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/java/awt/event/InvocationEvent.java diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/java/beans/IndexedPropertyDescriptor.java --- a/src/share/classes/java/beans/IndexedPropertyDescriptor.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/java/beans/IndexedPropertyDescriptor.java Wed Aug 29 13:24:58 2012 +0100 @@ -181,20 +181,21 @@ // the Indexed readMethod was explicitly set to null. return null; } + String nextMethodName = Introspector.GET_PREFIX + getBaseName(); if (indexedReadMethodName == null) { Class type = getIndexedPropertyType0(); if (type == boolean.class || type == null) { indexedReadMethodName = Introspector.IS_PREFIX + getBaseName(); } else { - indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); + indexedReadMethodName = nextMethodName; } } Class[] args = { int.class }; indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args); - if (indexedReadMethod == null) { + if ((indexedReadMethod == null) && !indexedReadMethodName.equals(nextMethodName)) { // no "is" method, so look for a "get" method. - indexedReadMethodName = Introspector.GET_PREFIX + getBaseName(); + indexedReadMethodName = nextMethodName; indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args); } setIndexedReadMethod0(indexedReadMethod); diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/java/beans/Introspector.java --- a/src/share/classes/java/beans/Introspector.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/java/beans/Introspector.java Wed Aug 29 13:24:58 2012 +0100 @@ -25,6 +25,7 @@ package java.beans; +import com.sun.beans.TypeResolver; import com.sun.beans.WeakCache; import com.sun.beans.finder.ClassFinder; @@ -34,6 +35,7 @@ import java.lang.ref.SoftReference; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.lang.reflect.Type; import java.util.Map; import java.util.ArrayList; @@ -951,44 +953,61 @@ continue; } - Class argTypes[] = FeatureDescriptor.getParameterTypes(beanClass, method); - Class resultType = FeatureDescriptor.getReturnType(beanClass, method); - - if (name.startsWith(ADD_PREFIX) && argTypes.length == 1 && - resultType == Void.TYPE && - Introspector.isSubclass(argTypes[0], eventListenerType)) { - String listenerName = name.substring(3); - if (listenerName.length() > 0 && - argTypes[0].getName().endsWith(listenerName)) { - if (adds == null) { - adds = new HashMap(); + if (name.startsWith(ADD_PREFIX)) { + Class returnType = method.getReturnType(); + if (returnType == void.class) { + Type[] parameterTypes = method.getGenericParameterTypes(); + if (parameterTypes.length == 1) { + Class type = TypeResolver.erase(TypeResolver.resolveInClass(beanClass, parameterTypes[0])); + if (Introspector.isSubclass(type, eventListenerType)) { + String listenerName = name.substring(3); + if (listenerName.length() > 0 && + type.getName().endsWith(listenerName)) { + if (adds == null) { + adds = new HashMap(); + } + adds.put(listenerName, method); + } + } } - adds.put(listenerName, method); } } - else if (name.startsWith(REMOVE_PREFIX) && argTypes.length == 1 && - resultType == Void.TYPE && - Introspector.isSubclass(argTypes[0], eventListenerType)) { - String listenerName = name.substring(6); - if (listenerName.length() > 0 && - argTypes[0].getName().endsWith(listenerName)) { - if (removes == null) { - removes = new HashMap(); + else if (name.startsWith(REMOVE_PREFIX)) { + Class returnType = method.getReturnType(); + if (returnType == void.class) { + Type[] parameterTypes = method.getGenericParameterTypes(); + if (parameterTypes.length == 1) { + Class type = TypeResolver.erase(TypeResolver.resolveInClass(beanClass, parameterTypes[0])); + if (Introspector.isSubclass(type, eventListenerType)) { + String listenerName = name.substring(6); + if (listenerName.length() > 0 && + type.getName().endsWith(listenerName)) { + if (removes == null) { + removes = new HashMap(); + } + removes.put(listenerName, method); + } + } } - removes.put(listenerName, method); } } - else if (name.startsWith(GET_PREFIX) && argTypes.length == 0 && - resultType.isArray() && - Introspector.isSubclass(resultType.getComponentType(), - eventListenerType)) { - String listenerName = name.substring(3, name.length() - 1); - if (listenerName.length() > 0 && - resultType.getComponentType().getName().endsWith(listenerName)) { - if (gets == null) { - gets = new HashMap(); + else if (name.startsWith(GET_PREFIX)) { + Class[] parameterTypes = method.getParameterTypes(); + if (parameterTypes.length == 0) { + Class returnType = FeatureDescriptor.getReturnType(beanClass, method); + if (returnType.isArray()) { + Class type = returnType.getComponentType(); + if (Introspector.isSubclass(type, eventListenerType)) { + String listenerName = name.substring(3, name.length() - 1); + if (listenerName.length() > 0 && + type.getName().endsWith(listenerName)) { + if (gets == null) { + gets = new HashMap(); + } + gets.put(listenerName, method); + } + } } - gets.put(listenerName, method); } } } @@ -1240,11 +1259,11 @@ private boolean isEventHandler(Method m) { // We assume that a method is an event handler if it has a single // argument, whose type inherit from java.util.Event. - Class argTypes[] = FeatureDescriptor.getParameterTypes(beanClass, m); + Type argTypes[] = m.getGenericParameterTypes(); if (argTypes.length != 1) { return false; } - return isSubclass(argTypes[0], EventObject.class); + return isSubclass(TypeResolver.erase(TypeResolver.resolveInClass(beanClass, argTypes[0])), EventObject.class); } /* @@ -1296,24 +1315,25 @@ } // make sure method signature matches. - Class params[] = FeatureDescriptor.getParameterTypes(start, method); - if (method.getName().equals(methodName) && - params.length == argCount) { - if (args != null) { - boolean different = false; - if (argCount > 0) { - for (int j = 0; j < argCount; j++) { - if (params[j] != args[j]) { - different = true; + if (method.getName().equals(methodName)) { + Type[] params = method.getGenericParameterTypes(); + if (params.length == argCount) { + if (args != null) { + boolean different = false; + if (argCount > 0) { + for (int j = 0; j < argCount; j++) { + if (TypeResolver.erase(TypeResolver.resolveInClass(start, params[j])) != args[j]) { + different = true; + continue; + } + } + if (different) { continue; } } - if (different) { - continue; - } } + return method; } - return method; } } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/java/beans/PropertyDescriptor.java --- a/src/share/classes/java/beans/PropertyDescriptor.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/java/beans/PropertyDescriptor.java Wed Aug 29 13:24:58 2012 +0100 @@ -210,12 +210,13 @@ // The read method was explicitly set to null. return null; } + String nextMethodName = Introspector.GET_PREFIX + getBaseName(); if (readMethodName == null) { Class type = getPropertyType0(); if (type == boolean.class || type == null) { readMethodName = Introspector.IS_PREFIX + getBaseName(); } else { - readMethodName = Introspector.GET_PREFIX + getBaseName(); + readMethodName = nextMethodName; } } @@ -225,8 +226,8 @@ // methods. If an "is" method exists, this is the official // reader method so look for this one first. readMethod = Introspector.findMethod(cls, readMethodName, 0); - if (readMethod == null) { - readMethodName = Introspector.GET_PREFIX + getBaseName(); + if ((readMethod == null) && !readMethodName.equals(nextMethodName)) { + readMethodName = nextMethodName; readMethod = Introspector.findMethod(cls, readMethodName, 0); } try { diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/java/net/HttpCookie.java --- a/src/share/classes/java/net/HttpCookie.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/java/net/HttpCookie.java Wed Aug 29 13:24:58 2012 +0100 @@ -154,7 +154,7 @@ private HttpCookie(String name, String value, String header) { name = name.trim(); - if (name.length() == 0 || !isToken(name) || isReserved(name)) { + if (name.length() == 0 || !isToken(name) || name.charAt(0) == '$') { throw new IllegalArgumentException("Illegal cookie name"); } @@ -909,32 +909,6 @@ /* - * @param name the name to be tested - * @return true if the name is reserved by cookie - * specification, false if it is not - */ - private static boolean isReserved(String name) { - if (name.equalsIgnoreCase("Comment") - || name.equalsIgnoreCase("CommentURL") // rfc2965 only - || name.equalsIgnoreCase("Discard") // rfc2965 only - || name.equalsIgnoreCase("Domain") - || name.equalsIgnoreCase("Expires") // netscape draft only - || name.equalsIgnoreCase("Max-Age") - || name.equalsIgnoreCase("Path") - || name.equalsIgnoreCase("Port") // rfc2965 only - || name.equalsIgnoreCase("Secure") - || name.equalsIgnoreCase("Version") - || name.equalsIgnoreCase("HttpOnly") - || name.charAt(0) == '$') - { - return true; - } - - return false; - } - - - /* * Parse header string to cookie object. * * @param header header string; should contain only one NAME=VALUE pair diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/javax/swing/JComponent.java --- a/src/share/classes/javax/swing/JComponent.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/javax/swing/JComponent.java Wed Aug 29 13:24:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2627,17 +2627,16 @@ * attribute: visualUpdate true */ public void setVisible(boolean aFlag) { - if(aFlag != isVisible()) { + if (aFlag != isVisible()) { super.setVisible(aFlag); - Container parent = getParent(); - if(parent != null) { - Rectangle r = getBounds(); - parent.repaint(r.x,r.y,r.width,r.height); + if (aFlag) { + Container parent = getParent(); + if (parent != null) { + Rectangle r = getBounds(); + parent.repaint(r.x, r.y, r.width, r.height); + } + revalidate(); } - // Some (all should) LayoutManagers do not consider components - // that are not visible. As such we need to revalidate when the - // visible bit changes. - revalidate(); } } @@ -5555,4 +5554,22 @@ ",preferredSize=" + preferredSizeString; } + /** + * {@inheritDoc} + */ + @Override + @Deprecated + public void hide() { + boolean showing = isShowing(); + super.hide(); + if (showing) { + Container parent = getParent(); + if (parent != null) { + Rectangle r = getBounds(); + parent.repaint(r.x, r.y, r.width, r.height); + } + revalidate(); + } + } + } diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/javax/swing/JViewport.java --- a/src/share/classes/javax/swing/JViewport.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/javax/swing/JViewport.java Wed Aug 29 13:24:58 2012 +0100 @@ -1586,10 +1586,18 @@ int bdx = blitToX - blitFromX; int bdy = blitToY - blitFromY; + Composite oldComposite = null; // Shift the scrolled region + if (g instanceof Graphics2D) { + Graphics2D g2d = (Graphics2D) g; + oldComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.Src); + } rm.copyArea(this, g, blitFromX, blitFromY, blitW, blitH, bdx, bdy, false); - + if (oldComposite != null) { + ((Graphics2D) g).setComposite(oldComposite); + } // Paint the newly exposed region. int x = view.getX(); int y = view.getY(); diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/javax/swing/RepaintManager.java --- a/src/share/classes/javax/swing/RepaintManager.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/javax/swing/RepaintManager.java Wed Aug 29 13:24:58 2012 +0100 @@ -119,6 +119,11 @@ // Whether or not a VolatileImage should be used for double-buffered painting static boolean volatileImageBufferEnabled = true; /** + * Type of VolatileImage which should be used for double-buffered + * painting. + */ + private static final int volatileBufferType; + /** * Value of the system property awt.nativeDoubleBuffering. */ private static boolean nativeDoubleBuffering; @@ -204,6 +209,13 @@ ((SunGraphicsEnvironment)ge).addDisplayChangedListener( new DisplayChangedHandler()); } + Toolkit tk = Toolkit.getDefaultToolkit(); + if ((tk instanceof SunToolkit) + && ((SunToolkit) tk).isSwingBackbufferTranslucencySupported()) { + volatileBufferType = Transparency.TRANSLUCENT; + } else { + volatileBufferType = Transparency.OPAQUE; + } } /** @@ -985,7 +997,8 @@ if (image != null) { image.flush(); } - image = config.createCompatibleVolatileImage(width, height); + image = config.createCompatibleVolatileImage(width, height, + volatileBufferType); volatileMap.put(config, image); } return image; @@ -1479,9 +1492,26 @@ for(y=clipY, maxy = clipY + clipH; y < maxy ; y += bh) { osg.translate(-x, -y); osg.setClip(x,y,bw,bh); + if (volatileBufferType != Transparency.OPAQUE + && osg instanceof Graphics2D) { + final Graphics2D g2d = (Graphics2D) osg; + final Color oldBg = g2d.getBackground(); + g2d.setBackground(c.getBackground()); + g2d.clearRect(x, y, bw, bh); + g2d.setBackground(oldBg); + } c.paintToOffscreen(osg, x, y, bw, bh, maxx, maxy); g.setClip(x, y, bw, bh); - g.drawImage(image, x, y, c); + if (volatileBufferType != Transparency.OPAQUE + && g instanceof Graphics2D) { + final Graphics2D g2d = (Graphics2D) g; + final Composite oldComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.Src); + g2d.drawImage(image, x, y, c); + g2d.setComposite(oldComposite); + } else { + g.drawImage(image, x, y, c); + } osg.translate(x, y); } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/javax/swing/SwingUtilities.java --- a/src/share/classes/javax/swing/SwingUtilities.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/javax/swing/SwingUtilities.java Wed Aug 29 13:24:58 2012 +0100 @@ -316,7 +316,8 @@ newEvent = new MouseWheelEvent(newSource, sourceWheelEvent.getID(), sourceWheelEvent.getWhen(), - sourceWheelEvent.getModifiers(), + sourceWheelEvent.getModifiers() + | sourceWheelEvent.getModifiersEx(), p.x,p.y, sourceWheelEvent.getXOnScreen(), sourceWheelEvent.getYOnScreen(), @@ -331,7 +332,8 @@ newEvent = new MenuDragMouseEvent(newSource, sourceMenuDragEvent.getID(), sourceMenuDragEvent.getWhen(), - sourceMenuDragEvent.getModifiers(), + sourceMenuDragEvent.getModifiers() + | sourceMenuDragEvent.getModifiersEx(), p.x,p.y, sourceMenuDragEvent.getXOnScreen(), sourceMenuDragEvent.getYOnScreen(), @@ -344,7 +346,8 @@ newEvent = new MouseEvent(newSource, sourceEvent.getID(), sourceEvent.getWhen(), - sourceEvent.getModifiers(), + sourceEvent.getModifiers() + | sourceEvent.getModifiersEx(), p.x,p.y, sourceEvent.getXOnScreen(), sourceEvent.getYOnScreen(), diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java --- a/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java Wed Aug 29 13:24:58 2012 +0100 @@ -299,7 +299,8 @@ */ @Override public void propertyChange(PropertyChangeEvent e) { - if (SynthLookAndFeel.shouldUpdateStyle(e)) { + if (SynthLookAndFeel.shouldUpdateStyle(e) || + (e.getPropertyName().equals("ancestor") && UIManager.getBoolean("Menu.useMenuBarForTopLevelMenus"))) { updateStyle((JMenu)e.getSource()); } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/sun/awt/AWTAccessor.java diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/sun/awt/SunToolkit.java --- a/src/share/classes/sun/awt/SunToolkit.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/sun/awt/SunToolkit.java Wed Aug 29 13:24:58 2012 +0100 @@ -1976,6 +1976,13 @@ } /** + * Returns true if swing backbuffer should be translucent. + */ + public boolean isSwingBackbufferTranslucencySupported() { + return false; + } + + /** * Returns whether or not a containing top level window for the passed * component is * {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT PERPIXEL_TRANSLUCENT}. diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/sun/beans/editors/BoolEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/beans/editors/BoolEditor.java Wed Aug 29 13:24:58 2012 +0100 @@ -0,0 +1,31 @@ + /* + * 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.beans.editors; + + /** + * FOR BACKWARD COMPATIBILITY ONLY - DO NOT USE. + */ + public class BoolEditor extends BooleanEditor { + } diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/sun/beans/editors/IntEditor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/classes/sun/beans/editors/IntEditor.java Wed Aug 29 13:24:58 2012 +0100 @@ -0,0 +1,31 @@ + /* + * 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.beans.editors; + + /** + * FOR BACKWARD COMPATIBILITY ONLY - DO NOT USE. + */ + public class IntEditor extends IntegerEditor { + } diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/sun/font/SunLayoutEngine.java --- a/src/share/classes/sun/font/SunLayoutEngine.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/sun/font/SunLayoutEngine.java Wed Aug 29 13:24:58 2012 +0100 @@ -137,8 +137,9 @@ LayoutEngine e = (LayoutEngine)cache.get(key); if (e == null) { - e = new SunLayoutEngine(key.copy()); - cache.put(key, e); + LayoutEngineKey copy = key.copy(); + e = new SunLayoutEngine(copy); + cache.put(copy, e); } return e; } diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/sun/security/pkcs/SignerInfo.java --- a/src/share/classes/sun/security/pkcs/SignerInfo.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/sun/security/pkcs/SignerInfo.java Wed Aug 29 13:24:58 2012 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -273,6 +273,24 @@ return certList; } + // Copied from com.sun.crypto.provider.OAEPParameters. + private static String convertToStandardName(String internalName) { + if (internalName.equals("SHA")) { + return "SHA-1"; + } else if (internalName.equals("SHA224")) { + return "SHA-224"; + } else if (internalName.equals("SHA256")) { + return "SHA-256"; + } else if (internalName.equals("SHA384")) { + return "SHA-384"; + } else if (internalName.equals("SHA512")) { + return "SHA-512"; + } else { + return internalName; + } + } + + /* Returns null if verify fails, this signerInfo if verify succeeds. */ SignerInfo verify(PKCS7 block, byte[] data) @@ -311,7 +329,8 @@ if (messageDigest == null) // fail if there is no message digest return null; - MessageDigest md = MessageDigest.getInstance(digestAlgname); + MessageDigest md = MessageDigest.getInstance( + convertToStandardName(digestAlgname)); byte[] computedMessageDigest = md.digest(data); if (messageDigest.length != computedMessageDigest.length) diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/classes/sun/security/provider/certpath/OCSPResponse.java --- a/src/share/classes/sun/security/provider/certpath/OCSPResponse.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/classes/sun/security/provider/certpath/OCSPResponse.java Wed Aug 29 13:24:58 2012 +0100 @@ -349,7 +349,9 @@ } } - X509Certificate trustedResponderCert = null; + // By default, the OCSP responder's cert is the same as the issuer of + // the cert being validated. The issuer cert is the first in the list. + X509Certificate trustedResponderCert = responderCerts.get(0); // Check whether the signer cert returned by the responder is trusted if (x509Certs != null && x509Certs[0] != null) { diff -r db7b5a2b5b11 -r 5a2688a73184 src/share/native/sun/java2d/opengl/OGLBlitLoops.c --- a/src/share/native/sun/java2d/opengl/OGLBlitLoops.c Wed Aug 29 12:57:49 2012 +0100 +++ b/src/share/native/sun/java2d/opengl/OGLBlitLoops.c Wed Aug 29 13:24:58 2012 +0100 @@ -393,7 +393,16 @@ OGLSDOps *dstOps, jint dx1, jint dy1, jint dx2, jint dy2) { + jboolean adjustAlpha = (pf != NULL && !pf->hasAlpha); j2d_glBindTexture(dstOps->textureTarget, dstOps->textureID); + + if (adjustAlpha) { + // if the source surface does not have an alpha channel, + // we need to ensure that the alpha values are forced to 1.0f + j2d_glPixelTransferf(GL_ALPHA_SCALE, 0.0f); + j2d_glPixelTransferf(GL_ALPHA_BIAS, 1.0f); + } + // in case pixel stride is not a multiple of scanline stride the copy // has to be done line by line (see 6207877) if (srcInfo->scanStride % srcInfo->pixelStride != 0) { @@ -413,6 +422,11 @@ dx1, dy1, dx2-dx1, dy2-dy1, pf->format, pf->type, srcInfo->rasBase); } + if (adjustAlpha) { + // restore scale/bias to their original values + j2d_glPixelTransferf(GL_ALPHA_SCALE, 1.0f); + j2d_glPixelTransferf(GL_ALPHA_BIAS, 0.0f); + } } /** diff -r db7b5a2b5b11 -r 5a2688a73184 src/solaris/bin/java_md_solinux.c --- a/src/solaris/bin/java_md_solinux.c Wed Aug 29 12:57:49 2012 +0100 +++ b/src/solaris/bin/java_md_solinux.c Wed Aug 29 13:24:58 2012 +0100 @@ -982,7 +982,18 @@ int ContinueInNewThread0(int (JNICALL *continuation)(void *), jlong stack_size, void * args) { int rslt; -#ifdef __linux__ +#ifdef __solaris__ + thread_t tid; + long flags = 0; + if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) { + void * tmp; + thr_join(tid, NULL, &tmp); + rslt = (int)tmp; + } else { + /* See below. Continue in current thread if thr_create() failed */ + rslt = continuation(args); + } +#else /* ! __solaris__ */ pthread_t tid; pthread_attr_t attr; pthread_attr_init(&attr); @@ -1007,18 +1018,7 @@ } pthread_attr_destroy(&attr); -#else /* ! __linux__ */ - thread_t tid; - long flags = 0; - if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) { - void * tmp; - thr_join(tid, NULL, &tmp); - rslt = (int)tmp; - } else { - /* See above. Continue in current thread if thr_create() failed */ - rslt = continuation(args); - } -#endif /* __linux__ */ +#endif /* __solaris__ */ return rslt; } diff -r db7b5a2b5b11 -r 5a2688a73184 src/solaris/bin/java_md_solinux.h --- a/src/solaris/bin/java_md_solinux.h Wed Aug 29 12:57:49 2012 +0100 +++ b/src/solaris/bin/java_md_solinux.h Wed Aug 29 13:24:58 2012 +0100 @@ -54,10 +54,10 @@ #endif #include -#ifdef __linux__ +#ifdef __solaris__ +#include +#else #include -#else -#include #endif #define JVM_DLL "libjvm.so" diff -r db7b5a2b5b11 -r 5a2688a73184 src/solaris/classes/sun/awt/X11/XTextAreaPeer.java --- a/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/solaris/classes/sun/awt/X11/XTextAreaPeer.java Wed Aug 29 13:24:58 2012 +0100 @@ -464,13 +464,6 @@ protected boolean setTextImpl(String txt) { if (jtext != null) { - // Please note that we do not want to post an event - // if setText() replaces an empty text by an empty text, - // that is, if component's text remains unchanged. - if (jtext.getDocument().getLength() == 0 && txt.length() == 0) { - return true; - } - // JTextArea.setText() posts two different events (remove & insert). // Since we make no differences between text events, // the document listener has to be disabled while diff -r db7b5a2b5b11 -r 5a2688a73184 src/solaris/native/java/lang/java_props_md.c --- a/src/solaris/native/java/lang/java_props_md.c Wed Aug 29 12:57:49 2012 +0100 +++ b/src/solaris/native/java/lang/java_props_md.c Wed Aug 29 13:24:58 2012 +0100 @@ -403,6 +403,7 @@ PreferredToolkit prefToolkit = getPreferredToolkit(); switch (prefToolkit) { case CToolkit: + case HToolkit: sprops.graphics_env = "sun.awt.CGraphicsEnvironment"; break; case XToolkit: @@ -410,9 +411,6 @@ sprops.graphics_env = "sun.awt.X11GraphicsEnvironment"; #ifdef MACOSX break; - default: - sprops.graphics_env = "sun.java2d.HeadlessGraphicsEnvironment"; - break; } #endif /* AWT properties */ diff -r db7b5a2b5b11 -r 5a2688a73184 src/solaris/native/sun/nio/ch/DatagramDispatcher.c --- a/src/solaris/native/sun/nio/ch/DatagramDispatcher.c Wed Aug 29 12:57:49 2012 +0100 +++ b/src/solaris/native/sun/nio/ch/DatagramDispatcher.c Wed Aug 29 13:24:58 2012 +0100 @@ -36,6 +36,7 @@ #include #include "nio_util.h" +#include JNIEXPORT jint JNICALL Java_sun_nio_ch_DatagramDispatcher_read0(JNIEnv *env, jclass clazz, @@ -60,23 +61,14 @@ ssize_t result = 0; struct iovec *iov = (struct iovec *)jlong_to_ptr(address); struct msghdr m; - if (len > 16) { - len = 16; + if (len > IOV_MAX) { + len = IOV_MAX; } - m.msg_name = NULL; - m.msg_namelen = 0; + // initialize the message + memset(&m, 0, sizeof(m)); m.msg_iov = iov; m.msg_iovlen = len; -#ifdef __solaris__ - m.msg_accrights = NULL; - m.msg_accrightslen = 0; -#endif - -#if defined(__linux__) || defined(_ALLBSD_SOURCE) - m.msg_control = NULL; - m.msg_controllen = 0; -#endif result = recvmsg(fd, &m, 0); if (result < 0 && errno == ECONNREFUSED) { @@ -108,23 +100,14 @@ struct iovec *iov = (struct iovec *)jlong_to_ptr(address); struct msghdr m; ssize_t result = 0; - if (len > 16) { - len = 16; + if (len > IOV_MAX) { + len = IOV_MAX; } - m.msg_name = NULL; - m.msg_namelen = 0; + // initialize the message + memset(&m, 0, sizeof(m)); m.msg_iov = iov; m.msg_iovlen = len; -#ifdef __solaris__ - m.msg_accrights = NULL; - m.msg_accrightslen = 0; -#endif - -#if defined(__linux__) || defined(_ALLBSD_SOURCE) - m.msg_control = NULL; - m.msg_controllen = 0; -#endif result = sendmsg(fd, &m, 0); if (result < 0 && errno == ECONNREFUSED) { diff -r db7b5a2b5b11 -r 5a2688a73184 src/solaris/transport/socket/socket_md.c --- a/src/solaris/transport/socket/socket_md.c Wed Aug 29 12:57:49 2012 +0100 +++ b/src/solaris/transport/socket/socket_md.c Wed Aug 29 13:24:58 2012 +0100 @@ -35,8 +35,7 @@ #include #ifdef __solaris__ #include -#endif -#if defined(__linux__) || defined(_ALLBSD_SOURCE) +#else #include #include #endif @@ -306,9 +305,7 @@ return r; } -#endif - -#if defined(__linux__) || defined(_ALLBSD_SOURCE) +#else int dbgsysTlsAlloc() { pthread_key_t key; diff -r db7b5a2b5b11 -r 5a2688a73184 src/windows/classes/sun/awt/windows/WComponentPeer.java --- a/src/windows/classes/sun/awt/windows/WComponentPeer.java Wed Aug 29 12:57:49 2012 +0100 +++ b/src/windows/classes/sun/awt/windows/WComponentPeer.java Wed Aug 29 13:24:58 2012 +0100 @@ -419,8 +419,12 @@ public void createScreenSurface(boolean isResize) { Win32GraphicsConfig gc = (Win32GraphicsConfig)getGraphicsConfiguration(); + if (gc == null) { + surfaceData = null; + return; + } + ScreenUpdateManager mgr = ScreenUpdateManager.getInstance(); - surfaceData = mgr.createScreenSurface(gc, this, numBackBuffers, isResize); } diff -r db7b5a2b5b11 -r 5a2688a73184 src/windows/native/java/net/NetworkInterface.c --- a/src/windows/native/java/net/NetworkInterface.c Wed Aug 29 12:57:49 2012 +0100 +++ b/src/windows/native/java/net/NetworkInterface.c Wed Aug 29 13:24:58 2012 +0100 @@ -504,8 +504,7 @@ */ if (netaddrCount < 0) { netaddrCount = enumAddresses_win(env, ifs, &netaddrP); - if ((*env)->ExceptionOccurred(env)) { - free_netaddr(netaddrP); + if (netaddrCount == -1) { return NULL; } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/windows/native/java/net/NetworkInterface_winXP.c --- a/src/windows/native/java/net/NetworkInterface_winXP.c Wed Aug 29 12:57:49 2012 +0100 +++ b/src/windows/native/java/net/NetworkInterface_winXP.c Wed Aug 29 13:24:58 2012 +0100 @@ -194,8 +194,7 @@ while (curr != NULL) { netaddr *netaddrP; ret = enumAddresses_win(env, curr, &netaddrP); - if ((*env)->ExceptionOccurred(env)) { - free_netaddr(netaddrP); + if (ret == -1) { return -1; } curr->addrs = netaddrP; @@ -449,8 +448,7 @@ */ if (netaddrCount < 0) { netaddrCount = enumAddresses_win(env, ifs, &netaddrP); - if ((*env)->ExceptionOccurred(env)) { - free_netaddr(netaddrP); + if (netaddrCount == -1) { return NULL; } } diff -r db7b5a2b5b11 -r 5a2688a73184 src/windows/native/sun/windows/awt_Component.cpp --- a/src/windows/native/sun/windows/awt_Component.cpp Wed Aug 29 12:57:49 2012 +0100 +++ b/src/windows/native/sun/windows/awt_Component.cpp Wed Aug 29 13:24:58 2012 +0100 @@ -558,6 +558,8 @@ m_hwnd = hwnd; + ::ImmAssociateContext(m_hwnd, NULL); + SetDrawState((jint)JAWT_LOCK_SURFACE_CHANGED | (jint)JAWT_LOCK_BOUNDS_CHANGED | (jint)JAWT_LOCK_CLIP_CHANGED); diff -r db7b5a2b5b11 -r 5a2688a73184 src/windows/native/sun/windows/awt_TextArea.cpp --- a/src/windows/native/sun/windows/awt_TextArea.cpp Wed Aug 29 12:57:49 2012 +0100 +++ b/src/windows/native/sun/windows/awt_TextArea.cpp Wed Aug 29 13:24:58 2012 +0100 @@ -131,48 +131,13 @@ MsgRouting mr = mrDoDefault; switch (message) { - case WM_PRINTCLIENT: - { - FORMATRANGE fr; - HDC hPrinterDC = (HDC)wParam; - int nHorizRes = ::GetDeviceCaps(hPrinterDC, HORZRES); - int nVertRes = ::GetDeviceCaps(hPrinterDC, VERTRES); - int nLogPixelsX = ::GetDeviceCaps(hPrinterDC, LOGPIXELSX); - int nLogPixelsY = ::GetDeviceCaps(hPrinterDC, LOGPIXELSY); - - // Ensure the printer DC is in MM_TEXT mode. - ::SetMapMode ( hPrinterDC, MM_TEXT ); - - // Rendering to the same DC we are measuring. - ::ZeroMemory(&fr, sizeof(fr)); - fr.hdc = fr.hdcTarget = hPrinterDC; - // Set up the page. - fr.rcPage.left = fr.rcPage.top = 0; - fr.rcPage.right = (nHorizRes/nLogPixelsX) * 1440; // in twips - fr.rcPage.bottom = (nVertRes/nLogPixelsY) * 1440; - fr.rc.left = fr.rcPage.left; - fr.rc.top = fr.rcPage.top; - fr.rc.right = fr.rcPage.right; - fr.rc.bottom = fr.rcPage.bottom; - - // start printing from the first visible line - LRESULT nLine = SendMessage(EM_GETFIRSTVISIBLELINE, 0, 0); - LONG startCh = static_cast(SendMessage(EM_LINEINDEX, - (WPARAM)nLine, 0)); - fr.chrg.cpMin = startCh; - fr.chrg.cpMax = -1; - - SendMessage(EM_FORMATRANGE, TRUE, (LPARAM)&fr); - } - - break; case EM_SETCHARFORMAT: case WM_SETFONT: SetIgnoreEnChange(TRUE); break; } - retValue = AwtComponent::WindowProc(message, wParam, lParam); + retValue = AwtTextComponent::WindowProc(message, wParam, lParam); switch (message) { case EM_SETCHARFORMAT: diff -r db7b5a2b5b11 -r 5a2688a73184 src/windows/native/sun/windows/awt_TextComponent.cpp --- a/src/windows/native/sun/windows/awt_TextComponent.cpp Wed Aug 29 12:57:49 2012 +0100 +++ b/src/windows/native/sun/windows/awt_TextComponent.cpp Wed Aug 29 13:24:58 2012 +0100 @@ -215,6 +215,50 @@ return c; } +LRESULT +AwtTextComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { + + switch (message) { + case WM_PRINTCLIENT: + { + FORMATRANGE fr; + HDC hPrinterDC = (HDC)wParam; + int nHorizRes = ::GetDeviceCaps(hPrinterDC, HORZRES); + int nVertRes = ::GetDeviceCaps(hPrinterDC, VERTRES); + int nLogPixelsX = ::GetDeviceCaps(hPrinterDC, LOGPIXELSX); + int nLogPixelsY = ::GetDeviceCaps(hPrinterDC, LOGPIXELSY); + + // Ensure the printer DC is in MM_TEXT mode. + ::SetMapMode ( hPrinterDC, MM_TEXT ); + + // Rendering to the same DC we are measuring. + ::ZeroMemory(&fr, sizeof(fr)); + fr.hdc = fr.hdcTarget = hPrinterDC; + // Set up the page. + fr.rcPage.left = fr.rcPage.top = 0; + fr.rcPage.right = (nHorizRes/nLogPixelsX) * 1440; // in twips + fr.rcPage.bottom = (nVertRes/nLogPixelsY) * 1440; + fr.rc.left = fr.rcPage.left; + fr.rc.top = fr.rcPage.top; + fr.rc.right = fr.rcPage.right; + fr.rc.bottom = fr.rcPage.bottom; + + // start printing from the first visible line + LRESULT nLine = SendMessage(EM_GETFIRSTVISIBLELINE, 0, 0); + LONG startCh = static_cast(SendMessage(EM_LINEINDEX, + (WPARAM)nLine, 0)); + fr.chrg.cpMin = startCh; + fr.chrg.cpMax = -1; + + SendMessage(EM_FORMATRANGE, TRUE, (LPARAM)&fr); + } + + break; + } + + return AwtComponent::WindowProc(message, wParam, lParam); +} + LONG AwtTextComponent::EditGetCharFromPos(POINT& pt) { return static_cast(SendMessage(EM_CHARFROMPOS, 0, reinterpret_cast(&pt))); diff -r db7b5a2b5b11 -r 5a2688a73184 src/windows/native/sun/windows/awt_TextComponent.h --- a/src/windows/native/sun/windows/awt_TextComponent.h Wed Aug 29 12:57:49 2012 +0100 +++ b/src/windows/native/sun/windows/awt_TextComponent.h Wed Aug 29 13:24:58 2012 +0100 @@ -50,6 +50,7 @@ static AwtTextComponent* Create(jobject self, jobject parent, BOOL isMultiline); virtual LPCTSTR GetClassName(); + LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); int RemoveCR(WCHAR *pStr); diff -r db7b5a2b5b11 -r 5a2688a73184 test/java/awt/Focus/OverrideRedirectWindowActivationTest/OverrideRedirectWindowActivationTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Focus/OverrideRedirectWindowActivationTest/OverrideRedirectWindowActivationTest.java Wed Aug 29 13:24:58 2012 +0100 @@ -0,0 +1,157 @@ +/* + * 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 6385277 + * @summary Tests that override redirect window gets activated on click. + * @author anton.tarasov@sun.com: area=awt.focus + * @library ../../regtesthelpers + * @build Util + * @run main OverrideRedirectWindowActivationTest + */ +import java.awt.*; +import java.awt.event.*; +import java.util.concurrent.Callable; +import javax.swing.SwingUtilities; +import sun.awt.SunToolkit; +import test.java.awt.regtesthelpers.Util; + +public class OverrideRedirectWindowActivationTest { + + private static Frame frame; + private static Window window; + private static Button fbutton; + private static Button wbutton; + private static Label label; + private static Robot robot; + private static SunToolkit toolkit; + + public static void main(String[] args) throws Exception { + + if ("sun.awt.motif.MToolkit".equals(Toolkit.getDefaultToolkit().getClass().getName())) { + System.out.println("No testing on Motif. Test passed."); + return; + } + + toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + robot = new Robot(); + robot.setAutoDelay(50); + + Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { + + public void eventDispatched(AWTEvent e) { + System.out.println(e); + } + }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK); + + createAndShowWindow(); + toolkit.realSync(); + + createAndShowFrame(); + toolkit.realSync(); + + // click on Frame + clickOn(getClickPoint(frame)); + + if (!frame.isFocused()) { + throw new RuntimeException("Error: a frame couldn't be focused by click."); + } + + //click on Label in Window + clickOn(getClickPoint(label)); + + if (!window.isFocused()) { + throw new RuntimeException("Test failed: the window couldn't be activated by click!"); + } + + // bring focus back to the frame + clickOn(getClickPoint(fbutton)); + + if (!frame.isFocused()) { + throw new RuntimeException("Error: a frame couldn't be focused by click."); + } + + // Test 2. Verifies that clicking on a component of unfocusable Window + // won't activate it. + + window.setFocusableWindowState(false); + toolkit.realSync(); + + + clickOn(getClickPoint(label)); + + if (window.isFocused()) { + throw new RuntimeException("Test failed: unfocusable window got activated by click!"); + } + System.out.println("Test passed."); + + } + + private static void createAndShowWindow() { + + frame = new Frame("Test Frame"); + window = new Window(frame); + wbutton = new Button("wbutton"); + label = new Label("label"); + + window.setBounds(800, 200, 200, 100); + window.setLayout(new FlowLayout()); + window.add(wbutton); + window.add(label); + window.setVisible(true); + + } + + private static void createAndShowFrame() { + fbutton = new Button("fbutton"); + + frame.setBounds(800, 0, 200, 100); + frame.setLayout(new FlowLayout()); + frame.add(fbutton); + frame.setVisible(true); + + } + + static void clickOn(Point point) { + + robot.mouseMove(point.x, point.y); + + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + toolkit.realSync(); + } + + static Point getClickPoint(Component c) { + Point p = c.getLocationOnScreen(); + Dimension d = c.getSize(); + return new Point(p.x + (int) (d.getWidth() / 2), p.y + (int) (d.getHeight() / 2)); + } + + static Point getClickPoint(Frame frame) { + Point p = frame.getLocationOnScreen(); + Dimension d = frame.getSize(); + return new Point(p.x + (int) (d.getWidth() / 2), p.y + (frame.getInsets().top / 2)); + } +} diff -r db7b5a2b5b11 -r 5a2688a73184 test/java/awt/Window/Grab/GrabTest.java --- a/test/java/awt/Window/Grab/GrabTest.java Wed Aug 29 12:57:49 2012 +0100 +++ b/test/java/awt/Window/Grab/GrabTest.java Wed Aug 29 13:24:58 2012 +0100 @@ -65,7 +65,7 @@ }, sun.awt.SunToolkit.GRAB_EVENT_MASK); f = new Frame("Frame"); - f.setSize(200, 200); + f.setBounds(0, 0, 300, 300); f.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { System.out.println(e); @@ -74,7 +74,7 @@ }); f1 = new Frame("OtherFrame"); - f1.setBounds(600, 100, 200, 200); + f1.setBounds(700, 100, 200, 200); w = new Window(f); w.setLayout(new FlowLayout()); @@ -86,7 +86,7 @@ } }); w.add(b); - w.setBounds(300, 100, 200, 200); + w.setBounds(400, 100, 200, 200); w.setBackground(Color.blue); w.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { @@ -175,7 +175,8 @@ // 6. Check that press on the outside area causes ungrab Point loc = f.getLocationOnScreen(); - robot.mouseMove(loc.x + 100, loc.y + f.getSize().height + 300); + robot.mouseMove(loc.x + 100, loc.y + f.getSize().height + 1); + Util.waitForIdle(robot); robot.mousePress(InputEvent.BUTTON1_MASK); robot.delay(50); robot.mouseRelease(InputEvent.BUTTON1_MASK); diff -r db7b5a2b5b11 -r 5a2688a73184 test/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/event/TextEvent/TextEventSequenceTest/TextEventSequenceTest.java Wed Aug 29 13:24:58 2012 +0100 @@ -0,0 +1,138 @@ +/* + * 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 4028580 + * @summary TextArea does not send TextEvent when setText. Does for insert + * @author kdm@sparc.spb.su: area= awt.TextAvent + * @run main TextEventSequenceTest + */ +import java.awt.*; +import java.awt.event.*; +import sun.awt.SunToolkit; + +public class TextEventSequenceTest { + + private static Frame f; + private static TextField tf; + private static TextArea t; + private static int cntEmptyStrings = 0; + private static int cntNonEmptyStrings = 0; + + public static void main(String[] args) { + + test("non-empty text string"); + test(""); + test(null); + } + + private static void test(String test) { + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + createAndShowGUI(test); + toolkit.realSync(); + + initCounts(); + t.setText("Hello "); + toolkit.realSync(); + t.append("World! !"); + toolkit.realSync(); + t.insert("from Roger Pham", 13); + toolkit.realSync(); + t.replaceRange("Java Duke", 18, 28); + toolkit.realSync(); + checkCounts(0, 4); + + initCounts(); + t.setText(""); + toolkit.realSync(); + t.setText(""); + toolkit.realSync(); + t.setText(""); + toolkit.realSync(); + checkCounts(1, 0); + + initCounts(); + tf.setText("Hello There!"); + toolkit.realSync(); + checkCounts(0, 1); + + initCounts(); + tf.setText(""); + toolkit.realSync(); + tf.setText(""); + toolkit.realSync(); + tf.setText(""); + toolkit.realSync(); + checkCounts(1, 0); + + f.dispose(); + } + + private static void createAndShowGUI(String text) { + f = new Frame("TextEventSequenceTest"); + f.setLayout(new FlowLayout()); + + TextListener listener = new MyTextListener(); + + tf = new TextField(text); + tf.addTextListener(listener); + f.add(tf); + + t = new TextArea(text, 10, 30); + t.addTextListener(listener); + f.add(t); + + f.pack(); + f.setVisible(true); + } + + static class MyTextListener implements TextListener { + + public synchronized void textValueChanged(TextEvent e) { + TextComponent tc = (TextComponent) e.getSource(); + String text = tc.getText(); + if (text.length() == 0) { + cntEmptyStrings++; + } else { + cntNonEmptyStrings++; + } + } + } + + synchronized static void initCounts() { + cntEmptyStrings = 0; + cntNonEmptyStrings = 0; + } + + synchronized static void checkCounts(int empty, int nonempty) { + if (empty != cntEmptyStrings || nonempty != cntNonEmptyStrings) { + throw new RuntimeException( + String.format("Expected events: empty = %d, nonempty = %d, " + + "actual events: empty = %d, nonempty = %d", + empty, nonempty, cntEmptyStrings, cntNonEmptyStrings)); + } + } +} + diff -r db7b5a2b5b11 -r 5a2688a73184 test/java/beans/Performance/Test7122740.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/beans/Performance/Test7122740.java Wed Aug 29 13:24:58 2012 +0100 @@ -0,0 +1,57 @@ +/* + * 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 7122740 + * @summary Tests just a benchmark of PropertyDescriptor(String, Class) performance + * @author Sergey Malenkov + * @run main/manual Test7122740 + */ + +import java.beans.PropertyDescriptor; + +public class Test7122740 { + public static void main(String[] args) throws Exception { + long time = System.nanoTime(); + for (int i = 0; i < 1000; i++) { + new PropertyDescriptor("name", PropertyDescriptor.class); + new PropertyDescriptor("value", Concrete.class); + } + time -= System.nanoTime(); + System.out.println("Time (ms): " + (-time / 1000000)); + } + + public static class Abstract { + private T value; + public T getValue() { + return this.value; + } + public void setValue(T value) { + this.value = value; + } + } + + private static class Concrete extends Abstract { + } +} diff -r db7b5a2b5b11 -r 5a2688a73184 test/java/beans/Performance/Test7184799.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/beans/Performance/Test7184799.java Wed Aug 29 13:24:58 2012 +0100 @@ -0,0 +1,71 @@ +/* + * 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 7184799 + * @summary Tests just a benchmark of Introspector.getBeanInfo(Class) performance + * @author Sergey Malenkov + * @run main/manual Test7184799 + */ + +import java.beans.Introspector; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; + +public class Test7184799 { + private static final Class[] TYPES = { + Class.class, + String.class, + Character.class, + Boolean.class, + Byte.class, + Short.class, + Integer.class, + Long.class, + Float.class, + Double.class, + Collection.class, + Set.class, + HashSet.class, + TreeSet.class, + LinkedHashSet.class, + Map.class, + HashMap.class, + TreeMap.class, + LinkedHashMap.class, + WeakHashMap.class, + ConcurrentHashMap.class, + Dictionary.class, + Exception.class, + }; + + public static void main(String[] args) throws Exception { + long time = System.nanoTime(); + for (Class type : TYPES) { + Introspector.getBeanInfo(type); + } + time -= System.nanoTime(); + System.out.println("Time (ms): " + (-time / 1000000)); + } +} diff -r db7b5a2b5b11 -r 5a2688a73184 test/java/net/HttpCookie/IllegalCookieNameTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/net/HttpCookie/IllegalCookieNameTest.java Wed Aug 29 13:24:58 2012 +0100 @@ -0,0 +1,74 @@ +/* + * 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 7183292 + */ +import java.net.*; +import java.util.*; +import java.io.*; +import com.sun.net.httpserver.*; + +public class IllegalCookieNameTest { + public static void main(String[] args) throws IOException { + HttpServer s = null; + try { + InetSocketAddress addr = new InetSocketAddress(0); + s = HttpServer.create(addr, 10); + s.createContext("/", new HHandler()); + s.start(); + String u = "http://127.0.0.1:" + s.getAddress().getPort() + "/"; + CookieHandler.setDefault(new TestCookieHandler()); + URL url = new URL(u); + HttpURLConnection c = (HttpURLConnection) url.openConnection(); + c.getHeaderFields(); + System.out.println ("OK"); + } finally { + s.stop(1); + } + } +} + +class TestCookieHandler extends CookieHandler { + @Override + public Map> get(URI uri, Map> requestHeaders) { + return new HashMap>(); + } + + @Override + public void put(URI uri, Map> responseHeaders) { + } +} + +class HHandler implements HttpHandler { + public void handle (HttpExchange e) { + try { + Headers h = e.getResponseHeaders(); + h.set ("Set-Cookie", "domain=; expires=Mon, 01-Jan-1990 00:00:00 GMT; path=/; domain=.foo.com"); + e.sendResponseHeaders(200, -1); + e.close(); + } catch (Exception ex) { + System.out.println (ex); + } + } +} diff -r db7b5a2b5b11 -r 5a2688a73184 test/javax/swing/JComponent/7154030/bug7154030.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/JComponent/7154030/bug7154030.java Wed Aug 29 13:24:58 2012 +0100 @@ -0,0 +1,169 @@ +/* + * 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 + */ + +import javax.swing.JButton; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import sun.awt.SunToolkit; + +import java.awt.AWTException; +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.image.BufferedImage; + +/* @test 1.1 2012/04/12 + * @bug 7154030 + * @summary Swing components fail to hide after calling hide() + * @author Jonathan Lu + * @library ../../regtesthelpers/ + * @build Util + * @run main bug7154030 + */ + +public class bug7154030 { + + private static JButton button = null; + + public static void main(String[] args) throws Exception { + BufferedImage imageInit = null; + + BufferedImage imageShow = null; + + BufferedImage imageHide = null; + + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + Robot robot = new Robot(); + + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + JDesktopPane desktop = new JDesktopPane(); + button = new JButton("button"); + JFrame frame = new JFrame(); + + button.setSize(200, 200); + button.setLocation(100, 100); + button.setForeground(Color.RED); + button.setBackground(Color.RED); + button.setOpaque(true); + button.setVisible(false); + desktop.add(button); + + frame.setContentPane(desktop); + frame.setSize(300, 300); + frame.setLocation(0, 0); + frame.setVisible(true); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + } + }); + + toolkit.realSync(); + imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300)); + + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + button.show(); + } + }); + + toolkit.realSync(); + imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300)); + if (Util.compareBufferedImages(imageInit, imageShow)) { + throw new Exception("Failed to show opaque button"); + } + + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + button.hide(); + } + }); + + toolkit.realSync(); + imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300)); + + if (!Util.compareBufferedImages(imageInit, imageHide)) { + throw new Exception("Failed to hide opaque button"); + } + + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + button.setOpaque(false); + button.setBackground(new Color(128, 128, 0)); + button.setVisible(false); + } + }); + + toolkit.realSync(); + imageInit = robot.createScreenCapture(new Rectangle(0, 0, 300, 300)); + + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + button.show(); + } + }); + + toolkit.realSync(); + imageShow = robot.createScreenCapture(new Rectangle(0, 0, 300, 300)); + + SwingUtilities.invokeAndWait(new Runnable() { + + @Override + public void run() { + button.hide(); + } + }); + + if (Util.compareBufferedImages(imageInit, imageShow)) { + throw new Exception("Failed to show non-opaque button"); + } + + toolkit.realSync(); + imageHide = robot.createScreenCapture(new Rectangle(0, 0, 300, 300)); + + if (!Util.compareBufferedImages(imageInit, imageHide)) { + throw new Exception("Failed to hide non-opaque button"); + } + } +} diff -r db7b5a2b5b11 -r 5a2688a73184 test/javax/swing/SwingUtilities/7170657/bug7170657.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/SwingUtilities/7170657/bug7170657.java Wed Aug 29 13:24:58 2012 +0100 @@ -0,0 +1,78 @@ +/* + * 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. + */ + +import java.awt.Frame; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseWheelEvent; + +import javax.swing.SwingUtilities; +import javax.swing.event.MenuDragMouseEvent; + +/** + * @test + * @bug 7170657 + * @author Sergey Bylokhov + */ +public final class bug7170657 { + + private static boolean FAILED; + + public static void main(final String[] args) { + final int mask = InputEvent.META_DOWN_MASK | InputEvent.CTRL_MASK; + + Frame f = new Frame(); + + MouseEvent mwe = new MouseWheelEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true, + 1, 1, 1); + MouseEvent mdme = new MenuDragMouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, + true, null, null); + MouseEvent me = new MouseEvent(f, 1, 1, mask, 1, 1, 1, 1, 1, true, + MouseEvent.NOBUTTON); + + test(f, mwe); + test(f, mdme); + test(f, me); + + if (FAILED) { + throw new RuntimeException("Wrong mouse event"); + } + } + + + private static void test(final Frame frame, final MouseEvent me) { + MouseEvent newme = SwingUtilities.convertMouseEvent(frame, me, frame); + if (me.getModifiersEx() != newme.getModifiersEx() + || me.getModifiers() != newme.getModifiers()) { + fail(me, newme); + } + } + + private static void fail(final MouseEvent exp, final MouseEvent act) { + System.err.println("Expected: " + exp); + System.err.println("Actual: " + act); + FAILED = true; + } +} diff -r db7b5a2b5b11 -r 5a2688a73184 test/sun/java2d/OpenGL/bug7181438.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/java2d/OpenGL/bug7181438.java Wed Aug 29 13:24:58 2012 +0100 @@ -0,0 +1,83 @@ +/* + * 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. + */ + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.Transparency; +import java.awt.image.BufferedImage; +import java.awt.image.VolatileImage; + +/** + * @test + * @bug 7181438 + * @summary Verifies that we get correct alpha, when we draw opaque + * BufferedImage to non opaque VolatileImage via intermediate opaque texture. + * @author Sergey Bylokhov + * @run main/othervm -Dsun.java2d.accthreshold=0 bug7181438 + */ +public final class bug7181438 { + + private static final int SIZE = 500; + + public static void main(final String[] args) { + + final BufferedImage bi = createBufferedImage(); + final VolatileImage vi = createVolatileImage(); + final Graphics s2dVi = vi.getGraphics(); + + //sw->texture->surface blit + s2dVi.drawImage(bi, 0, 0, null); + + final BufferedImage results = vi.getSnapshot(); + for (int i = 0; i < SIZE; ++i) { + for (int j = 0; j < SIZE; ++j) { + //Image should be opaque: (black color and alpha = 255) + if (results.getRGB(i, j) != 0xFF000000) { + throw new RuntimeException("Failed: Wrong alpha"); + } + } + } + System.out.println("Passed"); + } + + + private static VolatileImage createVolatileImage() { + final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + final GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration(); + return gc.createCompatibleVolatileImage(SIZE, SIZE, + Transparency.TRANSLUCENT); + } + + private static BufferedImage createBufferedImage() { + final BufferedImage bi = new BufferedImage(SIZE, SIZE, + BufferedImage.TYPE_INT_RGB); + final Graphics bg = bi.getGraphics(); + //Black color and alpha = 0 + bg.setColor(new Color(0, 0, 0, 0)); + bg.fillRect(0, 0, SIZE, SIZE); + bg.dispose(); + return bi; + } +} diff -r db7b5a2b5b11 -r 5a2688a73184 test/sun/security/x509/AlgorithmId/NonStandardNames.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/security/x509/AlgorithmId/NonStandardNames.java Wed Aug 29 13:24:58 2012 +0100 @@ -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 7180907 + * @summary Jarsigner -verify fails if rsa file used sha-256 with authenticated attributes + */ + +import java.security.MessageDigest; +import java.security.Signature; +import java.security.cert.X509Certificate; +import sun.security.pkcs.ContentInfo; +import sun.security.pkcs.PKCS7; +import sun.security.pkcs.PKCS9Attribute; +import sun.security.pkcs.PKCS9Attributes; +import sun.security.pkcs.SignerInfo; +import sun.security.x509.CertAndKeyGen; +import sun.security.x509.AlgorithmId; +import sun.security.x509.X500Name; + +public class NonStandardNames { + + public static void main(String[] args) throws Exception { + + byte[] data = "Hello".getBytes(); + X500Name n = new X500Name("cn=Me"); + + CertAndKeyGen cakg = new CertAndKeyGen("RSA", "SHA256withRSA"); + cakg.generate(1024); + X509Certificate cert = cakg.getSelfCertificate(n, 1000); + + MessageDigest md = MessageDigest.getInstance("SHA-256"); + PKCS9Attributes authed = new PKCS9Attributes(new PKCS9Attribute[]{ + new PKCS9Attribute(PKCS9Attribute.CONTENT_TYPE_OID, ContentInfo.DATA_OID), + new PKCS9Attribute(PKCS9Attribute.MESSAGE_DIGEST_OID, md.digest(data)), + }); + + Signature s = Signature.getInstance("SHA256withRSA"); + s.initSign(cakg.getPrivateKey()); + s.update(authed.getDerEncoding()); + byte[] sig = s.sign(); + + SignerInfo signerInfo = new SignerInfo( + n, + cert.getSerialNumber(), + AlgorithmId.get("SHA-256"), + authed, + AlgorithmId.get("SHA256withRSA"), + sig, + null + ); + + PKCS7 pkcs7 = new PKCS7( + new AlgorithmId[] {signerInfo.getDigestAlgorithmId()}, + new ContentInfo(data), + new X509Certificate[] {cert}, + new SignerInfo[] {signerInfo}); + + if (pkcs7.verify(signerInfo, data) == null) { + throw new Exception("Not verified"); + } + } +}