changeset 9629:fe7704d1b87b

Merge
author chegar
date Fri, 30 May 2014 14:54:57 +0100
parents f54dfd95979b ab026f1b2f28
children 91975f822db8
files
diffstat 12 files changed, 348 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/classes/com/apple/laf/AquaComboBoxPopup.java	Fri May 23 16:35:10 2014 +0200
+++ b/src/macosx/classes/com/apple/laf/AquaComboBoxPopup.java	Fri May 30 14:54:57 2014 +0100
@@ -120,6 +120,10 @@
     public void show() {
         final int startItemCount = comboBox.getItemCount();
 
+        if (startItemCount == 0) {
+            return;
+        }
+
         final Rectangle popupBounds = adjustPopupAndGetBounds();
         if (popupBounds == null) return; // null means don't show
 
--- a/src/macosx/classes/sun/lwawt/LWChoicePeer.java	Fri May 23 16:35:10 2014 +0200
+++ b/src/macosx/classes/sun/lwawt/LWChoicePeer.java	Fri May 30 14:54:57 2014 +0100
@@ -171,7 +171,9 @@
             SwingUtilities.invokeLater(() -> {
                 JPopupMenu popupMenu = getPopupMenu();
                 // Need to override the invoker for proper grab handling
-                if (popupMenu != null && popupMenu.getInvoker() != getTarget()) {
+                if (popupMenu != null
+                        && popupMenu.isShowing()
+                        && popupMenu.getInvoker() != getTarget()) {
                     // The popup is now visible with correct location
                     // Save it and restore after toggling visibility and changing invoker
                     Point loc = popupMenu.getLocationOnScreen();
--- a/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java	Fri May 23 16:35:10 2014 +0200
+++ b/src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java	Fri May 30 14:54:57 2014 +0100
@@ -806,9 +806,8 @@
 
         // Paint the background for the tab area
         if ( tabPane.isOpaque() ) {
-            Color bg = UIManager.getColor("TabbedPane.tabAreaBackground");
-            if (bg != null) {
-                g.setColor(bg);
+            if (!c.isBackgroundSet() && (tabAreaBackground != null)) {
+                g.setColor(tabAreaBackground);
             }
             else {
                 g.setColor( c.getBackground() );
--- a/src/share/classes/sun/awt/image/FileImageSource.java	Fri May 23 16:35:10 2014 +0200
+++ b/src/share/classes/sun/awt/image/FileImageSource.java	Fri May 30 14:54:57 2014 +0100
@@ -48,6 +48,10 @@
     }
 
     protected ImageDecoder getDecoder() {
+        if (imagefile == null) {
+            return null;
+        }
+
         InputStream is;
         try {
             is = new BufferedInputStream(new FileInputStream(imagefile));
--- a/src/solaris/classes/sun/awt/X11/XFramePeer.java	Fri May 23 16:35:10 2014 +0200
+++ b/src/solaris/classes/sun/awt/X11/XFramePeer.java	Fri May 30 14:54:57 2014 +0100
@@ -284,6 +284,11 @@
             if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
                 stateLog.finer("DeIconifying " + this);
             }
+
+            XNETProtocol net_protocol = XWM.getWM().getNETProtocol();
+            if (net_protocol != null) {
+                net_protocol.setActiveWindow(this);
+            }
             xSetVisible(true);
         }
     }
--- a/src/solaris/classes/sun/awt/X11/XNETProtocol.java	Fri May 23 16:35:10 2014 +0200
+++ b/src/solaris/classes/sun/awt/X11/XNETProtocol.java	Fri May 30 14:54:57 2014 +0100
@@ -213,7 +213,7 @@
      * If window is showing then it uses ClientMessage, otherwise adjusts NET_WM_STATE list
      * @param window Window which NET_WM_STATE property is being modified
      * @param state State atom to be set/reset
-     * @param reset Indicates operation, 'set' if false, 'reset' if true
+     * @param set Indicates operation, 'set' if false, 'reset' if true
      */
     private void setStateHelper(XWindowPeer window, XAtom state, boolean set) {
         if (log.isLoggable(PlatformLogger.Level.FINER)) {
@@ -249,6 +249,7 @@
     XAtom XA_UTF8_STRING = XAtom.get("UTF8_STRING");   /* like STRING but encoding is UTF-8 */
     XAtom XA_NET_SUPPORTING_WM_CHECK = XAtom.get("_NET_SUPPORTING_WM_CHECK");
     XAtom XA_NET_SUPPORTED = XAtom.get("_NET_SUPPORTED");      /* list of protocols (property of root) */
+    XAtom XA_NET_ACTIVE_WINDOW = XAtom.get("_NET_ACTIVE_WINDOW");
     XAtom XA_NET_WM_NAME = XAtom.get("_NET_WM_NAME");  /* window property */
     XAtom XA_NET_WM_STATE = XAtom.get("_NET_WM_STATE");/* both window property and request */
 
@@ -325,6 +326,32 @@
         return res;
     }
 
+    public void setActiveWindow(XWindow window) {
+        if (!active() || !checkProtocol(XA_NET_SUPPORTED, XA_NET_ACTIVE_WINDOW)) {
+            return;
+        }
+
+        XClientMessageEvent msg = new XClientMessageEvent();
+        msg.zero();
+        msg.set_type(XConstants.ClientMessage);
+        msg.set_message_type(XA_NET_ACTIVE_WINDOW.getAtom());
+        msg.set_display(XToolkit.getDisplay());
+        msg.set_window(window.getWindow());
+        msg.set_format(32);
+        msg.set_data(0, 1);
+        msg.set_data(1, XToolkit.getCurrentServerTime());
+        msg.set_data(2, 0);
+
+        XToolkit.awtLock();
+        try {
+            XlibWrapper.XSendEvent(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), false,
+                    XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask, msg.getPData());
+        } finally {
+            XToolkit.awtUnlock();
+            msg.dispose();
+        }
+    }
+
     boolean isWMName(String name) {
         if (!active()) {
             return false;
--- a/src/windows/native/java/io/io_util_md.c	Fri May 23 16:35:10 2014 +0200
+++ b/src/windows/native/java/io/io_util_md.c	Fri May 30 14:54:57 2014 +0100
@@ -161,10 +161,17 @@
             {
                  if (pathlen > max_path - 1) {
                      pathbuf = prefixAbpath(ps, pathlen, pathlen);
+                     if (pathbuf == NULL) {
+                         JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+                         return NULL;
+                     }
                  } else {
                      pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
                      if (pathbuf != 0) {
                          wcscpy(pathbuf, ps);
+                     } else {
+                         JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+                         return NULL;
                      }
                  }
             } else {
@@ -184,10 +191,17 @@
                 int dirlen = currentDirLength(ps, pathlen);
                 if (dirlen + pathlen + 1 > max_path - 1) {
                     pathbuf = prefixAbpath(ps, pathlen, dirlen + pathlen);
+                    if( pathbuf == NULL) {
+                        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+                        return NULL;
+                    }
                 } else {
                     pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
                     if (pathbuf != 0) {
                         wcscpy(pathbuf, ps);
+                    } else {
+                        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+                        return NULL;
                     }
                 }
             }
@@ -196,7 +210,9 @@
 
     if (pathlen == 0) {
         if (throwFNFE == JNI_TRUE) {
-            throwFileNotFoundException(env, path);
+            if (!(*env)->ExceptionCheck(env)) {
+                throwFileNotFoundException(env, path);
+            }
             return NULL;
         } else {
             pathbuf = (WCHAR*)malloc(sizeof(WCHAR));
@@ -204,7 +220,9 @@
         }
     }
     if (pathbuf == 0) {
-        JNU_ThrowOutOfMemoryError(env, 0);
+        if (!(*env)->ExceptionCheck(env)) {
+            JNU_ThrowOutOfMemoryError(env,  "native memory allocation failed");
+        }
         return NULL;
     }
     return pathbuf;
--- a/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c	Fri May 23 16:35:10 2014 +0200
+++ b/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c	Fri May 30 14:54:57 2014 +0100
@@ -39,6 +39,7 @@
 #define STS_NO_CONFIG       0x0             /* no configuration found */
 #define STS_SL_FOUND        0x1             /* search list found */
 #define STS_NS_FOUND        0x2             /* name servers found */
+#define STS_ERROR           -1              /* error return  lodConfig failed memory allccation failure*/
 
 #define IS_SL_FOUND(sts)    (sts & STS_SL_FOUND)
 #define IS_NS_FOUND(sts)    (sts & STS_NS_FOUND)
@@ -123,14 +124,14 @@
     size = sizeof(IP_ADAPTER_INFO);
     adapterP = (IP_ADAPTER_INFO *)malloc(size);
     if (adapterP == NULL) {
-        return -1;
+        return STS_ERROR;
     }
     ret = GetAdaptersInfo(adapterP, &size);
     if (ret == ERROR_BUFFER_OVERFLOW) {
         IP_ADAPTER_INFO *newAdapterP = (IP_ADAPTER_INFO *)realloc(adapterP, size);
         if (newAdapterP == NULL) {
             free(adapterP);
-            return -1;
+            return STS_ERROR;
         }
         adapterP = newAdapterP;
 
@@ -239,6 +240,7 @@
 {
     searchlistID = (*env)->GetStaticFieldID(env, cls, "os_searchlist",
                                       "Ljava/lang/String;");
+    CHECK_NULL(searchlistID);
     nameserversID = (*env)->GetStaticFieldID(env, cls, "os_nameservers",
                                       "Ljava/lang/String;");
 }
@@ -258,16 +260,21 @@
     searchlist[0] = '\0';
     nameservers[0] = '\0';
 
-    loadConfig(searchlist, nameservers);
+    if (loadConfig(searchlist, nameservers) != STS_ERROR) {
 
-    /*
-     * Populate static fields in sun.net.DefaultResolverConfiguration
-     */
-    obj = (*env)->NewStringUTF(env, searchlist);
-    (*env)->SetStaticObjectField(env, cls, searchlistID, obj);
+        /*
+         * Populate static fields in sun.net.DefaultResolverConfiguration
+         */
+        obj = (*env)->NewStringUTF(env, searchlist);
+        CHECK_NULL(obj);
+        (*env)->SetStaticObjectField(env, cls, searchlistID, obj);
 
-    obj = (*env)->NewStringUTF(env, nameservers);
-    (*env)->SetStaticObjectField(env, cls, nameserversID, obj);
+        obj = (*env)->NewStringUTF(env, nameservers);
+        CHECK_NULL(obj);
+        (*env)->SetStaticObjectField(env, cls, nameserversID, obj);
+    } else {
+        JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
+    }
 }
 
 
--- a/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c	Fri May 23 16:35:10 2014 +0200
+++ b/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c	Fri May 30 14:54:57 2014 +0100
@@ -1118,11 +1118,13 @@
                     JNU_ThrowInternalError(env, "GetFullPathNameW failed");
                 }
                 free(lpBuf);
+            } else {
+                JNU_ThrowOutOfMemoryError(env, "native memory allocation failure");
             }
         }
+    } else {
+        throwWindowsException(env, GetLastError());
     }
-    if (len == 0)
-        throwWindowsException(env, GetLastError());
 
     return rv;
 }
@@ -1157,13 +1159,13 @@
                     JNU_ThrowInternalError(env, "GetFinalPathNameByHandleW failed");
                 }
                 free(lpBuf);
+            } else {
+                JNU_ThrowOutOfMemoryError(env, "native memory allocation failure");
             }
         }
