Merge
authorlana
Thu, 09 Feb 2012 23:17:22 -0800
changeset 11815 5561a4c99825
parent 11812 fc06525cb345 (diff)
parent 11746 6c805d8ed4e5 (current diff)
child 11816 9bd62ce55848
Merge
jdk/test/tools/launcher/ChangeDataModel.sh
jdk/test/tools/launcher/CreatePlatformFile.java
jdk/test/tools/launcher/SomeException.java
jdk/test/tools/launcher/UnicodeCleanup.java
jdk/test/tools/launcher/UnicodeTest.sh
jdk/test/tools/launcher/deleteI18n.sh
jdk/test/tools/launcher/i18nTest.sh
jdk/test/tools/launcher/unresolvedExceptions.sh
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java	Wed Jul 05 18:02:34 2017 +0200
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java	Thu Feb 09 23:17:22 2012 -0800
@@ -137,6 +137,11 @@
                 g.setColor(progressBar.getForeground());
                 barRectHeight -= 2;
                 barRectWidth -= 2;
+
+                if (barRectWidth <= 0 || barRectHeight <= 0) {
+                    return;
+                }
+
                 Graphics2D g2 = (Graphics2D)g;
                 g2.setStroke(new BasicStroke((float)(vertical ? barRectWidth : barRectHeight),
                                              BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
--- a/jdk/src/share/classes/javax/swing/JOptionPane.java	Wed Jul 05 18:02:34 2017 +0200
+++ b/jdk/src/share/classes/javax/swing/JOptionPane.java	Thu Feb 09 23:17:22 2012 -0800
@@ -34,7 +34,6 @@
 import java.awt.Frame;
 import java.awt.Point;
 import java.awt.HeadlessException;
-import java.awt.Toolkit;
 import java.awt.Window;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
@@ -994,8 +993,7 @@
                 // if the user closed the window without selecting a button
                 // (newValue = null in that case).  Otherwise, close the dialog.
                 if (dialog.isVisible() && event.getSource() == JOptionPane.this &&
-                        (event.getPropertyName().equals(VALUE_PROPERTY) ||
-                                event.getPropertyName().equals(INPUT_VALUE_PROPERTY)) &&
+                        (event.getPropertyName().equals(VALUE_PROPERTY)) &&
                         event.getNewValue() != null &&
                         event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
                     dialog.setVisible(false);
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java	Wed Jul 05 18:02:34 2017 +0200
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java	Thu Feb 09 23:17:22 2012 -0800
@@ -1236,6 +1236,7 @@
                 int       index = list.locationToIndex(e.getPoint());
 
                 optionPane.setInputValue(list.getModel().getElementAt(index));
+                optionPane.setValue(JOptionPane.OK_OPTION);
             }
         }
 
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Wed Jul 05 18:02:34 2017 +0200
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Thu Feb 09 23:17:22 2012 -0800
@@ -434,6 +434,8 @@
 
         // Empty out the renderer pane, allowing renderers to be gc'ed.
         rendererPane.removeAll();
+
+        paintContext = null;
     }
 
     private void configureRenderer(SynthContext context) {
--- a/jdk/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java	Wed Jul 05 18:02:34 2017 +0200
+++ b/jdk/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java	Thu Feb 09 23:17:22 2012 -0800
@@ -156,7 +156,7 @@
     protected Color borderSelectionColor;
 
     private boolean isDropCell;
-    private boolean fillBackground = true;
+    private boolean fillBackground;
 
     /**
      * Set to true after the constructor has run.
--- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Wed Jul 05 18:02:34 2017 +0200
+++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Thu Feb 09 23:17:22 2012 -0800
@@ -171,6 +171,53 @@
     return array;
 }
 
+/**
+ * Convert a GSList to an array of filenames (with the parent folder)
+ */
+static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list)
+{
+    jstring str;
+    jclass stringCls;
+    GSList *iterator;
+    jobjectArray array;
+    int i;
+    char* entry;
+
+
+    if (list == NULL) {
+        return NULL;
+    }
+
+    stringCls = (*env)->FindClass(env, "java/lang/String");
+    if (stringCls == NULL) {
+        JNU_ThrowInternalError(env, "Could not get java.lang.String class");
+        return NULL;
+    }
+
+    array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls,
+            NULL);
+    if (array == NULL) {
+        JNU_ThrowInternalError(env, "Could not instantiate array files array");
+        return NULL;
+    }
+
+    i = 0;
+    for (iterator = list; iterator; iterator = iterator->next) {
+        entry = (char*) iterator->data;
+
+        //check for leading slash.
+        if (entry[0] == '/') {
+            entry++;
+        }
+
+        str = (*env)->NewStringUTF(env, entry);
+        (*env)->SetObjectArrayElement(env, array, i, str);
+        i++;
+    }
+
+    return array;
+}
+
 static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj)
 {
     JNIEnv *env;
@@ -183,16 +230,25 @@
     env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
     current_folder = NULL;
     filenames = NULL;
+    gboolean full_path_names = FALSE;
 
     if (responseId == GTK_RESPONSE_ACCEPT) {
         current_folder = fp_gtk_file_chooser_get_current_folder(
                 GTK_FILE_CHOOSER(aDialog));
+        if (current_folder == NULL) {
+            full_path_names = TRUE;
+        }
         filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog));
     }
