# HG changeset patch # User lana # Date 1370460602 25200 # Node ID 51098296e610273ab19582d9ccc1bf5abfab4ba9 # Parent 5ed4dd5caf75014097eda3765df909f2a0e4b348# Parent 96cc915fc8b933167774961b7abfd4a3cde2e46e Merge diff -r 5ed4dd5caf75 -r 51098296e610 jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java --- a/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/src/macosx/classes/sun/lwawt/macosx/LWCToolkit.java Wed Jun 05 12:30:02 2013 -0700 @@ -77,8 +77,20 @@ if (!GraphicsEnvironment.isHeadless()) { initIDs(); } + inAWT = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Boolean run() { + return !Boolean.parseBoolean(System.getProperty("javafx.embed.singleThread", "false")); + } + }); } + /* + * If true we operate in normal mode and nested runloop is executed in JavaRunLoopMode + * If false we operate in singleThreaded FX/AWT interop mode and nested loop uses NSDefaultRunLoopMode + */ + private static final boolean inAWT; + public LWCToolkit() { SunToolkit.setDataTransfererClassName("sun.lwawt.macosx.CDataTransferer"); @@ -701,7 +713,10 @@ * * if false - all events come after exit form the nested loop */ - static native void doAWTRunLoop(long mediator, boolean processEvents); + static void doAWTRunLoop(long mediator, boolean processEvents) { + doAWTRunLoopImpl(mediator, processEvents, inAWT); + } + static private native void doAWTRunLoopImpl(long mediator, boolean processEvents, boolean inAWT); static native void stopAWTRunLoop(long mediator); private native boolean nativeSyncQueue(long timeout); diff -r 5ed4dd5caf75 -r 51098296e610 jdk/src/macosx/native/sun/awt/AWTWindow.m --- a/jdk/src/macosx/native/sun/awt/AWTWindow.m Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/src/macosx/native/sun/awt/AWTWindow.m Wed Jun 05 12:30:02 2013 -0700 @@ -539,7 +539,7 @@ AWTWindow *opposite = [AWTWindow lastKeyWindow]; if (!IS(self.styleBits, IS_DIALOG)) { [CMenuBar activate:self.javaMenuBar modallyDisabled:NO]; - } else if (IS(self.styleBits, IS_MODAL)) { + } else if ((opposite != NULL) && IS(self.styleBits, IS_MODAL)) { [CMenuBar activate:opposite->javaMenuBar modallyDisabled:YES]; } [AWTWindow setLastKeyWindow:nil]; diff -r 5ed4dd5caf75 -r 51098296e610 jdk/src/macosx/native/sun/awt/CDropTargetContextPeer.m --- a/jdk/src/macosx/native/sun/awt/CDropTargetContextPeer.m Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/src/macosx/native/sun/awt/CDropTargetContextPeer.m Wed Jun 05 12:30:02 2013 -0700 @@ -61,7 +61,6 @@ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CDropTargetContextPeer_startTransfer (JNIEnv *env, jobject jthis, jlong jdroptarget, jlong jformat) { - AWT_ASSERT_NOT_APPKIT_THREAD; jlong result = (jlong) 0L; diff -r 5ed4dd5caf75 -r 51098296e610 jdk/src/macosx/native/sun/awt/LWCToolkit.m --- a/jdk/src/macosx/native/sun/awt/LWCToolkit.m Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/src/macosx/native/sun/awt/LWCToolkit.m Wed Jun 05 12:30:02 2013 -0700 @@ -295,11 +295,11 @@ /* * Class: sun_lwawt_macosx_LWCToolkit - * Method: doAWTRunLoop + * Method: doAWTRunLoopImpl * Signature: (JZZ)V */ -JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_doAWTRunLoop -(JNIEnv *env, jclass clz, jlong mediator, jboolean processEvents) +JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_doAWTRunLoopImpl +(JNIEnv *env, jclass clz, jlong mediator, jboolean processEvents, jboolean inAWT) { AWT_ASSERT_APPKIT_THREAD; JNF_COCOA_ENTER(env); @@ -311,7 +311,7 @@ // Don't use acceptInputForMode because that doesn't setup autorelease pools properly BOOL isRunning = true; while (![mediatorObject shouldEndRunLoop] && isRunning) { - isRunning = [[NSRunLoop currentRunLoop] runMode:[JNFRunLoop javaRunLoopMode] + isRunning = [[NSRunLoop currentRunLoop] runMode:(inAWT ? [JNFRunLoop javaRunLoopMode] : NSDefaultRunLoopMode) beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.010]]; if (processEvents) { //We do not spin a runloop here as date is nil, so does not matter which mode to use @@ -340,7 +340,6 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_stopAWTRunLoop (JNIEnv *env, jclass clz, jlong mediator) { -AWT_ASSERT_NOT_APPKIT_THREAD; JNF_COCOA_ENTER(env); AWTRunLoopObject* mediatorObject = (AWTRunLoopObject*)jlong_to_ptr(mediator); diff -r 5ed4dd5caf75 -r 51098296e610 jdk/src/macosx/native/sun/osxapp/QueuingApplicationDelegate.m --- a/jdk/src/macosx/native/sun/osxapp/QueuingApplicationDelegate.m Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/src/macosx/native/sun/osxapp/QueuingApplicationDelegate.m Wed Jun 05 12:30:02 2013 -0700 @@ -110,8 +110,14 @@ - (void)_handleOpenURLEvent:(NSAppleEventDescriptor *)openURLEvent withReplyEvent:(NSAppleEventDescriptor *)replyEvent { + // Make an explicit copy of the passed events as they may be invalidated by the time they're processed + NSAppleEventDescriptor *openURLEventCopy = [openURLEvent copy]; + NSAppleEventDescriptor *replyEventCopy = [replyEvent copy]; + [self.queue addObject:[^(){ - [self.realDelegate _handleOpenURLEvent:openURLEvent withReplyEvent:replyEvent]; + [self.realDelegate _handleOpenURLEvent:openURLEventCopy withReplyEvent:replyEventCopy]; + [openURLEventCopy release]; + [replyEventCopy release]; } copy]]; } diff -r 5ed4dd5caf75 -r 51098296e610 jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java --- a/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java Wed Jun 05 12:30:02 2013 -0700 @@ -42,7 +42,7 @@ * Component to focus. This behavior can be disabled using the * setImplicitDownCycleTraversal method. *