+    } else {
+        throwWindowsException(env, GetLastError());
     }
-
-    if (len == 0)
-        throwWindowsException(env, GetLastError());
-
     return rv;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Choice/RemoveAllShrinkTest/RemoveAllShrinkTest.java	Fri May 30 14:54:57 2014 +0100
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4851798 8041896
+  @summary Tests Choice List shrinks after removeAll
+  @run main RemoveAllShrinkTest
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+
+
+public class RemoveAllShrinkTest {
+
+    public static void main(String[] args) {
+        Frame f = new Frame();
+        Choice choice = new Choice();
+
+        for (int i = 0; i < 10; ++i) {
+            choice.addItem("Item " + i);
+        }
+
+        f.add(choice, BorderLayout.NORTH);
+        Panel panel = new Panel();
+        panel.setBackground(Color.RED);
+        f.add(panel);
+
+        f.setSize(200, 200);
+        f.setVisible(true);
+        f.toFront();
+
+        choice.removeAll();
+
+        try {
+            Robot robot = new Robot();
+            robot.setAutoWaitForIdle(true);
+            robot.setAutoDelay(50);
+
+            robot.waitForIdle();
+            Thread.sleep(200);
+
+            Point pt = choice.getLocationOnScreen();
+            robot.mouseMove(pt.x + choice.getWidth() - choice.getHeight() / 2,
+                    pt.y + choice.getHeight() / 2);
+            robot.mousePress(InputEvent.BUTTON1_MASK);
+            robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+            Thread.sleep(400);
+
+            Point pt1 = panel.getLocationOnScreen();
+
+            Color color = robot.getPixelColor(pt1.x + panel.getWidth() / 2,
+                    pt1.y + panel.getHeight() / 2);
+
+            if (!color.equals(Color.RED)) {
+                throw new RuntimeException("RemoveAllShrinkTest failed. " + color);
+            }
+        } catch (Exception e) {
+            throw new RuntimeException("The test was not completed.\n\n" + e);
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/image/ImageIconHang.java	Fri May 30 14:54:57 2014 +0100
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.*;
+
+/*
+ * @test
+ * @bug     8032788
+ * @summary Checks that null filename argument is processed correctly
+ *
+ * @run     main ImageIconHang
+ */
+public class ImageIconHang {
+    public static void main(String[] args) throws Exception {
+        Image image = Toolkit.getDefaultToolkit().getImage((String) null);
+        MediaTracker mt = new MediaTracker(new Component() {});
+        mt.addImage(image, 1);
+        mt.waitForID(1, 5000);
+
+        int status = mt.statusID(1, false);
+
+        System.out.println("Status: " + status);
+
+        if (status != MediaTracker.ERRORED) {
+            throw new RuntimeException("MediaTracker.waitForID() hung.");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JTabbedPane/8007563/Test8007563.java	Fri May 30 14:54:57 2014 +0100
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.Point;
+import java.awt.Robot;
+import java.util.ArrayList;
+import java.util.concurrent.CountDownLatch;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JTabbedPane;
+
+import static javax.swing.UIManager.*;
+import static javax.swing.SwingUtilities.*;
+
+/*
+ * @test
+ * @bug 8007563
+ * @summary Tests JTabbedPane background
+ * @author Sergey Malenkov
+ */
+
+public class Test8007563 implements Runnable {
+    private static final ArrayList<String> LIST = new ArrayList<>();
+    private static final LookAndFeelInfo[] INFO = getInstalledLookAndFeels();
+    private static final CountDownLatch LATCH = new CountDownLatch(INFO.length);
+    private static Robot ROBOT;
+
+    public static void main(String[] args) throws Exception {
+        ROBOT = new Robot();
+        invokeLater(new Test8007563());
+        LATCH.await();
+        if (!LIST.isEmpty()) {
+            throw new Error(LIST.toString());
+        }
+    }
+
+    private static void addOpaqueError(boolean opaque) {
+        LIST.add(getLookAndFeel().getName() + " opaque=" + opaque);
+    }
+
+    private static boolean updateLookAndFeel() {
+        int index = (int) LATCH.getCount() - 1;
+        if (index >= 0) {
+            try {
+                LookAndFeelInfo info = INFO[index];
+                System.err.println("L&F: " + info.getName());
+                setLookAndFeel(info.getClassName());
+                return true;
+            } catch (Exception exception) {
+                exception.printStackTrace();
+            }
+        }
+        return false;
+    }
+
+    private JFrame frame;
+    private JTabbedPane pane;
+
+    public void run() {
+        if (this.frame == null) {
+            if (!updateLookAndFeel()) {
+                return;
+            }
+            this.pane = new JTabbedPane();
+            this.pane.setOpaque(false);
+            this.pane.setBackground(Color.RED);
+            for (int i = 0; i < 3; i++) {
+                this.pane.addTab("Tab " + i, new JLabel("Content area " + i));
+            }
+            this.frame = new JFrame(getClass().getSimpleName());
+            this.frame.getContentPane().setBackground(Color.BLUE);
+            this.frame.add(this.pane);
+            this.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+            this.frame.setSize(400, 200);
+            this.frame.setLocationRelativeTo(null);
+            this.frame.setVisible(true);
+        } else {
+            Point point = new Point(this.pane.getWidth() - 2, 2);
+            convertPointToScreen(point, this.pane);
+            Color actual = ROBOT.getPixelColor(point.x, point.y);
+
+            boolean opaque = this.pane.isOpaque();
+            Color expected = opaque
+                    ? this.pane.getBackground()
+                    : this.frame.getContentPane().getBackground();
+
+            if (!expected.equals(actual)){
+                addOpaqueError(opaque);
+            }
+            if (!opaque) {
+                this.pane.setOpaque(true);
+                this.pane.repaint();
+            } else {
+                this.frame.dispose();
+                this.frame = null;
+                this.pane = null;
+                LATCH.countDown();
+            }
+
+        }
+        invokeLater(this);
+    }
+}