From 15113a03ad68289337eab40960779050d649a733 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 5 Apr 2011 16:50:11 +0400 Subject: [PATCH 01/12] 6998877: After double-click on the folder names , FileNameOverrideTest FAILED Reviewed-by: art, dcherepanov, anthony --- .../solaris/native/sun/awt/gtk2_interface.c | 2 + .../solaris/native/sun/awt/gtk2_interface.h | 2 + .../sun/awt/sun_awt_X11_GtkFileDialogPeer.c | 9 ++- .../FileNameOverrideTest.html | 22 ++++++ .../FileNameOverrideTest.java | 73 +++++++++++++++++++ .../SaveFileNameOverrideTest.html | 22 ++++++ .../SaveFileNameOverrideTest.java | 65 +++++++++++++++++ 7 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 jdk/test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.html create mode 100644 jdk/test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.java create mode 100644 jdk/test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.html create mode 100644 jdk/test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.java diff --git a/jdk/src/solaris/native/sun/awt/gtk2_interface.c b/jdk/src/solaris/native/sun/awt/gtk2_interface.c index 291edc3fb7e..7e5c3765e7d 100644 --- a/jdk/src/solaris/native/sun/awt/gtk2_interface.c +++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.c @@ -443,6 +443,8 @@ void gtk2_file_chooser_load() "gtk_file_chooser_set_current_folder"); fp_gtk_file_chooser_set_filename = dl_symbol( "gtk_file_chooser_set_filename"); + fp_gtk_file_chooser_set_current_name = dl_symbol( + "gtk_file_chooser_set_current_name"); fp_gtk_file_filter_add_custom = dl_symbol("gtk_file_filter_add_custom"); fp_gtk_file_chooser_set_filter = dl_symbol("gtk_file_chooser_set_filter"); fp_gtk_file_chooser_get_type = dl_symbol("gtk_file_chooser_get_type"); diff --git a/jdk/src/solaris/native/sun/awt/gtk2_interface.h b/jdk/src/solaris/native/sun/awt/gtk2_interface.h index addbc99d61c..15f50c649b7 100644 --- a/jdk/src/solaris/native/sun/awt/gtk2_interface.h +++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.h @@ -766,6 +766,8 @@ gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser, const gchar *filename); gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser, const char *filename); +void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser, + const gchar *name); void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter, GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data, GDestroyNotify notify); diff --git a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c index a5bdbec6cdb..403a16e0311 100644 --- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c +++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c @@ -4,6 +4,7 @@ #include #include "gtk2_interface.h" #include "sun_awt_X11_GtkFileDialogPeer.h" +#include "java_awt_FileDialog.h" #include "debug_assert.h" static JavaVM *jvm; @@ -220,7 +221,7 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer, const char *title = jtitle == NULL? "": (*env)->GetStringUTFChars(env, jtitle, 0); - if (mode == 1) { + if (mode == java_awt_FileDialog_SAVE) { /* Save action */ dialog = fp_gtk_file_chooser_dialog_new(title, NULL, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, @@ -253,7 +254,11 @@ Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer, /* Set the filename */ if (jfile != NULL) { const char *filename = (*env)->GetStringUTFChars(env, jfile, 0); - fp_gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename); + if (mode == java_awt_FileDialog_SAVE) { + fp_gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename); + } else { + fp_gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename); + } (*env)->ReleaseStringUTFChars(env, jfile, filename); } diff --git a/jdk/test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.html b/jdk/test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.html new file mode 100644 index 00000000000..56e616362be --- /dev/null +++ b/jdk/test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.html @@ -0,0 +1,22 @@ + + + + FileNameOverrideTest + + + +

FileNameOverrideTest
Bug ID: 6260659

+ +

See the dialog box (usually in upper left corner) for instructions