-
-    jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
-    jfilenames = toFilenamesArray(env, filenames);
-
+    if (full_path_names) {
+        //This is a hack for use with "Recent Folders" in gtk where each
+        //file could have its own directory.
+        jcurrent_folder = (*env)->NewStringUTF(env, "/");
+        jfilenames = toPathAndFilenamesArray(env, filenames);
+    } else {
+        jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
+        jfilenames = toFilenamesArray(env, filenames);
+    }
     (*env)->CallVoidMethod(env, obj, setFileInternalMethodID, jcurrent_folder,
             jfilenames);
     fp_g_free(current_folder);
--- a/jdk/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java	Wed Jul 05 18:02:34 2017 +0200
+++ b/jdk/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java	Thu Feb 09 23:17:22 2012 -0800
@@ -96,7 +96,10 @@
 
             // Test mouse wheel over the choice
             String name = Toolkit.getDefaultToolkit().getClass().getName();
-            if(!name.equals("sun.awt.X11.XToolkit")) { // mouse wheel doesn't work for the choice on X11, so skip it
+
+            // mouse wheel doesn't work for the choice on X11 and Mac, so skip it
+            if(!name.equals("sun.awt.X11.XToolkit")
+               && !name.equals("sun.lwawt.macosx.LWCToolkit")) {
                 robot.mouseWheel(1);
                 Util.waitForIdle(robot);
 
--- a/jdk/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java	Wed Jul 05 18:02:34 2017 +0200
+++ b/jdk/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java	Thu Feb 09 23:17:22 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,28 +26,29 @@
  * @bug 6396844
  * @summary Tests memory leak for 20000 files
  * @author Sergey Malenkov
- * @run main/othervm/timeout=1000 -mx256m TwentyThousandTest
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main/othervm/timeout=1000 -mx128m TwentyThousandTest
  */
 
+import sun.java2d.Disposer;
+import sun.java2d.DisposerRecord;
+
 import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.awt.event.HierarchyEvent;
+import java.awt.event.HierarchyListener;
 import java.io.File;
 import java.io.FileWriter;
 
-public class TwentyThousandTest implements ActionListener, Runnable {
+public class TwentyThousandTest {
 
     private static final int FILES = 20000;
-    private static final int ATTEMPTS = 100;
+    private static final int ATTEMPTS = 20;
     private static final int INTERVAL = 100;
 
-    private static final boolean ALWAYS_NEW_INSTANCE = false;
-    private static final boolean UPDATE_UI_EACH_INTERVAL = true;
-    private static final boolean AUTO_CLOSE_DIALOG = true;
+    private static String tmpDir;
 
-    private static JFileChooser CHOOSER;
-
-    private static String tmpDir;
+    private static volatile boolean disposerComplete;
 
     public static void main(String[] args) throws Exception {
         tmpDir = System.getProperty("java.io.tmpdir");
@@ -77,15 +78,13 @@
 
             System.out.println("Do " + ATTEMPTS + " attempts for " + laf.getClassName());
 
-            for ( int i = 0; i < ATTEMPTS; i++ ) {
+            for (int i = 0; i < ATTEMPTS; i++) {
                 System.out.print(i + " ");
 
                 doAttempt();
             }
 
             System.out.println();
-
-            CHOOSER = null;
         }
 
         System.out.println("Removing " + FILES + " files");
@@ -94,7 +93,7 @@
             getTempFile(i).delete();
         }
 
-        System.out.println( "Test passed successfully" );
+        System.out.println("Test passed successfully");
     }
 
     private static File getTempFile(int i) {
@@ -104,48 +103,55 @@
     private static void doAttempt() throws Exception {
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
-                if ( ALWAYS_NEW_INSTANCE || ( CHOOSER == null ) )
-                    CHOOSER = new JFileChooser(tmpDir);
+                final JFileChooser chooser = new JFileChooser(tmpDir);
+
+                chooser.updateUI();
 
-                if ( UPDATE_UI_EACH_INTERVAL )
-                    CHOOSER.updateUI();
+                // Postpone JFileChooser closing until it becomes visible
+                chooser.addHierarchyListener(new HierarchyListener() {
+                    @Override
+                    public void hierarchyChanged(HierarchyEvent e) {
+                        if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
+                            if (chooser.isShowing()) {
+                                Thread thread = new Thread(new Runnable() {
+                                    public void run() {
+                                        try {
+                                            Thread.sleep(INTERVAL);
 
-                if ( AUTO_CLOSE_DIALOG ) {
-                    Thread t = new Thread( new TwentyThousandTest( CHOOSER ) );
-                    t.start();
-                    CHOOSER.showOpenDialog( null );
-                } else {
-                    CHOOSER.showOpenDialog( null );
-                }
+                                            // Close JFileChooser
+                                            SwingUtilities.invokeLater(new Runnable() {
+                                                public void run() {
+                                                    chooser.cancelSelection();
+                                                }
+                                            });
+                                        } catch (InterruptedException e) {
+                                            throw new RuntimeException(e);
+                                        }
+                                    }
+                                });
+
+                                thread.start();
+                            }
+                        }
+                    }
+                });
+
+                chooser.showOpenDialog(null);
             }
         });
 
-        // Allow to collect garbage by GC
-        Thread.sleep(1000);
-
-        System.gc();
-    }
-
-    private final JFileChooser chooser;
-
-    TwentyThousandTest( JFileChooser chooser ) {
-        this.chooser = chooser;
-    }
+        DisposerRecord disposerRecord = new DisposerRecord() {
+            public void dispose() {
+                disposerComplete = true;
+            }
+        };
 