- * By default, methods of this class with return a Component only if it is + * By default, methods of this class will return a Component only if it is * visible, displayable, enabled, and focusable. Subclasses can modify this * behavior by overriding the accept method. *

diff -r 5ed4dd5caf75 -r 51098296e610 jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java --- a/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/src/share/classes/java/awt/DefaultKeyboardFocusManager.java Wed Jun 05 12:30:02 2013 -0700 @@ -559,6 +559,7 @@ } else { restoreFocus(fe, newFocusedWindow); } + setMostRecentFocusOwner(newFocusedWindow, null); // see: 8013773 } break; } diff -r 5ed4dd5caf75 -r 51098296e610 jdk/src/share/classes/java/awt/EventQueue.java --- a/jdk/src/share/classes/java/awt/EventQueue.java Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/src/share/classes/java/awt/EventQueue.java Wed Jun 05 12:30:02 2013 -0700 @@ -37,16 +37,10 @@ import java.util.EmptyStackException; +import sun.awt.*; import sun.awt.dnd.SunDropTargetEvent; import sun.util.logging.PlatformLogger; -import sun.awt.AppContext; -import sun.awt.AWTAutoShutdown; -import sun.awt.PeerEvent; -import sun.awt.SunToolkit; -import sun.awt.EventQueueItem; -import sun.awt.AWTAccessor; - import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.atomic.AtomicInteger; @@ -181,6 +175,8 @@ private final String name = "AWT-EventQueue-" + threadInitNumber.getAndIncrement(); + private FwDispatcher fwDispatcher; + private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventQueue"); static { @@ -209,6 +205,10 @@ { EventQueue.invokeAndWait(source, r); } + public void setFwDispatcher(EventQueue eventQueue, + FwDispatcher dispatcher) { + eventQueue.setFwDispatcher(dispatcher); + } }); } @@ -684,7 +684,16 @@ final Object src = event.getSource(); final PrivilegedAction action = new PrivilegedAction() { public Void run() { - dispatchEventImpl(event, src); + if (fwDispatcher == null) { + dispatchEventImpl(event, src); + } else { + fwDispatcher.scheduleDispatch(new Runnable() { + @Override + public void run() { + dispatchEventImpl(event, src); + } + }); + } return null; } }; @@ -844,7 +853,9 @@ while (topQueue.nextQueue != null) { topQueue = topQueue.nextQueue; } - + if (topQueue.fwDispatcher != null) { + throw new RuntimeException("push() to queue with fwDispatcher"); + } if ((topQueue.dispatchThread != null) && (topQueue.dispatchThread.getEventQueue() == this)) { @@ -975,6 +986,9 @@ // Forward the request to the top of EventQueue stack return nextQueue.createSecondaryLoop(cond, filter, interval); } + if (fwDispatcher != null) { + return fwDispatcher.createSecondaryLoop(); + } if (dispatchThread == null) { initDispatchThread(); } @@ -1018,6 +1032,9 @@ eq = next; next = eq.nextQueue; } + if (eq.fwDispatcher != null) { + return eq.fwDispatcher.isDispatchThread(); + } return (Thread.currentThread() == eq.dispatchThread); } finally { pushPopLock.unlock(); @@ -1303,6 +1320,15 @@ pushPopLock.unlock(); } } + + // The method is used by AWTAccessor for javafx/AWT single threaded mode. + private void setFwDispatcher(FwDispatcher dispatcher) { + if (nextQueue != null) { + nextQueue.setFwDispatcher(dispatcher); + } else { + fwDispatcher = dispatcher; + } + } } /** diff -r 5ed4dd5caf75 -r 51098296e610 jdk/src/share/classes/java/awt/Window.java --- a/jdk/src/share/classes/java/awt/Window.java Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/src/share/classes/java/awt/Window.java Wed Jun 05 12:30:02 2013 -0700 @@ -1200,6 +1200,7 @@ } } } + boolean fireWindowClosedEvent = isDisplayable(); DisposeAction action = new DisposeAction(); if (EventQueue.isDispatchThread()) { action.run(); @@ -1220,7 +1221,9 @@ // Execute outside the Runnable because postWindowEvent is // synchronized on (this). We don't need to synchronize the call // on the EventQueue anyways. - postWindowEvent(WindowEvent.WINDOW_CLOSED); + if (fireWindowClosedEvent) { + postWindowEvent(WindowEvent.WINDOW_CLOSED); + } } /* diff -r 5ed4dd5caf75 -r 51098296e610 jdk/src/share/classes/java/beans/XMLEncoder.java --- a/jdk/src/share/classes/java/beans/XMLEncoder.java Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/src/share/classes/java/beans/XMLEncoder.java Wed Jun 05 12:30:02 2013 -0700 @@ -487,6 +487,12 @@ } indentation--; + Statement statement = getMissedStatement(); + while (statement != null) { + outputStatement(statement, this, false); + statement = getMissedStatement(); + } + try { out.flush(); } @@ -503,6 +509,17 @@ targetToStatementList.clear(); } + Statement getMissedStatement() { + for (List statements : this.targetToStatementList.values()) { + for (int i = 0; i < statements.size(); i++) { + if (Statement.class == statements.get(i).getClass()) { + return statements.remove(i); + } + } + } + return null; + } + /** * This method calls flush, writes the closing @@ -597,7 +614,7 @@ "methodName") + " should not be null"); } - if (target instanceof Field && methodName.equals("get")) { + if (isArgument && target instanceof Field && methodName.equals("get")) { Field f = (Field)target; writeln(""); diff -r 5ed4dd5caf75 -r 51098296e610 jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java --- a/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java Wed Jun 05 12:30:02 2013 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -55,8 +55,7 @@ * @param items an array of Object objects */ public DefaultComboBoxModel(final E items[]) { - objects = new Vector(); - objects.ensureCapacity( items.length ); + objects = new Vector(items.length); int i,c; for ( i=0,c=items.length;i. + // If not, click to set focus on it. + // + if (!b1.hasFocus()) { + gained = Util.trackFocusGained(b1, new Runnable() { + public void run() { + Util.clickOnComp(b1, robot); + } + }, 5000, false); + + if (!gained) { + throw new RuntimeException("Unexpected state: focus is not on "); + } + } + + robot.delay(500); + + // + // Click , check that focus is set on the parent frame. + // + gained = false; + gained = Util.trackFocusGained(frame2, new Runnable() { + public void run() { + Util.clickOnComp(b2, robot); + } + }, 5000, false); + + if (!gained) { + throw new RuntimeException("Test failed: focus wasn't set to "); + } + + System.out.println("Test passed."); + } +} diff -r 5ed4dd5caf75 -r 51098296e610 jdk/test/java/awt/TextArea/Mixing/TextAreaMixing.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/TextArea/Mixing/TextAreaMixing.java Wed Jun 05 12:30:02 2013 -0700 @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2013, 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 8013189 + * @run main TextAreaMixing + * @summary TextArea should support HW/LW mixing + * @author anthony.petrov@oracle.com + */ + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +public class TextAreaMixing { + + private static volatile boolean menuClicked = false; + private static JMenuItem menuItem; + + public static void main(String[] args) throws Exception { + // The bug is only reproducible on X11, but there's no reason + // for this test to not pass on any platofrm + + final JFrame frame = new JFrame("JFrame"); + frame.setLayout(new GridLayout(0, 1)); + frame.setSize(200, 200); + + JMenuBar menuBar = new JMenuBar(); + JMenu menu = new JMenu("Test Menu"); + + for (int i = 0; i < 6; i++) { + JMenuItem mi = new JMenuItem(Integer.toString(i)); + mi.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + menuClicked = true; + } + }); + menu.add(mi); + + // Choose a random (OK, the fourth) menu item to click on + if (i == 3) { + menuItem = mi; + } + } + menuBar.add(menu); + frame.setJMenuBar(menuBar); + + frame.getContentPane().add(new TextArea()); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + + Thread.sleep(2000); + + Robot robot = new Robot(); + + // Open the menu + Point loc = menu.getLocationOnScreen(); + robot.mouseMove(loc.x + menu.getWidth() / 2, loc.y + menu.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + Thread.sleep(500); + + // Click an item + loc = menuItem.getLocationOnScreen(); + robot.mouseMove(loc.x + menuItem.getWidth() / 2, loc.y + menuItem.getHeight() / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + + Thread.sleep(500); + + frame.dispose(); + + if (!menuClicked) { + throw new RuntimeException("A menu item has never been clicked."); + } + } +} diff -r 5ed4dd5caf75 -r 51098296e610 jdk/test/java/awt/Window/Grab/GrabTest.java --- a/jdk/test/java/awt/Window/Grab/GrabTest.java Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/test/java/awt/Window/Grab/GrabTest.java Wed Jun 05 12:30:02 2013 -0700 @@ -175,7 +175,7 @@ // 6. Check that press on the outside area causes ungrab Point loc = f.getLocationOnScreen(); - robot.mouseMove(loc.x + 100, loc.y + f.getSize().height + 1); + robot.mouseMove(loc.x + 100, loc.y + f.getSize().height + 10); Util.waitForIdle(robot); robot.mousePress(InputEvent.BUTTON1_MASK); robot.delay(50); diff -r 5ed4dd5caf75 -r 51098296e610 jdk/test/java/awt/Window/WindowClosedEvents/WindowClosedEventOnDispose.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/Window/WindowClosedEvents/WindowClosedEventOnDispose.java Wed Jun 05 12:30:02 2013 -0700 @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2013, 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 8015500 + @summary DisposeAction multiplies the WINDOW_CLOSED event. + @author jlm@joseluismartin.info + @run main WindowClosedEventOnDispose + */ + + +import java.awt.Toolkit; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +/** + * WindowClosedEventOnDispose.java + * Summary: tests that Window don't multiplies the WINDOW_CLOSED event + * on dispose. + * Test fails if fire more events that expected; + */ +public class WindowClosedEventOnDispose { + + private static int N_LOOPS = 5; + private static int N_DIALOGS = 2; + + public static void main(String args[]) throws Exception { + tesWithFrame(); + testWithoutFrame(); + testHidenChildDispose(); + testHidenWindowDispose(); + } + + /** + * Test WINDOW_CLOSED event received by a dialog + * that have a owner window. + * @throws Exception + */ + public static void tesWithFrame() throws Exception { + doTest(true); + } + + /** + * Test WINDOW_CLOSED event received by a dialog + * that don't have a owner window. + * @throws Exception + */ + public static void testWithoutFrame() throws Exception { + System.out.println("Run without owner Frame"); + doTest(false); + } + + /** + * Test if a dialog that has never been shown fire + * the WINDOW_CLOSED event on parent dispose(). + * @throws Exception + */ + public static void testHidenChildDispose() throws Exception { + JFrame f = new JFrame(); + JDialog dlg = new JDialog(f); + Listener l = new Listener(); + dlg.addWindowListener(l); + f.dispose(); + waitEvents(); + + assertEquals(0, l.getCount()); + } + + /** + * Test if a dialog fire the WINDOW_CLOSED event + * on parent dispose(). + * @throws Exception + */ + public static void testVisibleChildParentDispose() throws Exception { + JFrame f = new JFrame(); + JDialog dlg = new JDialog(f); + Listener l = new Listener(); + dlg.addWindowListener(l); + dlg.setVisible(true); + f.dispose(); + waitEvents(); + + assertEquals(1, l.getCount()); + } + + /** + * Test if a Window that has never been shown fire the + * WINDOW_CLOSED event on dispose() + */ + public static void testHidenWindowDispose() throws Exception { + JFrame f = new JFrame(); + Listener l = new Listener(); + f.addWindowListener(l); + f.dispose(); + waitEvents(); + + assertEquals(0, l.getCount()); + } + + /** + * Test if a JDialog receive the correct number + * of WINDOW_CLOSED_EVENT + * @param useFrame true if use a owner frame + * @throws Exception + */ + private static void doTest(final boolean useFrame) throws Exception { + final Listener l = new Listener(); + final JFrame f = new JFrame(); + + for (int i = 0; i < N_LOOPS; i++) { + + SwingUtilities.invokeLater(new Runnable() { + + public void run() { + JDialog[] dialogs = new JDialog[N_DIALOGS]; + for (int i = 0; i < N_DIALOGS; i++) { + if (useFrame) { + dialogs[i]= new JDialog(f); + } + else { + dialogs[i] = new JDialog(); + } + + dialogs[i].addWindowListener(l); + dialogs[i].setVisible(true); + } + + // Dispose all + for (JDialog d : dialogs) + d.dispose(); + + f.dispose(); + } + }); + } + + waitEvents(); + + assertEquals(N_DIALOGS * N_LOOPS, l.getCount()); + } + + private static void waitEvents() throws InterruptedException { + // Wait until events are dispatched + while (Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent() != null) + Thread.sleep(100); + } + + /** + * @param expected the expected value + * @param real the real value + */ + private static void assertEquals(int expected, int real) throws Exception { + if (expected != real) { + throw new Exception("Expected events: " + expected + " Received Events: " + real); + } + } + +} + +/** + * Listener to count events + */ +class Listener extends WindowAdapter { + + private volatile int count = 0; + + public void windowClosed(WindowEvent e) { + count++; + } + + public int getCount() { + return count; + } + + public void setCount(int count) { + this.count = count; + } +} diff -r 5ed4dd5caf75 -r 51098296e610 jdk/test/java/beans/XMLEncoder/Test6989223.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/beans/XMLEncoder/Test6989223.java Wed Jun 05 12:30:02 2013 -0700 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013, 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 6989223 + * @summary Tests Rectangle2D.Double encoding + * @author Sergey Malenkov + */ + +import java.awt.geom.Rectangle2D; + +public class Test6989223 extends AbstractTest { + public static void main(String[] args) { + new Test6989223().test(true); + } + + protected Object getObject() { + return new Bean(1, 2, 3, 4); + } + + @Override + protected Object getAnotherObject() { + return new Bean(1, 2, 3, 5); + } + + public static class Bean extends Rectangle2D.Double { + public Bean() { + } + + public Bean(double x, double y, double w, double h) { + super(x, y, w, h); + } + + @Override + public boolean equals(Object object) { + return super.equals(object); // to avoid recursion during validation + } + } +} diff -r 5ed4dd5caf75 -r 51098296e610 jdk/test/java/beans/XMLEncoder/Test7080156.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/beans/XMLEncoder/Test7080156.java Wed Jun 05 12:30:02 2013 -0700 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2013, 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 7080156 7094245 + * @summary Tests beans with public arrays + * @author Sergey Malenkov + */ + +public class Test7080156 extends AbstractTest { + public static void main(String[] args) { + new Test7080156().test(true); + } + + protected Object getObject() { + Bean bean = new Bean(); + bean.setArray("something"); + return bean; + } + + @Override + protected Object getAnotherObject() { + Bean bean = new Bean(); + bean.setArray("some", "thing"); + return bean; + } + + public static class Bean { + public String[] array = {"default"}; + + public void setArray(String... array) { + this.array = array; + } + + public String[] getArray() { + return this.array; + } + } +} diff -r 5ed4dd5caf75 -r 51098296e610 jdk/test/java/beans/XMLEncoder/Test8013557.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/beans/XMLEncoder/Test8013557.java Wed Jun 05 12:30:02 2013 -0700 @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2013, 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 8013557 + * @summary Tests beans with public fields + * @author Sergey Malenkov + */ + +public class Test8013557 extends AbstractTest { + public static void main(String[] args) { + new Test8013557().test(true); + } + + protected Object getObject() { + return new Bean(new Value("something")); + } + + @Override + protected Object getAnotherObject() { + return new Bean(new Value()); + } + + public static class Bean { + public Value value; + + public Bean() { + this.value = new Value(); + } + + public Bean(Value value) { + this.value = value; + } + + public void setValue(Value value) { + this.value = value; + } + + public Value getValue() { + return this.value; + } + } + + public static class Value { + private String string; + + public Value() { + this.string = "default"; + } + + public Value(String value) { + this.string = value; + } + + public void setString(String string) { + this.string = string; + } + + public String getString() { + return this.string; + } + } +} diff -r 5ed4dd5caf75 -r 51098296e610 jdk/test/javax/swing/JComboBox/6337518/bug6337518.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JComboBox/6337518/bug6337518.java Wed Jun 05 12:30:02 2013 -0700 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2013, 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 6337518 + @summary Null Arrow Button Throws Exception in BasicComboBoxUI + @author Anton Litvinov +*/ + +import javax.swing.*; +import javax.swing.plaf.basic.*; + +public class bug6337518 extends BasicComboBoxUI { + @Override + protected JButton createArrowButton() { + return null; + } + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + JComboBox comboBox = new JComboBox(); + comboBox.setUI(new bug6337518()); + } + }); + } +} diff -r 5ed4dd5caf75 -r 51098296e610 jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java --- a/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java Wed Jun 05 09:52:41 2013 -0700 +++ b/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java Wed Jun 05 12:30:02 2013 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,8 @@ import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import java.awt.event.KeyEvent; + +import sun.awt.OSInfo; import sun.awt.SunToolkit; public class bug4624207 implements ChangeListener, FocusListener { @@ -99,7 +101,7 @@ toolkit.realSync(); - if ("Aqua".equals(UIManager.getLookAndFeel().getID())) { + if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) { Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B); } else { Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B); diff -r 5ed4dd5caf75 -r 51098296e610 jdk/test/javax/swing/JTable/7068740/bug7068740.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JTable/7068740/bug7068740.java Wed Jun 05 12:30:02 2013 -0700 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2013, 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 7068740 + @summary JTable wrapped in JLayer can't use PGUP/PGDOWN keys + @author Vladislav Karnaukhov + @run main bug7068740 +*/ + +import sun.awt.SunToolkit; + +import javax.swing.*; +import javax.swing.plaf.LayerUI; +import javax.swing.plaf.metal.MetalLookAndFeel; +import javax.swing.table.DefaultTableModel; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.lang.reflect.InvocationTargetException; + +public class bug7068740 extends JFrame { + + private static Robot robot = null; + private static JTable table = null; + private static SunToolkit toolkit = null; + + bug7068740() { + super(); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + + DefaultTableModel model = new DefaultTableModel() { + @Override + public int getRowCount() { + return 20; + } + + @Override + public int getColumnCount() { + return 2; + } + + @Override + public Object getValueAt(int row, int column) { + return "(" + row + "," + column + ")"; + } + }; + + table = new JTable(model); + LayerUI layerUI = new LayerUI<>(); + JLayer layer = new JLayer<>(table, layerUI); + JScrollPane scrollPane = new JScrollPane(layer); + add(scrollPane); + pack(); + setLocationRelativeTo(null); + } + + private static void setUp() { + try { + if (robot == null) { + robot = new Robot(); + robot.setAutoDelay(20); + } + + if (toolkit == null) { + toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + } + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + bug7068740 test = new bug7068740(); + test.setVisible(true); + } + }); + } catch (InterruptedException e) { + e.printStackTrace(); + throw new RuntimeException("Test failed"); + } catch (InvocationTargetException e) { + e.printStackTrace(); + throw new RuntimeException("Test failed"); + } catch (AWTException e) { + e.printStackTrace(); + throw new RuntimeException("Test failed"); + } + } + + private static void doTest() { + toolkit.realSync(); + table.setRowSelectionInterval(0, 0); + + robot.keyPress(KeyEvent.VK_PAGE_DOWN); + toolkit.realSync(); + if (table.getSelectedRow() != 19) { + throw new RuntimeException("Test failed"); + } + + robot.keyPress(KeyEvent.VK_PAGE_UP); + toolkit.realSync(); + if (table.getSelectedRow() != 0) { + throw new RuntimeException("Test failed"); + } + } + + public static void main(String[] args) { + try { + UIManager.setLookAndFeel(new MetalLookAndFeel()); + setUp(); + doTest(); + } catch (UnsupportedLookAndFeelException e) { + e.printStackTrace(); + throw new RuntimeException("Test failed"); + } + } +} diff -r 5ed4dd5caf75 -r 51098296e610 jdk/test/javax/swing/KeyboardManager/8013370/Test8013370.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/KeyboardManager/8013370/Test8013370.java Wed Jun 05 12:30:02 2013 -0700 @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2013, 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.Robot; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; + +import javax.swing.AbstractAction; +import javax.swing.InputMap; +import javax.swing.JFrame; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.KeyStroke; +import sun.awt.SunToolkit; + +import static java.awt.event.InputEvent.CTRL_DOWN_MASK; +import static javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW; +import static javax.swing.JOptionPane.showMessageDialog; +import static javax.swing.SwingUtilities.invokeAndWait; + +/* + * @test + * @bug 8013370 + * @summary Ensure that key stroke is not null + * @author Sergey Malenkov + */ + +public class Test8013370 implements Runnable { + public static void main(String[] args) throws Exception { + Test8013370 task = new Test8013370(); + invokeAndWait(task); + + Robot robot = new Robot(); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.waitForIdle(); + + invokeAndWait(task); + task.validate(); + } + + private JFrame frame; + private boolean error; + + @Override + public void run() { + if (this.frame == null) { + JMenuBar menu = new JMenuBar() { + @Override + protected boolean processKeyBinding(KeyStroke stroke, KeyEvent event, int condition, boolean pressed) { + if (stroke == null) { + Test8013370.this.error = true; + return false; + } + return super.processKeyBinding(stroke, event, condition, pressed); + } + }; + menu.add(new JMenuItem("Menu")); + + InputMap map = menu.getInputMap(WHEN_IN_FOCUSED_WINDOW); + // We add exactly 10 actions because the ArrayTable is converted + // from a array to a hashtable when more than 8 values are added. + for (int i = 0; i < 9; i++) { + String name = " Action #" + i; + map.put(KeyStroke.getKeyStroke(KeyEvent.VK_A + i, CTRL_DOWN_MASK), name); + + menu.getActionMap().put(name, new AbstractAction(name) { + @Override + public void actionPerformed(ActionEvent event) { + showMessageDialog(null, getValue(NAME)); + } + }); + } + this.frame = new JFrame("8013370"); + this.frame.setJMenuBar(menu); + this.frame.setVisible(true); + } + else { + this.frame.dispose(); + } + } + + private void validate() { + if (this.error) { + throw new Error("KeyStroke is null"); + } + } +}