+ + + + diff --git a/jdk/test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.java b/jdk/test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.java new file mode 100644 index 00000000000..38fbbccca90 --- /dev/null +++ b/jdk/test/java/awt/FileDialog/FileNameOverrideTest/FileNameOverrideTest.java @@ -0,0 +1,73 @@ +/* + test + @bug 6260659 + @summary File Name set programmatically in FileDialog is overridden during navigation, XToolkit + @author Dmitry.Cherepanov@SUN.COM area=awt.filedialog + @library ../../regtesthelpers + @build Sysout + @run applet/manual=yesno FileNameOverrideTest.html +*/ + +import test.java.awt.regtesthelpers.Sysout; + +import java.applet.Applet; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; + +public class FileNameOverrideTest extends Applet implements ActionListener { + private final static String fileName = "input"; + private final static String clickDirName = "Directory for double click"; + private final static String dirPath = "."; + private Button showBtn; + private FileDialog fd; + + public void init() { + this.setLayout(new GridLayout(1, 1)); + + fd = new FileDialog(new Frame(), "Open"); + + showBtn = new Button("Show File Dialog"); + showBtn.addActionListener(this); + add(showBtn); + + try { + File tmpFileUp = new File(dirPath + File.separator + fileName); + File tmpDir = new File(dirPath + File.separator + clickDirName); + File tmpFileIn = new File(tmpDir.getAbsolutePath() + File.separator + fileName); + tmpDir.mkdir(); + tmpFileUp.createNewFile(); + tmpFileIn.createNewFile(); + } catch (IOException ex) { + throw new RuntimeException("Cannot create test folder", ex); + } + + String[] instructions = { + "1) Click on 'Show File Dialog' button. A file dialog will come up.", + "2) Double-click on '" + clickDirName + "' and click OK.", + "3) See result of the test below" + }; + Sysout.createDialogWithInstructions(instructions); + }//End init() + + public void start() { + setSize(200, 200); + show(); + }// start() + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == showBtn) { + fd.setFile(fileName); + fd.setDirectory(dirPath); + fd.setVisible(true); + String output = fd.getFile(); + if (fileName.equals(output)) { + Sysout.println("TEST PASSED"); + } else { + Sysout.println("TEST FAILED (output file - " + output + ")"); + } + } + } +}// class ManualYesNoTest diff --git a/jdk/test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.html b/jdk/test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.html new file mode 100644 index 00000000000..561e780969a --- /dev/null +++ b/jdk/test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.html @@ -0,0 +1,22 @@ + + + + SaveFileNameOverrideTest + + + +

SaveFileNameOverrideTest
Bug ID: 6260659

+ +

See the dialog box (usually in upper left corner) for instructions

+ + + + diff --git a/jdk/test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.java b/jdk/test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.java new file mode 100644 index 00000000000..19c2feb4e69 --- /dev/null +++ b/jdk/test/java/awt/FileDialog/SaveFileNameOverrideTest/SaveFileNameOverrideTest.java @@ -0,0 +1,65 @@ +/* + test + @bug 6998877 + @summary After double-click on the folder names, FileNameOverrideTest FAILED + @author Sergey.Bylokhov@oracle.com area=awt.filedialog + @library ../../regtesthelpers + @build Sysout + @run applet/manual=yesno SaveFileNameOverrideTest.html +*/ + +import test.java.awt.regtesthelpers.Sysout; + +import java.applet.Applet; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +public class SaveFileNameOverrideTest extends Applet implements ActionListener { + private final static String clickDirName = "Directory for double click"; + private final static String dirPath = "."; + private Button showBtn; + private FileDialog fd; + + public void init() { + this.setLayout(new GridLayout(1, 1)); + + fd = new FileDialog(new Frame(), "Save", FileDialog.SAVE); + + showBtn = new Button("Show File Dialog"); + showBtn.addActionListener(this); + add(showBtn); + + File tmpDir = new File(dirPath + File.separator + clickDirName); + tmpDir.mkdir(); + + String[] instructions = { + "1) Click on 'Show File Dialog' button. A file dialog will come up.", + "2) Double-click on '" + clickDirName + "' and click OK.", + "3) See result of the test below" + }; + + Sysout.createDialogWithInstructions(instructions); + + }//End init() + + public void start() { + setSize(200, 200); + show(); + }// start() + + public void actionPerformed(ActionEvent e) { + if (e.getSource() == showBtn) { + fd.setFile("input"); + fd.setDirectory(dirPath); + fd.setVisible(true); + String output = fd.getFile(); + if ("input".equals(output)) { + Sysout.println("TEST PASSED"); + } else { + Sysout.println("TEST FAILED (output file - " + output + ")"); + } + } + } +}// class ManualYesNoTest From 58ceadaf02f8a0d857615f0f15188e93280ebd08 Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Wed, 6 Apr 2011 17:13:08 +0400 Subject: [PATCH 02/12] 7002839: Static initialization deadlock between sun.awt.Win32GraphicsEnvironment and sun.awt.windows.WToolkit Reviewed-by: art, dcherepanov, denis --- .../sun/awt/Win32GraphicsEnvironment.java | 6 --- .../classes/sun/awt/windows/WToolkit.java | 3 -- .../LoadLock/GE_init1.java | 37 +++++++++++++++ .../LoadLock/GE_init2.java | 38 ++++++++++++++++ .../LoadLock/GE_init3.java | 38 ++++++++++++++++ .../LoadLock/GE_init4.java | 37 +++++++++++++++ .../LoadLock/GE_init5.java | 37 +++++++++++++++ .../LoadLock/GE_init6.java | 45 +++++++++++++++++++ 8 files changed, 232 insertions(+), 9 deletions(-) create mode 100644 jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init1.java create mode 100644 jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init2.java create mode 100644 jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init3.java create mode 100644 jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init4.java create mode 100644 jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init5.java create mode 100644 jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init6.java diff --git a/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java b/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java index f3088fcbca3..50e7640663f 100644 --- a/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java +++ b/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java @@ -75,12 +75,6 @@ public class Win32GraphicsEnvironment SurfaceManagerFactory.setInstance(new WindowsSurfaceManagerFactory()); } - /** - * Noop function that just acts as an entry point for someone to force - * a static initialization of this class. - */ - public static void init() {} - /** * Initializes native components of the graphics environment. This * includes everything from the native GraphicsDevice elements to diff --git a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java index 7a18683e659..82318cd3b97 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WToolkit.java +++ b/jdk/src/windows/classes/sun/awt/windows/WToolkit.java @@ -103,9 +103,6 @@ public class WToolkit extends SunToolkit implements Runnable { static { loadLibraries(); - // Force Win32GE to load if it is not already loaded; this loads - // various other classes that are required for basic awt functionality - Win32GraphicsEnvironment.init(); initIDs(); // Print out which version of Windows is running diff --git a/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init1.java b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init1.java new file mode 100644 index 00000000000..1aef7874ce8 --- /dev/null +++ b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init1.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2011, 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 7002839 + * @summary Static init deadlock Win32GraphicsEnvironment and WToolkit + * @run main GE_init1 + */ + +import java.awt.Toolkit; + +public class GE_init1 { + public static void main(String[] args) { + Toolkit.getDefaultToolkit(); + } +} diff --git a/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init2.java b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init2.java new file mode 100644 index 00000000000..306c3c46c9d --- /dev/null +++ b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init2.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2011, 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 7002839 + * @summary Static init deadlock Win32GraphicsEnvironment and WToolkit + * @run main GE_init2 + */ + + +import java.awt.GraphicsEnvironment; + +public class GE_init2 { + public static void main(String[] args) { + GraphicsEnvironment.getLocalGraphicsEnvironment(); + } +} diff --git a/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init3.java b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init3.java new file mode 100644 index 00000000000..68a64f88002 --- /dev/null +++ b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init3.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2011, 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 7002839 + * @summary Static init deadlock Win32GraphicsEnvironment and WToolkit + * @run main GE_init3 + */ + + +import java.awt.Frame; + +public class GE_init3 { + public static void main(String[] args) { + new Frame("Test3").setVisible(true); + } +} diff --git a/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init4.java b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init4.java new file mode 100644 index 00000000000..534424b1f4e --- /dev/null +++ b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init4.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2011, 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 7002839 + * @summary Static init deadlock Win32GraphicsEnvironment and WToolkit + * @run main/othervm -Djava.awt.headless=true GE_init4 + */ + +import java.awt.Toolkit; + +public class GE_init4 { + public static void main(String[] args) { + Toolkit.getDefaultToolkit(); + } +} diff --git a/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init5.java b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init5.java new file mode 100644 index 00000000000..d0b40315ef0 --- /dev/null +++ b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init5.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2011, 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 7002839 + * @summary Static init deadlock Win32GraphicsEnvironment and WToolkit + * @run main/othervm -Djava.awt.headless=true GE_init4 + */ + +import java.awt.Toolkit; + +public class GE_init5 { + public static void main(String[] args) { + GraphicsEnvironment.getLocalGraphicsEnvironment(); + } +} diff --git a/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init6.java b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init6.java new file mode 100644 index 00000000000..355b0f6c65a --- /dev/null +++ b/jdk/test/java/awt/GraphicsEnvironment/LoadLock/GE_init6.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2011, 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 7002839 + * @summary Static init deadlock Win32GraphicsEnvironment and WToolkit + * @run main/othervm -Djava.awt.headless=true GE_init6 + */ + +import java.awt.*; + +public class GE_init6 { + private static boolean passed = false; + public static void main(String[] args) { + try { + new Frame("Test3").setVisible(true); + } catch (HeadlessException e){ + passed = true; + } + if (!passed){ + throw new RuntimeException("Should have thrown HE but it either didn't throw any or just passed through."); + } + } +} From 27da779f25dcb80b10c61ec162b76f3011429a18 Mon Sep 17 00:00:00 2001 From: Dmitry Cherepanov Date: Thu, 7 Apr 2011 18:54:34 +0400 Subject: [PATCH 03/12] 7016889: GraphicsDevice.setFullScreenWindow() spec for simulated full-screen mode is not always correct Reviewed-by: art, anthony --- .../classes/java/awt/GraphicsDevice.java | 6 ++- jdk/src/share/classes/java/awt/Window.java | 51 +++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/java/awt/GraphicsDevice.java b/jdk/src/share/classes/java/awt/GraphicsDevice.java index 25c6eb5d41f..f3b7cd390a6 100644 --- a/jdk/src/share/classes/java/awt/GraphicsDevice.java +++ b/jdk/src/share/classes/java/awt/GraphicsDevice.java @@ -243,8 +243,10 @@ public abstract class GraphicsDevice { * a non-client of the input method framework. * *

- * Simulated full-screen mode resizes - * the window to the size of the screen and positions it at (0,0). + * The simulated full-screen mode places and resizes the window to the maximum + * possible visible area of the screen. However, the native windowing system + * may modify the requested geometry-related data, so that the {@code Window} object + * is placed and sized in a way that corresponds closely to the desktop settings. *

* When entering full-screen mode, if the window to be used as a * full-screen window is not visible, this method will make it visible. diff --git a/jdk/src/share/classes/java/awt/Window.java b/jdk/src/share/classes/java/awt/Window.java index 5d8f1e6695d..e5dbc67afce 100644 --- a/jdk/src/share/classes/java/awt/Window.java +++ b/jdk/src/share/classes/java/awt/Window.java @@ -870,6 +870,11 @@ public class Window extends Container implements Accessible { * are automatically enlarged if either is less than * the minimum size as specified by previous call to * {@code setMinimumSize}. + *

+ * The method changes the geometry-related data. Therefore, + * the native windowing system may ignore such requests, or it may modify + * the requested data, so that the {@code Window} object is placed and sized + * in a way that corresponds closely to the desktop settings. * * @see #getSize * @see #setBounds @@ -887,6 +892,11 @@ public class Window extends Container implements Accessible { * are automatically enlarged if either is less than * the minimum size as specified by previous call to * {@code setMinimumSize}. + *

+ * The method changes the geometry-related data. Therefore, + * the native windowing system may ignore such requests, or it may modify + * the requested data, so that the {@code Window} object is placed and sized + * in a way that corresponds closely to the desktop settings. * * @see #getSize * @see #setBounds @@ -897,6 +907,32 @@ public class Window extends Container implements Accessible { super.setSize(width, height); } + /** + * {@inheritDoc} + *

+ * The method changes the geometry-related data. Therefore, + * the native windowing system may ignore such requests, or it may modify + * the requested data, so that the {@code Window} object is placed and sized + * in a way that corresponds closely to the desktop settings. + */ + @Override + public void setLocation(int x, int y) { + super.setLocation(x, y); + } + + /** + * {@inheritDoc} + *

+ * The method changes the geometry-related data. Therefore, + * the native windowing system may ignore such requests, or it may modify + * the requested data, so that the {@code Window} object is placed and sized + * in a way that corresponds closely to the desktop settings. + */ + @Override + public void setLocation(Point p) { + super.setLocation(p); + } + /** * @deprecated As of JDK version 1.1, * replaced by setBounds(int, int, int, int). @@ -3147,6 +3183,11 @@ public class Window extends Container implements Accessible { * placed at the left side of the screen. The similar placement * will occur if both top and bottom edges are out of the screen. * In that case, the window is placed at the top side of the screen. + *

+ * The method changes the geometry-related data. Therefore, + * the native windowing system may ignore such requests, or it may modify + * the requested data, so that the {@code Window} object is placed and sized + * in a way that corresponds closely to the desktop settings. * * @param c the component in relation to which the window's location * is determined @@ -3395,6 +3436,11 @@ public class Window extends Container implements Accessible { * are automatically enlarged if either is less than * the minimum size as specified by previous call to * {@code setMinimumSize}. + *

+ * The method changes the geometry-related data. Therefore, + * the native windowing system may ignore such requests, or it may modify + * the requested data, so that the {@code Window} object is placed and sized + * in a way that corresponds closely to the desktop settings. * * @see #getBounds * @see #setLocation(int, int) @@ -3424,6 +3470,11 @@ public class Window extends Container implements Accessible { * will be automatically enlarged if either is less than * the minimum size as specified by previous call to * {@code setMinimumSize}. + *

+ * The method changes the geometry-related data. Therefore, + * the native windowing system may ignore such requests, or it may modify + * the requested data, so that the {@code Window} object is placed and sized + * in a way that corresponds closely to the desktop settings. * * @see #getBounds * @see #setLocation(int, int) From fae19754bb6200de0478a5086aee57da35fb96b7 Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Thu, 7 Apr 2011 22:34:29 +0400 Subject: [PATCH 04/12] 7031854: JCK 7 test FileDialogTest0001 fails on Windows with Russian locale Reviewed-by: uta, dcherepanov --- jdk/src/windows/native/sun/windows/awt_FileDialog.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp b/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp index a0762b4eaaf..8e2c4996ece 100644 --- a/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp +++ b/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp @@ -225,7 +225,6 @@ AwtFileDialog::Show(void *p) { JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jobject peer; - WCHAR unicodeChar = L' '; LPTSTR fileBuffer = NULL; LPTSTR currentDirectory = NULL; jint mode = 0; @@ -263,7 +262,7 @@ AwtFileDialog::Show(void *p) HWND hwndOwner = awtParent ? awtParent->GetHWnd() : NULL; if (title == NULL || env->GetStringLength(title)==0) { - title = JNU_NewStringPlatform(env, &unicodeChar); + title = JNU_NewStringPlatform(env, L" "); } JavaStringBuffer titleBuffer(env, title); From 8ca505ebed7aa33fa61b312b9afa2cc1fda16889 Mon Sep 17 00:00:00 2001 From: Anthony Petrov Date: Fri, 8 Apr 2011 15:00:20 +0400 Subject: [PATCH 05/12] 7027013: Regression: JComponent.revalidate() has no effect on invisible components Dialog.conditionalShow() should call validateUnconditionally() instead of simple validate() Reviewed-by: art, dcherepanov --- jdk/src/share/classes/java/awt/Dialog.java | 2 +- .../Dialog/ValidateOnShow/ValidateOnShow.java | 84 +++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/awt/Dialog/ValidateOnShow/ValidateOnShow.java diff --git a/jdk/src/share/classes/java/awt/Dialog.java b/jdk/src/share/classes/java/awt/Dialog.java index e6ac3a8cdff..a388c70e7f5 100644 --- a/jdk/src/share/classes/java/awt/Dialog.java +++ b/jdk/src/share/classes/java/awt/Dialog.java @@ -903,7 +903,7 @@ public class Dialog extends Window { if (peer == null) { addNotify(); } - validate(); + validateUnconditionally(); if (visible) { toFront(); retval = false; diff --git a/jdk/test/java/awt/Dialog/ValidateOnShow/ValidateOnShow.java b/jdk/test/java/awt/Dialog/ValidateOnShow/ValidateOnShow.java new file mode 100644 index 00000000000..9f72f2a14bf --- /dev/null +++ b/jdk/test/java/awt/Dialog/ValidateOnShow/ValidateOnShow.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2011, 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 7027013 + @summary Dialog.show() should validate the window unconditionally + @author anthony.petrov@oracle.com: area=awt.toplevel + @run main ValidateOnShow +*/ + +import java.awt.*; + +public class ValidateOnShow { + private static Dialog dialog = new Dialog((Frame)null); + private static Panel panel = new Panel() { + @Override + public boolean isValidateRoot() { + return true; + } + }; + private static Button button = new Button("Test"); + + private static void sleep() { + try { Thread.sleep(500); } catch (Exception e) {} + } + + private static void test() { + System.out.println("Before showing: panel.isValid=" + panel.isValid() + " dialog.isValid=" + dialog.isValid()); + dialog.setVisible(true); + sleep(); + System.out.println("After showing: panel.isValid=" + panel.isValid() + " dialog.isValid=" + dialog.isValid()); + + if (!panel.isValid()) { + dialog.dispose(); + throw new RuntimeException("The panel hasn't been validated upon showing the dialog"); + } + + dialog.setVisible(false); + sleep(); + } + + public static void main(String[] args) { + // setup + dialog.add(panel); + panel.add(button); + + dialog.setBounds(200, 200, 300, 200); + + // The first test should always succeed since the dialog is invalid initially + test(); + + // now invalidate the button and the panel + button.setBounds(1, 1, 30, 30); + sleep(); + // since the panel is a validate root, the dialog is still valid + + // w/o a fix this would fail + test(); + + // cleanup + dialog.dispose(); + } +} From f9feed66689b8a6633c2ed93fd95314b231efd49 Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Fri, 8 Apr 2011 18:29:27 +0400 Subject: [PATCH 06/12] 7029832: Buffer overrun at awt_LoadLibrary.c (and java_props_md.c) Reviewed-by: anthony, art --- .../solaris/native/sun/awt/awt_LoadLibrary.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c b/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c index a0e7b43b6d9..fa75aa2d053 100644 --- a/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c +++ b/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c @@ -128,12 +128,12 @@ AWT_OnLoad(JavaVM *vm, void *reserved) } } - /* Calculate toolkit name, kind of toolkit (XAWT, Motif) and library to load */ + /* Calculate library name to load */ if (AWTIsHeadless()) { - strcpy(p, "/headless/libmawt"); + strncpy(p, "/headless/libmawt.so", MAXPATHLEN-len-1); } else { /* Default AWT Toolkit on Linux and Solaris is XAWT. */ - strcpy(p, "/xawt/libmawt"); + strncpy(p, "/xawt/libmawt.so", MAXPATHLEN-len-1); } if (toolkit) { @@ -143,23 +143,12 @@ AWT_OnLoad(JavaVM *vm, void *reserved) (*env)->DeleteLocalRef(env, propname); } - strcat(p, ".so"); - JNU_CallStaticMethodByName(env, NULL, "java/lang/System", "load", "(Ljava/lang/String;)V", JNU_NewStringPlatform(env, buf)); awtHandle = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL); -/* - if (dlsym(awtHandle, "AWTCharRBearing") == NULL) { - printf("========= AWTCharRBearing not found\n"); fflush(stdout); - } - else { - printf("========= AWTCharRBearing was found\n"); fflush(stdout); - } -*/ - return JNI_VERSION_1_2; } From c2d4b9c218f29884f16d0228fa13983061738ea2 Mon Sep 17 00:00:00 2001 From: Anthony Petrov Date: Fri, 8 Apr 2011 17:04:35 +0400 Subject: [PATCH 07/12] 7008513: Case TranslucentJAppletTest.jtr automatically failed due to java.lang.RuntimeException Set transparent background to the applet Reviewed-by: art, dcherepanov --- .../Window/TranslucentJAppletTest/TranslucentJAppletTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java b/jdk/test/java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java index a3a3f6cfe89..26112c89178 100644 --- a/jdk/test/java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java +++ b/jdk/test/java/awt/Window/TranslucentJAppletTest/TranslucentJAppletTest.java @@ -43,6 +43,7 @@ public class TranslucentJAppletTest { private static void initAndShowGUI() { frame = new JFrame(); JApplet applet = new JApplet(); + applet.setBackground(new Color(0, 0, 0, 0)); JPanel panel = new JPanel() { protected void paintComponent(Graphics g) { paintComponentCalled = true; From fc7a236fd5caa1d9db0a45c54a42e66742fefc9a Mon Sep 17 00:00:00 2001 From: Denis Fokin Date: Tue, 12 Apr 2011 19:06:57 +0400 Subject: [PATCH 08/12] 7030062: duplicate free Reviewed-by: dcherepanov --- jdk/make/sun/jpeg/Makefile | 2 +- jdk/src/share/classes/java/awt/Toolkit.java | 33 +++++++++++++++++++++ jdk/src/solaris/native/sun/awt/awt_mgrsel.c | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/jdk/make/sun/jpeg/Makefile b/jdk/make/sun/jpeg/Makefile index 78c53c461a1..ddd8e3bc7a8 100644 --- a/jdk/make/sun/jpeg/Makefile +++ b/jdk/make/sun/jpeg/Makefile @@ -74,7 +74,7 @@ ifeq ($(PLATFORM), linux) # volatile to prevent the optimization. However, this approach does not # work because we have to declare all variables as volatile in result. - OTHER_CFLAGS += -Wno-clobbered +# OTHER_CFLAGS += -Wno-clobbered endif include $(BUILDDIR)/common/Mapfile-vers.gmk diff --git a/jdk/src/share/classes/java/awt/Toolkit.java b/jdk/src/share/classes/java/awt/Toolkit.java index 105bc1bf325..2f474e970e0 100644 --- a/jdk/src/share/classes/java/awt/Toolkit.java +++ b/jdk/src/share/classes/java/awt/Toolkit.java @@ -466,6 +466,10 @@ public abstract class Toolkit { */ protected void loadSystemColors(int[] systemColors) throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } + } /** @@ -500,6 +504,10 @@ public abstract class Toolkit { */ public void setDynamicLayout(boolean dynamic) throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } + } /** @@ -523,6 +531,9 @@ public abstract class Toolkit { */ protected boolean isDynamicLayoutSet() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().isDynamicLayoutSet(); } else { @@ -558,6 +569,9 @@ public abstract class Toolkit { */ public boolean isDynamicLayoutActive() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().isDynamicLayoutActive(); } else { @@ -601,6 +615,9 @@ public abstract class Toolkit { */ public Insets getScreenInsets(GraphicsConfiguration gc) throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getScreenInsets(gc); } else { @@ -1342,6 +1359,9 @@ public abstract class Toolkit { * @since 1.4 */ public Clipboard getSystemSelection() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getSystemSelection(); } else { @@ -1371,6 +1391,10 @@ public abstract class Toolkit { * @since JDK1.1 */ public int getMenuShortcutKeyMask() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } + return Event.CTRL_MASK; } @@ -1499,6 +1523,9 @@ public abstract class Toolkit { */ public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } // Override to implement custom cursor support. if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit(). @@ -1526,6 +1553,9 @@ public abstract class Toolkit { * @since 1.2 */ public int getMaximumCursorColors() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } // Override to implement custom cursor support. if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getMaximumCursorColors(); @@ -2572,6 +2602,9 @@ public abstract class Toolkit { * @since 1.7 */ public boolean areExtraMouseButtonsEnabled() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled(); } } diff --git a/jdk/src/solaris/native/sun/awt/awt_mgrsel.c b/jdk/src/solaris/native/sun/awt/awt_mgrsel.c index a326f3886f6..b0332278980 100644 --- a/jdk/src/solaris/native/sun/awt/awt_mgrsel.c +++ b/jdk/src/solaris/native/sun/awt/awt_mgrsel.c @@ -136,7 +136,7 @@ awt_mgrsel_select(const char *selname, long extra_mask, || per_scr_owners == NULL || mgrsel == NULL) { DTRACE_PRINTLN("MG: select: unable to allocate memory"); - if (namesbuf != NULL) free(per_scr_atoms); + if (namesbuf != NULL) free(namesbuf); if (names != NULL) free(names); if (per_scr_atoms != NULL) free(per_scr_atoms); if (per_scr_owners != NULL) free(per_scr_owners); From 6c09d788597eb5f36f8f80b4aa81b9c8a1cb23c8 Mon Sep 17 00:00:00 2001 From: Denis Fokin Date: Thu, 14 Apr 2011 13:53:08 +0400 Subject: [PATCH 09/12] 7036540: A change for 7021001 and some makefile changes have been pushed as a part of 7030062 Reviewed-by: dcherepanov --- jdk/make/sun/jpeg/Makefile | 2 +- jdk/src/share/classes/java/awt/Toolkit.java | 33 --------------------- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/jdk/make/sun/jpeg/Makefile b/jdk/make/sun/jpeg/Makefile index ddd8e3bc7a8..78c53c461a1 100644 --- a/jdk/make/sun/jpeg/Makefile +++ b/jdk/make/sun/jpeg/Makefile @@ -74,7 +74,7 @@ ifeq ($(PLATFORM), linux) # volatile to prevent the optimization. However, this approach does not # work because we have to declare all variables as volatile in result. -# OTHER_CFLAGS += -Wno-clobbered + OTHER_CFLAGS += -Wno-clobbered endif include $(BUILDDIR)/common/Mapfile-vers.gmk diff --git a/jdk/src/share/classes/java/awt/Toolkit.java b/jdk/src/share/classes/java/awt/Toolkit.java index 2f474e970e0..105bc1bf325 100644 --- a/jdk/src/share/classes/java/awt/Toolkit.java +++ b/jdk/src/share/classes/java/awt/Toolkit.java @@ -466,10 +466,6 @@ public abstract class Toolkit { */ protected void loadSystemColors(int[] systemColors) throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } - } /** @@ -504,10 +500,6 @@ public abstract class Toolkit { */ public void setDynamicLayout(boolean dynamic) throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } - } /** @@ -531,9 +523,6 @@ public abstract class Toolkit { */ protected boolean isDynamicLayoutSet() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().isDynamicLayoutSet(); } else { @@ -569,9 +558,6 @@ public abstract class Toolkit { */ public boolean isDynamicLayoutActive() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().isDynamicLayoutActive(); } else { @@ -615,9 +601,6 @@ public abstract class Toolkit { */ public Insets getScreenInsets(GraphicsConfiguration gc) throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getScreenInsets(gc); } else { @@ -1359,9 +1342,6 @@ public abstract class Toolkit { * @since 1.4 */ public Clipboard getSystemSelection() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getSystemSelection(); } else { @@ -1391,10 +1371,6 @@ public abstract class Toolkit { * @since JDK1.1 */ public int getMenuShortcutKeyMask() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } - return Event.CTRL_MASK; } @@ -1523,9 +1499,6 @@ public abstract class Toolkit { */ public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } // Override to implement custom cursor support. if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit(). @@ -1553,9 +1526,6 @@ public abstract class Toolkit { * @since 1.2 */ public int getMaximumCursorColors() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } // Override to implement custom cursor support. if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getMaximumCursorColors(); @@ -2602,9 +2572,6 @@ public abstract class Toolkit { * @since 1.7 */ public boolean areExtraMouseButtonsEnabled() throws HeadlessException { - if (GraphicsEnvironment.isHeadless()){ - throw new HeadlessException(); - } return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled(); } } From 118113c31f31b44ab191acaf19ac2862cd7914d3 Mon Sep 17 00:00:00 2001 From: Denis Fokin Date: Thu, 14 Apr 2011 13:59:26 +0400 Subject: [PATCH 10/12] 7021001: Default implementation of Toolkit.loadSystemColors(int[]) and many others doesn't throw HE in hl env Reviewed-by: dcherepanov --- jdk/src/share/classes/java/awt/Toolkit.java | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/jdk/src/share/classes/java/awt/Toolkit.java b/jdk/src/share/classes/java/awt/Toolkit.java index 105bc1bf325..2f474e970e0 100644 --- a/jdk/src/share/classes/java/awt/Toolkit.java +++ b/jdk/src/share/classes/java/awt/Toolkit.java @@ -466,6 +466,10 @@ public abstract class Toolkit { */ protected void loadSystemColors(int[] systemColors) throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } + } /** @@ -500,6 +504,10 @@ public abstract class Toolkit { */ public void setDynamicLayout(boolean dynamic) throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } + } /** @@ -523,6 +531,9 @@ public abstract class Toolkit { */ protected boolean isDynamicLayoutSet() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().isDynamicLayoutSet(); } else { @@ -558,6 +569,9 @@ public abstract class Toolkit { */ public boolean isDynamicLayoutActive() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().isDynamicLayoutActive(); } else { @@ -601,6 +615,9 @@ public abstract class Toolkit { */ public Insets getScreenInsets(GraphicsConfiguration gc) throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getScreenInsets(gc); } else { @@ -1342,6 +1359,9 @@ public abstract class Toolkit { * @since 1.4 */ public Clipboard getSystemSelection() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getSystemSelection(); } else { @@ -1371,6 +1391,10 @@ public abstract class Toolkit { * @since JDK1.1 */ public int getMenuShortcutKeyMask() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } + return Event.CTRL_MASK; } @@ -1499,6 +1523,9 @@ public abstract class Toolkit { */ public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } // Override to implement custom cursor support. if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit(). @@ -1526,6 +1553,9 @@ public abstract class Toolkit { * @since 1.2 */ public int getMaximumCursorColors() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } // Override to implement custom cursor support. if (this != Toolkit.getDefaultToolkit()) { return Toolkit.getDefaultToolkit().getMaximumCursorColors(); @@ -2572,6 +2602,9 @@ public abstract class Toolkit { * @since 1.7 */ public boolean areExtraMouseButtonsEnabled() throws HeadlessException { + if (GraphicsEnvironment.isHeadless()){ + throw new HeadlessException(); + } return Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled(); } } From d9212b0817b23c1b239290bf61451a28d096175f Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Thu, 14 Apr 2011 16:16:19 +0400 Subject: [PATCH 11/12] 7032566: Toolkit.areExtraMouseButtonsEnabled() not alws correspnd "sun.awt.enableExtraMouseButtons" sys prop Reviewed-by: art, dcherepanov --- jdk/src/share/classes/java/awt/Toolkit.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/jdk/src/share/classes/java/awt/Toolkit.java b/jdk/src/share/classes/java/awt/Toolkit.java index 2f474e970e0..169084ec5fb 100644 --- a/jdk/src/share/classes/java/awt/Toolkit.java +++ b/jdk/src/share/classes/java/awt/Toolkit.java @@ -2591,8 +2591,6 @@ public abstract class Toolkit { * initialized with {@code true}. * Changing this value after the {@code Toolkit} class initialization will have no effect. *

- * The current value could be queried by using the - * {@code System.getProperty("sun.awt.enableExtraMouseButtons")} method. * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true * @return {@code true} if events from extra mouse buttons are allowed to be processed and posted; * {@code false} otherwise From 30d9e9d6dc71b3352aae3ec72a33d11c2bd6bb4a Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 15 Apr 2011 16:51:25 +0400 Subject: [PATCH 12/12] 6983562: Two java/awt tests failing just on jdk7b108 Reviewed-by: art, denis, dcherepanov --- jdk/src/windows/native/sun/windows/awt_Button.cpp | 4 +++- jdk/src/windows/native/sun/windows/awt_Checkbox.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/jdk/src/windows/native/sun/windows/awt_Button.cpp b/jdk/src/windows/native/sun/windows/awt_Button.cpp index b62069035c1..672d3540c1d 100644 --- a/jdk/src/windows/native/sun/windows/awt_Button.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Button.cpp @@ -317,7 +317,9 @@ void AwtButton::_SetLabel(void *param) badAlloc = 1; } else { c->SetText(labelStr); - JNU_ReleaseStringPlatformChars(env, label, labelStr); + if (label != NULL) { + JNU_ReleaseStringPlatformChars(env, label, labelStr); + } } } diff --git a/jdk/src/windows/native/sun/windows/awt_Checkbox.cpp b/jdk/src/windows/native/sun/windows/awt_Checkbox.cpp index 21f42bea3dd..362c857b88d 100644 --- a/jdk/src/windows/native/sun/windows/awt_Checkbox.cpp +++ b/jdk/src/windows/native/sun/windows/awt_Checkbox.cpp @@ -384,7 +384,9 @@ void AwtCheckbox::_SetLabel(void *param) { c->SetText(labelStr); c->VerifyState(); - JNU_ReleaseStringPlatformChars(env, label, labelStr); + if (label != NULL) { + JNU_ReleaseStringPlatformChars(env, label, labelStr); + } } }