-    public void run() {
-        while ( !this.chooser.isShowing() ) {
-            try {
-                Thread.sleep( 30 );
-            } catch ( InterruptedException exception ) {
-                exception.printStackTrace();
-            }
+        disposerComplete = false;
+
+        Disposer.addRecord(new Object(), disposerRecord);
+
+        while (!disposerComplete) {
+            Util.generateOOME();
         }
-        Timer timer = new Timer( INTERVAL, this );
-        timer.setRepeats( false );
-        timer.start();
-    }
-
-    public void actionPerformed( ActionEvent event ) {
-        this.chooser.cancelSelection();
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JOptionPane/7138665/bug7138665.java	Thu Feb 09 23:17:22 2012 -0800
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 7138665
+   @summary JOptionPane.getValue() unexpected change between JRE 1.6 and JRE 1.7
+   @author Pavel Porvatov
+*/
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+
+public class bug7138665 {
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeLater(new Runnable() {
+            @Override
+            public void run() {
+                JOptionPane pane = new JOptionPane("Enter value", JOptionPane.QUESTION_MESSAGE,
+                        JOptionPane.OK_CANCEL_OPTION, null, null, null);
+                pane.setWantsInput(true);
+
+                JDialog dialog = pane.createDialog(null, "My Dialog");
+                dialog.setVisible(true);
+
+                Object result = pane.getValue();
+
+                if (result == null || ((Integer) result).intValue() != JOptionPane.OK_OPTION) {
+                    throw new RuntimeException("Invalid result: " + result);
+                }
+
+                System.out.println("Test bug7138665 passed");
+            }
+        });
+
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+        toolkit.realSync();
+
+        Robot robot = new Robot();
+
+        robot.setAutoDelay(100);
+        robot.keyPress(KeyEvent.VK_ENTER);
+        robot.keyRelease(KeyEvent.VK_ENTER);
+
+        toolkit.realSync();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JProgressBar/7141573/bug7141573.java	Thu Feb 09 23:17:22 2012 -0800
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 7141573
+   @summary JProgressBar resize exception, if setStringPainted in Windows LAF
+   @author Pavel Porvatov
+*/
+
+import javax.swing.*;
+import java.awt.image.BufferedImage;
+
+public class bug7141573 {
+    public static void main(String[] args) throws Exception {
+        try {
+            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
+        } catch (Exception e) {
+            System.out.println("WindowsLookAndFeel is not supported. The test bug7141573 is skipped.");
+
+            return;
+        }
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);
+
+                JProgressBar bar = new JProgressBar();
+
+                bar.setStringPainted(true);
+
+                bar.setSize(100, 1);
+                bar.paint(image.getGraphics());
+
+                bar.setSize(1, 100);
+                bar.paint(image.getGraphics());
+
+                System.out.println("The test bug7141573 is passed.");
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/tree/DefaultTreeCellRenderer/7142955/bug7142955.java	Thu Feb 09 23:17:22 2012 -0800
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 7142955
+   @summary DefaultTreeCellRenderer doesn't honor 'Tree.rendererFillBackground' LAF property
+   @author Pavel Porvatov
+*/
+
+import javax.swing.*;
+import javax.swing.tree.DefaultTreeCellRenderer;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+public class bug7142955 {
+    private static final Color TEST_COLOR = Color.RED;
+
+    public static void main(String[] args) throws Exception {
+        UIManager.put("Tree.rendererFillBackground", Boolean.FALSE);
+        UIManager.put("Tree.textBackground", TEST_COLOR);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                int w = 200;
+                int h = 100;
+
+                BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
+
+                Graphics g = image.getGraphics();
+
+                g.setColor(Color.WHITE);
+                g.fillRect(0, 0, image.getWidth(), image.getHeight());
+
+                DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
+
+                renderer.setSize(w, h);
+                renderer.paint(g);
+
+                for (int y = 0; y < h; y++) {
+                    for (int x = 0; x < w; x++) {
+                        if (image.getRGB(x, y) == TEST_COLOR.getRGB()) {
+                            throw new RuntimeException("Test bug7142955 failed");
+                        }
+                    }
+                }
+
+                System.out.println("Test bug7142955 passed.");
+            }
+        });
+    }
+}