changeset 5602:a1c5bac982a6 jdk7u10-b17

Merge
author lana
date Tue, 20 Nov 2012 12:01:00 -0800
parents 5bc986d34209 a91ac65b5e2f
children 579463b11b0e
files
diffstat 6 files changed, 279 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/native/sun/awt/CMenuItem.m	Wed Nov 14 18:41:55 2012 -0800
+++ b/src/macosx/native/sun/awt/CMenuItem.m	Tue Nov 20 12:01:00 2012 -0800
@@ -76,7 +76,7 @@
     NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent];
     if ([currEvent type] == NSKeyDown) {
         NSString *menuKey = [sender keyEquivalent];
-        NSString *eventKey = [currEvent characters];
+        NSString *eventKey = [currEvent charactersIgnoringModifiers];
         if ([menuKey isEqualToString:eventKey]) {
             return;
         }
--- a/src/share/classes/javax/swing/AncestorNotifier.java	Wed Nov 14 18:41:55 2012 -0800
+++ b/src/share/classes/javax/swing/AncestorNotifier.java	Tue Nov 20 12:01:00 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2008, 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
@@ -44,7 +44,7 @@
 
 class AncestorNotifier implements ComponentListener, PropertyChangeListener, Serializable
 {
-    Component firstInvisibleAncestor;
+    transient Component firstInvisibleAncestor;
     EventListenerList listenerList = new EventListenerList();
     JComponent root;
 
--- a/test/java/util/concurrent/Executors/AutoShutdown.java	Wed Nov 14 18:41:55 2012 -0800
+++ b/test/java/util/concurrent/Executors/AutoShutdown.java	Tue Nov 20 12:01:00 2012 -0800
@@ -67,6 +67,11 @@
         e1 = e2 = null;
         for (int i = 0; i < 10 && Thread.activeCount() > count0; i++)
             tryWaitForFinalizersToRun();
+        for (int i = 0; i < 10; ++i) { // give JVM a chance to settle.
+            if (Thread.activeCount() == count0)
+                return;
+            Thread.sleep(1000);
+        }
         equal(Thread.activeCount(), count0);
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/AncestorNotifier/7193219/bug7193219.java	Tue Nov 20 12:01:00 2012 -0800
@@ -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.
+ */
+
+/* @test
+   @bug 7193219
+   @summary JComboBox serialization fails in JDK 1.7
+   @author Anton Litvinov
+*/
+
+import java.io.*;
+
+import javax.swing.*;
+
+public class bug7193219 {
+    private static byte[] serializeGUI() {
+        // Create and set up the window.
+        JFrame frame = new JFrame("Serialization");
+        JPanel mainPanel = new JPanel();
+
+        /**
+         * If JComboBox is replaced with other component like JLabel
+         * The issue does not happen.
+         */
+        JComboBox status = new JComboBox();
+        status.addItem("123");
+        mainPanel.add(status);
+        frame.getContentPane().add(mainPanel);
+        frame.pack();
+
+        try {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream(baos);
+            oos.writeObject(mainPanel);
+            oos.flush();
+            frame.dispose();
+            return baos.toByteArray();
+        } catch (IOException ioe) {
+            throw new RuntimeException(ioe);
+        }
+    }
+
+    private static void deserializeGUI(byte[] serializedData) {
+        try {
+            ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(serializedData));
+            JPanel mainPanel = (JPanel)ois.readObject();
+            JFrame frame = new JFrame("Deserialization");
+            frame.getContentPane().add(mainPanel);
+            frame.pack();
+            frame.dispose();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                deserializeGUI(serializeGUI());
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java	Tue Nov 20 12:01:00 2012 -0800
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 7160951
+ * @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
+ * @author vera.akulova@oracle.com
+ * @run main ActionListenerCalledTwiceTest
+ */
+
+import sun.awt.*;
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+public class ActionListenerCalledTwiceTest {
+    static volatile int listenerCallCounter = 0;
+    public static void main(String[] args) throws Exception {
+        if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
+            System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
+            return;
+        }
+        System.setProperty("apple.laf.useScreenMenuBar", "true");
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
+        robot.setAutoDelay(100);
+        robot.keyPress(KeyEvent.VK_META);
+        robot.keyPress(KeyEvent.VK_E);
+        robot.keyRelease(KeyEvent.VK_E);
+        robot.keyRelease(KeyEvent.VK_META);
+        toolkit.realSync();
+        if (listenerCallCounter != 1) {
+            throw new Exception("Test failed: ActionListener called " + listenerCallCounter + " times instead of 1!");
+        }
+    }
+
+    private static void createAndShowGUI() {
+        JMenuItem newItem = new JMenuItem("Exit");
+        newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK));
+        newItem.addActionListener(
+            new ActionListener(){
+                public void actionPerformed(ActionEvent e) {
+                    listenerCallCounter++;
+                }
+            }
+        );
+        JMenu menu = new JMenu("Menu");
+        menu.add(newItem);
+        JMenuBar bar = new JMenuBar();
+        bar.add(menu);
+        JFrame frame = new JFrame("Test");
+        frame.setJMenuBar(bar);
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.pack();
+        frame.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JMenuItem/ShortcutNotDiplayed/ShortcutNotDisplayedTest.java	Tue Nov 20 12:01:00 2012 -0800
@@ -0,0 +1,105 @@
+/*
+ * 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 7186371
+ * @summary [macosx] Main menu shortcuts not displayed
+ * @author vera.akulova@oracle.com
+ * @run main/manual ShortcutNotDisplayedTest
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+
+public class ShortcutNotDisplayedTest {
+    static volatile boolean done = false;
+    static volatile boolean pass = false;
+    static final String PASS_COMMAND = "pass";
+
+    public static void main(String[] args) throws Exception {
+        if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.MACOSX) {
+            System.out.println("This test is for MacOS only. Automatically passed on other platforms.");
+            return;
+        }
+        System.setProperty("apple.laf.useScreenMenuBar", "true");
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        do { try { Thread.sleep(300); } catch (Exception e) {} } while (!done) ;
+        if (!pass) {
+            throw new Exception("Shortcuts not displayed as expected in the screen menu bar.");
+        }
+    }
+
+    private static void createAndShowGUI() {
+        JMenuItem newItem = new JMenuItem("Exit");
+        newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, java.awt.event.InputEvent.META_MASK));
+
+        JMenu menu = new JMenu("Test Frame Window Menu");
+        menu.setMnemonic(KeyEvent.VK_M);
+        menu.add(newItem);
+
+        JMenuBar bar = new JMenuBar();
+        bar.add(menu);
+        JTextArea text = new JTextArea(
+            "  Please follow instructions:\n" +
+            "  1. You should see \"Test Frame Window Menu\" menu on the screen menu bar.\n" +
+            "  2. Open \"Test Frame Window Menu\" menu. \n" +
+            "     Check that menu item \"Exit\" has a shortcut with image for Command Key and symbol \"E\". \n" +
+            "     If you see the shortcut press \"Passed\". Otherwise press \"Failed\".\n"
+        );
+        text.setEditable(false);
+
+        JScrollPane sp = new JScrollPane(text);
+        sp.setSize(300,200);
+
+        JButton passBtn = new JButton("Pass");
+        passBtn.setActionCommand(PASS_COMMAND);
+        JButton failBtn = new JButton("Fail");
+        ActionListener listener = new ActionListener() {
+            public void actionPerformed(ActionEvent e) {
+                if (e.getActionCommand().equals(PASS_COMMAND)) {
+                    pass = true;
+                }
+                done = true;
+            }
+        };
+
+        JFrame testFrame = new JFrame("Test Frame Window");
+        testFrame.setLayout(new FlowLayout());
+        testFrame.setBounds(100, 100, 600, 180);
+        testFrame.setJMenuBar(bar);
+        testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        passBtn.addActionListener(listener);
+        failBtn.addActionListener(listener);
+        testFrame.getContentPane().add(sp);
+        testFrame.getContentPane().add(passBtn);
+        testFrame.getContentPane().add(failBtn);
+        testFrame.setVisible(true);
+    }
+}