Mercurial > hg > icedtea7-forest > jdk
changeset 8256:bf3af4e1335c
Merge
author | lana |
---|---|
date | Thu, 20 Nov 2014 14:01:52 -0800 |
parents | cba625be1713 (current diff) 8f7559387f84 (diff) |
children | cc7c09cc2393 |
files | |
diffstat | 17 files changed, 597 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Nov 20 09:53:08 2014 -0800 +++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Thu Nov 20 14:01:52 2014 -0800 @@ -676,7 +676,7 @@ final long nsWindowPtr = getNSWindowPtr(); LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit(); Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); - if( w != null + if( w != null && w.getPeer() != null && ((LWWindowPeer)w.getPeer()).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME && !lwcToolkit.isApplicationActive()) { lwcToolkit.activateApplicationIgnoringOtherApps();
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java Thu Nov 20 09:53:08 2014 -0800 +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java Thu Nov 20 14:01:52 2014 -0800 @@ -31,6 +31,8 @@ import java.awt.KeyEventPostProcessor; import java.awt.Window; import java.awt.Toolkit; + +import sun.awt.AWTAccessor; import sun.awt.SunToolkit; import java.awt.event.ActionEvent; @@ -133,10 +135,15 @@ // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. + // Also we must ensure that original source of key event belongs + // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { - skip = ev.getWhen() <= ((SunToolkit)tk).getWindowDeactivationTime(winAncestor); + Component originalSource = AWTAccessor.getKeyEventAccessor() + .getOriginalSource(ev); + skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || + ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) {
--- a/src/share/classes/java/awt/event/KeyEvent.java Thu Nov 20 09:53:08 2014 -0800 +++ b/src/share/classes/java/awt/event/KeyEvent.java Thu Nov 20 14:01:52 2014 -0800 @@ -930,6 +930,10 @@ long extendedKeyCode) { ev.extendedKeyCode = extendedKeyCode; } + + public Component getOriginalSource( KeyEvent ev ) { + return ev.originalSource; + } }); } @@ -939,6 +943,14 @@ */ private static native void initIDs(); + /** + * The original event source. + * + * Event source can be changed during processing, but in some cases + * we need to be able to obtain original source. + */ + private Component originalSource; + private KeyEvent(Component source, int id, long when, int modifiers, int keyCode, char keyChar, int keyLocation, boolean isProxyActive) { this(source, id, when, modifiers, keyCode, keyChar, keyLocation); @@ -1023,6 +1035,7 @@ } else if ((getModifiers() == 0) && (getModifiersEx() != 0)) { setOldModifiers(); } + originalSource = source; } /**
--- a/src/share/classes/sun/awt/AWTAccessor.java Thu Nov 20 09:53:08 2014 -0800 +++ b/src/share/classes/sun/awt/AWTAccessor.java Thu Nov 20 14:01:52 2014 -0800 @@ -650,6 +650,11 @@ * Sets extendedKeyCode field for KeyEvent */ void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode); + + /** + * Gets original source for KeyEvent + */ + Component getOriginalSource(KeyEvent ev); } /**
--- a/src/solaris/classes/java/lang/UNIXProcess.java.bsd Thu Nov 20 09:53:08 2014 -0800 +++ b/src/solaris/classes/java/lang/UNIXProcess.java.bsd Thu Nov 20 14:01:52 2014 -0800 @@ -35,6 +35,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; +import java.util.Locale; import java.util.concurrent.Executors; import java.util.concurrent.Executor; import java.util.concurrent.ThreadFactory; @@ -99,7 +100,7 @@ "jdk.lang.Process.launchMechanism", "posix_spawn"); try { - return LaunchMechanism.valueOf(s.toUpperCase()); + return LaunchMechanism.valueOf(s.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { throw new Error(s + " is not a supported " + "process launch mechanism on this platform.");
--- a/src/solaris/classes/java/lang/UNIXProcess.java.linux Thu Nov 20 09:53:08 2014 -0800 +++ b/src/solaris/classes/java/lang/UNIXProcess.java.linux Thu Nov 20 14:01:52 2014 -0800 @@ -35,6 +35,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; +import java.util.Locale; import java.util.concurrent.Executors; import java.util.concurrent.Executor; import java.util.concurrent.ThreadFactory; @@ -100,7 +101,7 @@ "jdk.lang.Process.launchMechanism", "vfork"); try { - return LaunchMechanism.valueOf(s.toUpperCase()); + return LaunchMechanism.valueOf(s.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { throw new Error(s + " is not a supported " + "process launch mechanism on this platform.");
--- a/src/solaris/classes/java/lang/UNIXProcess.java.solaris Thu Nov 20 09:53:08 2014 -0800 +++ b/src/solaris/classes/java/lang/UNIXProcess.java.solaris Thu Nov 20 14:01:52 2014 -0800 @@ -26,6 +26,7 @@ package java.lang; import java.io.*; +import java.util.Locale; import java.security.AccessController; import java.security.PrivilegedAction; @@ -89,7 +90,7 @@ "jdk.lang.Process.launchMechanism", "fork"); try { - return LaunchMechanism.valueOf(s.toUpperCase()); + return LaunchMechanism.valueOf(s.toUpperCase(Locale.ENGLISH)); } catch (IllegalArgumentException e) { throw new Error(s + " is not a supported " + "process launch mechanism on this platform.");
--- a/src/solaris/classes/sun/awt/X11/XBaseWindow.java Thu Nov 20 09:53:08 2014 -0800 +++ b/src/solaris/classes/sun/awt/X11/XBaseWindow.java Thu Nov 20 14:01:52 2014 -0800 @@ -1001,6 +1001,13 @@ switch (xev.get_type()) { case XConstants.ButtonPress: if (buttonState == 0) { + XWindowPeer parent = getToplevelXWindow(); + // See 6385277, 6981400. + if (parent != null && parent.isFocusableWindow()) { + // A click in a client area drops the actual focused window retaining. + parent.setActualFocusedWindow(null); + parent.requestWindowFocus(xbe.get_time(), true); + } XAwtState.setAutoGrabWindow(this); } break;
--- a/src/solaris/classes/sun/awt/X11/XComponentPeer.java Thu Nov 20 09:53:08 2014 -0800 +++ b/src/solaris/classes/sun/awt/X11/XComponentPeer.java Thu Nov 20 14:01:52 2014 -0800 @@ -605,33 +605,6 @@ } - public void handleButtonPressRelease(XEvent xev) { - /* - * Fix for 6385277. - * We request focus on simple Window by click in order - * to make it behave like Frame/Dialog in this case and also to unify - * the behaviour with what we have on MS Windows. - * handleJavaMouseEvent() would be more suitable place to do this - * but we want Swing to have this functionality also. - */ - if (xev.get_type() == XConstants.ButtonPress) { - final XWindowPeer parentXWindow = getParentTopLevel(); - Window parentWindow = (Window)parentXWindow.getTarget(); - if (parentXWindow.isFocusableWindow() && parentXWindow.isSimpleWindow() && - XKeyboardFocusManagerPeer.getInstance().getCurrentFocusedWindow() != parentWindow) - { - postEvent(new InvocationEvent(parentWindow, new Runnable() { - public void run() { - // Request focus on the EDT of 'parentWindow' because - // XDecoratedPeer.requestWindowFocus() calls client code. - parentXWindow.requestXFocus(); - } - })); - } - } - super.handleButtonPressRelease(xev); - } - public Dimension getMinimumSize() { return target.getSize(); }
--- a/src/solaris/classes/sun/awt/X11/XContentWindow.java Thu Nov 20 09:53:08 2014 -0800 +++ b/src/solaris/classes/sun/awt/X11/XContentWindow.java Thu Nov 20 14:01:52 2014 -0800 @@ -24,7 +24,9 @@ */ package sun.awt.X11; -import java.awt.*; +import java.awt.Component; +import java.awt.Rectangle; +import java.awt.Insets; import java.awt.event.ComponentEvent; @@ -160,23 +162,6 @@ } } - public void handleButtonPressRelease(XEvent xev) { - if (xev.get_type() == XConstants.ButtonPress) { - Window parentWindow = (Window)parentFrame.getTarget(); - /* - * In case the decorated frame is active but not focused - * (that is an owned window is currently focused) - * it should be made a focused window. - * This is needed to focus the frame when it's clicked - * in an empty spot of its content area. See 6886678. - */ - if (parentWindow != null && parentWindow.isActive() && !parentWindow.isFocused()) { - parentFrame.requestWindowFocus(); - } - } - super.handleButtonPressRelease(xev); - } - void purgeIconifiedExposeEvents() { for (SavedExposeEvent evt : iconifiedExposeEvents) { super.handleExposeEvent(evt.target, evt.x, evt.y, evt.w, evt.h);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Focus/NPEInKFMOnButtonClickInDialogTest/NPEInKFMOnButtonClickInDialogTest.java Thu Nov 20 14:01:52 2014 -0800 @@ -0,0 +1,135 @@ +/* + * 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 8061954 + @summary Button does not get the focus on a mouse click, and NPE is thrown in KFM + @author Anton Litvinov +*/ + +import java.awt.Container; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.InputEvent; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.SwingUtilities; + +import sun.awt.OSInfo; +import sun.awt.SunToolkit; + +public class NPEInKFMOnButtonClickInDialogTest { + private static Frame frame = null; + private static JDialog dialog = null; + private static JButton cancelBtn = null; + private static Point clickPoint = null; + private static volatile Boolean cancelBtnIsFocused = null; + + public static void main(String[] args) { + OSInfo.OSType osType = OSInfo.getOSType(); + if ((osType != OSInfo.OSType.LINUX) && (osType != OSInfo.OSType.SOLARIS)) { + System.out.println("This test is only for Linux OS and Solaris OS."); + return; + } + + ThreadGroup mainThreadGroup = Thread.currentThread().getThreadGroup(); + Thread t = new Thread(new ThreadGroup(mainThreadGroup, "TestThreadGroup"), new Runnable() { + public void run() { + try { + SunToolkit.createNewAppContext(); + doTest(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + t.start(); + + try { + t.join(); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + + if (cancelBtnIsFocused == null) { + throw new RuntimeException("Test failed for an unknown reason, look at error log."); + } else if (cancelBtnIsFocused.booleanValue() == false) { + throw new RuntimeException("'Cancel' button did not become a focus owner."); + } + } + + private static void doTest() throws Exception { + final SunToolkit toolkit = (SunToolkit)Toolkit.getDefaultToolkit(); + final Robot robot = new Robot(); + robot.setAutoDelay(50); + + try { + frame = new Frame("Frame of NPEInKFMOnButtonClickInDialogTest"); + frame.setSize(100, 100); + frame.setVisible(true); + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + dialog = new JDialog(frame, + "Dialog of NPEInKFMOnButtonClickInDialogTest", false); + Container content = dialog.getContentPane(); + content.setLayout(new FlowLayout()); + content.add(new JButton("Run")); + content.add(cancelBtn = new JButton("Cancel")); + dialog.pack(); + dialog.setVisible(true); + } + }); + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Point p = cancelBtn.getLocationOnScreen(); + clickPoint = new Point(p.x + cancelBtn.getWidth() / 2, + p.y + cancelBtn.getHeight() / 2); + } + }); + robot.mouseMove(clickPoint.x, clickPoint.y); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + cancelBtnIsFocused = cancelBtn.isFocusOwner(); + } + }); + } finally { + if (dialog != null) { + dialog.dispose(); + } + if (frame != null) { + frame.dispose(); + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Frame/DisposeStressTest/DisposeStressTest.html Thu Nov 20 14:01:52 2014 -0800 @@ -0,0 +1,21 @@ +<html> +<!-- + @test + @bug 4051487 4145670 + @summary Tests that disposing of an empty Frame or a Frame with a MenuBar + while it is being created does not crash the VM. + @author dpm area=Threads + @run applet/timeout=7200 DisposeStressTest.html + --> +<head> +<title>DisposeStressTest</title> +</head> +<body> + +<h1>DisposeStressTest<br>Bug ID: 4051487, 4145670</h1> + +<p> This is an AUTOMATIC test, simply wait for completion </p> + +<APPLET CODE="DisposeStressTest.class" WIDTH=200 HEIGHT=200></APPLET> +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/Frame/DisposeStressTest/DisposeStressTest.java Thu Nov 20 14:01:52 2014 -0800 @@ -0,0 +1,247 @@ +/* + * 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 4051487 4145670 8062021 + @summary Tests that disposing of an empty Frame or a Frame with a MenuBar + while it is being created does not crash the VM. + @author dpm area=Threads + @run applet/timeout=7200 DisposeStressTest.html +*/ + +// Note there is no @ in front of test above. This is so that the +// harness will not mistake this file as a test file. It should +// only see the html file as a test file. (the harness runs all +// valid test files, so it would run this test twice if this file +// were valid as well as the html file.) +// Also, note the area= after Your Name in the author tag. Here, you +// should put which functional area the test falls in. See the +// AWT-core home page -> test areas and/or -> AWT team for a list of +// areas. +// Note also the 'DisposeStressTest.html' in the run tag. This should +// be changed to the name of the test. + + +/** + * DisposeStressTest.java + * + * summary: + */ + +import java.applet.Applet; +import java.awt.*; + + +//Automated tests should run as applet tests if possible because they +// get their environments cleaned up, including AWT threads, any +// test created threads, and any system resources used by the test +// such as file descriptors. (This is normally not a problem as +// main tests usually run in a separate VM, however on some platforms +// such as the Mac, separate VMs are not possible and non-applet +// tests will cause problems). Also, you don't have to worry about +// synchronisation stuff in Applet tests they way you do in main +// tests... + + +public class DisposeStressTest extends Applet + { + //Declare things used in the test, like buttons and labels here + + public void init() + { + //Create instructions for the user here, as well as set up + // the environment -- set the layout manager, add buttons, + // etc. + + this.setLayout (new BorderLayout ()); + + String[] instructions = + { + "This is an AUTOMATIC test", + "simply wait until it is done" + }; + Sysout.createDialog( ); + Sysout.printInstructions( instructions ); + + }//End init() + + public void start () + { + for (int i = 0; i < 1000; i++) { + Frame f = new Frame(); + f.setBounds(10, 10, 10, 10); + f.show(); + f.dispose(); + + Frame f2 = new Frame(); + f2.setBounds(10, 10, 100, 100); + MenuBar bar = new MenuBar(); + Menu menu = new Menu(); + menu.add(new MenuItem("foo")); + bar.add(menu); + f2.setMenuBar(bar); + f2.show(); + f2.dispose(); + } + }// start() + + }// class DisposeStressTest + + +/**************************************************** + Standard Test Machinery + DO NOT modify anything below -- it's a standard + chunk of code whose purpose is to make user + interaction uniform, and thereby make it simpler + to read and understand someone else's test. + ****************************************************/ + +/** + This is part of the standard test machinery. + It creates a dialog (with the instructions), and is the interface + for sending text messages to the user. + To print the instructions, send an array of strings to Sysout.createDialog + WithInstructions method. Put one line of instructions per array entry. + To display a message for the tester to see, simply call Sysout.println + with the string to be displayed. + This mimics System.out.println but works within the test harness as well + as standalone. + */ + +class Sysout + { + private static TestDialog dialog; + + public static void createDialogWithInstructions( String[] instructions ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + dialog.printInstructions( instructions ); + dialog.show(); + println( "Any messages for the tester will display here." ); + } + + public static void createDialog( ) + { + dialog = new TestDialog( new Frame(), "Instructions" ); + String[] defInstr = { "Instructions will appear here. ", "" } ; + dialog.printInstructions( defInstr ); + dialog.show(); + println( "Any messages for the tester will display here." ); + } + + + public static void printInstructions( String[] instructions ) + { + dialog.printInstructions( instructions ); + } + + + public static void println( String messageIn ) + { + dialog.displayMessage( messageIn ); + } + + }// Sysout class + +/** + This is part of the standard test machinery. It provides a place for the + test instructions to be displayed, and a place for interactive messages + to the user to be displayed. + To have the test instructions displayed, see Sysout. + To have a message to the user be displayed, see Sysout. + Do not call anything in this dialog directly. + */ +class TestDialog extends Dialog + { + + TextArea instructionsText; + TextArea messageText; + int maxStringLength = 80; + + //DO NOT call this directly, go through Sysout + public TestDialog( Frame frame, String name ) + { + super( frame, name ); + int scrollBoth = TextArea.SCROLLBARS_BOTH; + instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); + add( "North", instructionsText ); + + messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); + add("South", messageText); + + pack(); + + show(); + }// TestDialog() + + //DO NOT call this directly, go through Sysout + public void printInstructions( String[] instructions ) + { + //Clear out any current instructions + instructionsText.setText( "" ); + + //Go down array of instruction strings + + String printStr, remainingStr; + for( int i=0; i < instructions.length; i++ ) + { + //chop up each into pieces maxSringLength long + remainingStr = instructions[ i ]; + while( remainingStr.length() > 0 ) + { + //if longer than max then chop off first max chars to print + if( remainingStr.length() >= maxStringLength ) + { + //Try to chop on a word boundary + int posOfSpace = remainingStr. + lastIndexOf( ' ', maxStringLength - 1 ); + + if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; + + printStr = remainingStr.substring( 0, posOfSpace + 1 ); + remainingStr = remainingStr.substring( posOfSpace + 1 ); + } + //else just print + else + { + printStr = remainingStr; + remainingStr = ""; + } + + instructionsText.append( printStr + "\n" ); + + }// while + + }// for + + }//printInstructions() + + //DO NOT call this directly, go through Sysout + public void displayMessage( String messageIn ) + { + messageText.append( messageIn + "\n" ); + } + + }// TestDialog class
--- a/test/java/lang/ProcessBuilder/Basic.java Thu Nov 20 09:53:08 2014 -0800 +++ b/test/java/lang/ProcessBuilder/Basic.java Thu Nov 20 14:01:52 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -26,10 +26,11 @@ * @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689 * 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313 * 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958 - * 4947220 7018606 7034570 + * 4947220 7018606 7034570 8047340 * @summary Basic tests for Process and Environment Variable code * @run main/othervm/timeout=300 Basic * @run main/othervm/timeout=300 -Djdk.lang.Process.launchMechanism=fork Basic + * @run main/othervm/timeout=300 -DTurkeyTest Basic * @author Martin Buchholz */ @@ -1083,6 +1084,11 @@ } private static void realMain(String[] args) throws Throwable { + if (System.getProperty("TurkeyTest") != null) { + // static initializer test, set this early. + System.out.println("Testing with Turkish locale."); + Locale.setDefault(new Locale("tr", "")); + } if (Windows.is()) System.out.println("This appears to be a Windows system."); if (Unix.is())
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/plaf/windows/WindowsRootPaneUI/AltKeyProccessingNPETest/AltKeyProccessingNPETest.java Thu Nov 20 14:01:52 2014 -0800 @@ -0,0 +1,65 @@ +/* + * 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 8001633 + @summary Wrong alt processing during switching between windows + @author mikhail.cherkasov@oracle.com + @run main AltKeyProccessingNPETest +*/ +import sun.awt.SunToolkit; + +import java.awt.*; +import java.awt.event.KeyEvent; +import javax.swing.UIManager; + +public class AltKeyProccessingNPETest { + + private static Robot robot; + + public static void initRobot() throws AWTException { + robot = new Robot(); + robot.setAutoDelay(100); + } + + public static void sync() { + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + toolkit.realSync(); + } + + public static void main(String args[]) throws Exception { + + initRobot(); + + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + + Frame frame = new Frame(); + frame.setSize(400,400); + frame.setVisible(true); + + sync(); + + robot.keyPress(KeyEvent.VK_ALT); + robot.keyRelease(KeyEvent.VK_ALT); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/jaxp/testng/TEST.properties Thu Nov 20 14:01:52 2014 -0800 @@ -0,0 +1,3 @@ +# This file identifies root(s) of the test-ng hierarchy. + +TestNG.dirs = .
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/xml/jaxp/testng/parse/XMLEntityScannerLoad.java Thu Nov 20 14:01:52 2014 -0800 @@ -0,0 +1,75 @@ +/* + * 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. + */ + +package parse; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import static org.testng.Assert.assertEquals; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +/** + * JDK-8059327: XML parser returns corrupt attribute value + * https://bugs.openjdk.java.net/browse/JDK-8059327 + * + * Also: + * JDK-8061550: XMLEntityScanner can corrupt corrupt content during parsing + * https://bugs.openjdk.java.net/browse/JDK-8061550 + * + * @Summary: verify that the character cache in XMLEntityScanner is reset properly + */ + +public class XMLEntityScannerLoad { + + @Test(dataProvider = "xmls") + public void test(String xml) throws SAXException, IOException, ParserConfigurationException { + Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ChunkInputStream(xml)); + String value = d.getDocumentElement().getAttribute("a1"); + assertEquals(value, "w"); + } + + static class ChunkInputStream extends ByteArrayInputStream { + ChunkInputStream(String xml) { + super(xml.getBytes()); + } + + @Override + public synchronized int read(byte[] b, int off, int len) { + return super.read(b, off, 7); + } + } + + @DataProvider(name = "xmls") + private Object[][] xmls() { + return new Object[][] { + {"<?xml version=\"1.0\"?><element a1=\"w\" a2=\"""\"/>"}, + {"<?xml version=\"1.1\"?><element a1=\"w\" a2=\"""\"/>"} + }; + } +}