Merge
authorlana
Tue, 08 Feb 2011 14:19:54 -0800
changeset 8150 0a3a7198c1c8
parent 8137 efd894717b2c (current diff)
parent 8149 768769e3cddd (diff)
child 8191 c9d1e3a6d6a2
Merge
--- a/jdk/src/share/classes/java/util/Locale.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/java/util/Locale.java	Tue Feb 08 14:19:54 2011 -0800
@@ -1265,7 +1265,9 @@
         StringBuilder buf = new StringBuilder();
 
         String subtag = tag.getLanguage();
-        buf.append(LanguageTag.canonicalizeLanguage(subtag));
+        if (subtag.length() > 0) {
+            buf.append(LanguageTag.canonicalizeLanguage(subtag));
+        }
 
         subtag = tag.getScript();
         if (subtag.length() > 0) {
@@ -1294,7 +1296,10 @@
 
         subtag = tag.getPrivateuse();
         if (subtag.length() > 0) {
-            buf.append(LanguageTag.SEP).append(LanguageTag.PRIVATEUSE).append(LanguageTag.SEP);
+            if (buf.length() > 0) {
+                buf.append(LanguageTag.SEP);
+            }
+            buf.append(LanguageTag.PRIVATEUSE).append(LanguageTag.SEP);
             // preserve casing
             buf.append(subtag);
         }
--- a/jdk/src/share/classes/java/util/spi/LocaleNameProvider.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/java/util/spi/LocaleNameProvider.java	Tue Feb 08 14:19:54 2011 -0800
@@ -77,7 +77,7 @@
      * is "Cyrl" and <code>locale</code> is fr_FR, getDisplayScript() will return "cyrillique".
      * If the name returned cannot be localized according to <code>locale</code>,
      * (say, the provider does not have a Japanese name for Cyrillic),
-     * this method returns null.
+     * this method returns null. The default implementation returns null.
      * @param scriptCode the four letter script code string in the form of title-case
      *     letters (the first letter is upper-case character between 'A' (U+0041) and
      *     'Z' (U+005A) followed by three lower-case character between 'a' (U+0061)
--- a/jdk/src/share/classes/javax/swing/BorderFactory.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/BorderFactory.java	Tue Feb 08 14:19:54 2011 -0800
@@ -159,9 +159,6 @@
      * Creates a beveled border of the specified type, using
      * the specified colors for the inner and outer highlight
      * and shadow areas.
-     * <p>
-     * Note: The shadow inner and outer colors are
-     * switched for a lowered bevel border.
      *
      * @param type  an integer specifying either
      *          <code>BevelBorder.LOWERED</code> or
--- a/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java	Tue Feb 08 14:19:54 2011 -0800
@@ -209,7 +209,7 @@
                 synchronized(BufferStrategyPaintManager.this) {
                     while (showing) {
                         try {
-                            wait();
+                            BufferStrategyPaintManager.this.wait();
                         } catch (InterruptedException ie) {
                         }
                     }
--- a/jdk/src/share/classes/javax/swing/ToolTipManager.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/ToolTipManager.java	Tue Feb 08 14:19:54 2011 -0800
@@ -75,6 +75,9 @@
     private MouseMotionListener moveBeforeEnterListener = null;
     private KeyListener accessibilityKeyListener = null;
 
+    private KeyStroke postTip;
+    private KeyStroke hideTip;
+
     // PENDING(ges)
     protected boolean lightWeightPopupEnabled = true;
     protected boolean heavyWeightPopupEnabled = false;
@@ -89,6 +92,9 @@
 
         moveBeforeEnterListener = new MoveBeforeEnterListener();
         accessibilityKeyListener = new AccessibilityKeyListener();
+
+        postTip = KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.CTRL_MASK);
+        hideTip =  KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
     }
 
     /**
@@ -805,13 +811,13 @@
         public void keyPressed(KeyEvent e) {
             if (!e.isConsumed()) {
                 JComponent source = (JComponent) e.getComponent();
-                if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+                KeyStroke keyStrokeForEvent = KeyStroke.getKeyStrokeForEvent(e);
+                if (hideTip.equals(keyStrokeForEvent)) {
                     if (tipWindow != null) {
                         hide(source);
                         e.consume();
                     }
-                } else if (e.getKeyCode() == KeyEvent.VK_F1
-                        && e.getModifiers() == Event.CTRL_MASK) {
+                } else if (postTip.equals(keyStrokeForEvent)) {
                     // Shown tooltip will be hidden
                     ToolTipManager.this.show(source);
                     e.consume();
--- a/jdk/src/share/classes/javax/swing/border/BevelBorder.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/border/BevelBorder.java	Tue Feb 08 14:19:54 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2010, 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,7 +26,6 @@
 
 import java.awt.Graphics;
 import java.awt.Insets;
-import java.awt.Rectangle;
 import java.awt.Color;
 import java.awt.Component;
 import java.beans.ConstructorProperties;
@@ -82,9 +81,6 @@
     /**
      * Creates a bevel border with the specified type, highlight and
      * shadow colors.
-     * <p>
-     * Note: The shadow inner and outer colors are
-     * switched for a lowered bevel border.
      *
      * @param bevelType the type of bevel for the border
      * @param highlightOuterColor the color to use for the bevel outer highlight
--- a/jdk/src/share/classes/javax/swing/border/StrokeBorder.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/border/StrokeBorder.java	Tue Feb 08 14:19:54 2011 -0800
@@ -88,6 +88,10 @@
     /**
      * Paints the border for the specified component
      * with the specified position and size.
+     * If the border was not specified with a {@link Paint} object,
+     * the component's foreground color will be used to render the border.
+     * If the component's foreground color is not available,
+     * the default color of the {@link Graphics} object will be used.
      *
      * @param c       the component for which this border is being painted
      * @param g       the paint graphics
@@ -96,7 +100,7 @@
      * @param width   the width of the painted border
      * @param height  the height of the painted border
      *
-     * @throws NullPointerException if the specified {@code c} or {@code g} are {@code null}
+     * @throws NullPointerException if the specified {@code g} is {@code null}
      */
     @Override
     public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
@@ -106,7 +110,7 @@
             if (g instanceof Graphics2D) {
                 Graphics2D g2d = (Graphics2D) g;
                 g2d.setStroke(this.stroke);
-                g2d.setPaint(this.paint != null ? this.paint : c.getForeground());
+                g2d.setPaint(this.paint != null ? this.paint : c == null ? null : c.getForeground());
                 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                      RenderingHints.VALUE_ANTIALIAS_ON);
                 g2d.draw(new Rectangle2D.Float(x + size / 2, y + size / 2, width - size, height - size));
@@ -118,13 +122,17 @@
     /**
      * Reinitializes the {@code insets} parameter
      * with this border's current insets.
-     * All insets are equal to the line width of the stroke.
+     * Every inset is the smallest (closest to negative infinity) integer value
+     * that is greater than or equal to the line width of the stroke
+     * that is used to paint the border.
      *
      * @param c       the component for which this border insets value applies
      * @param insets  the {@code Insets} object to be reinitialized
      * @return the reinitialized {@code insets} parameter
      *
      * @throws NullPointerException if the specified {@code insets} is {@code null}
+     *
+     * @see Math#ceil
      */
     @Override
     public Insets getBorderInsets(Component c, Insets insets) {
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java	Tue Feb 08 14:19:54 2011 -0800
@@ -1721,6 +1721,7 @@
                         editor.setFont( comboBox.getFont() );
                     }
                     isMinimumSizeDirty = true;
+                    isDisplaySizeDirty = true;
                     comboBox.validate();
                 }
                 else if ( propertyName == JComponent.TOOL_TIP_TEXT_KEY ) {
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java	Tue Feb 08 14:19:54 2011 -0800
@@ -342,12 +342,10 @@
 
         setOrientation(splitPane.getOrientation());
 
-        // This plus 2 here is to provide backwards consistancy. Previously,
-        // the old size did not include the 2 pixel border around the divider,
-        // it now does.
-        Integer dividerSize = (Integer)UIManager.get("SplitPane.dividerSize");
-        if (divider == null) dividerSize = 10;
-        LookAndFeel.installProperty(splitPane, "dividerSize", dividerSize);
+        // note: don't rename this temp variable to dividerSize
+        // since it will conflict with "this.dividerSize" field
+        Integer temp = (Integer)UIManager.get("SplitPane.dividerSize");
+        LookAndFeel.installProperty(splitPane, "dividerSize", temp == null? 10: temp);
 
         divider.setDividerSize(splitPane.getDividerSize());
         dividerSize = divider.getDividerSize();
--- a/jdk/src/share/classes/javax/swing/text/JTextComponent.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/text/JTextComponent.java	Tue Feb 08 14:19:54 2011 -0800
@@ -4822,6 +4822,7 @@
      * @return  {@code true} if the composed text exists and is saved,
      *          {@code false} otherwise
      * @see #restoreComposedText
+     * @since 1.7
      */
     protected boolean saveComposedText(int pos) {
         if (composedTextExists()) {
@@ -4845,6 +4846,7 @@
      * should be invoked only if {@code saveComposedText} returns {@code true}.
      *
      * @see #saveComposedText
+     * @since 1.7
      */
     protected void restoreComposedText() {
         Document doc = getDocument();
--- a/jdk/src/share/classes/javax/swing/text/Keymap.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/text/Keymap.java	Tue Feb 08 14:19:54 2011 -0800
@@ -137,6 +137,8 @@
     /**
      * Sets the parent keymap, which will be used to
      * resolve key-bindings.
+     * The behavior is unspecified if a {@code Keymap} has itself
+     * as one of its resolve parents.
      *
      * @param parent the parent keymap
      */
--- a/jdk/src/share/classes/sun/swing/WindowsPlacesBar.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/sun/swing/WindowsPlacesBar.java	Tue Feb 08 14:19:54 2011 -0800
@@ -120,6 +120,7 @@
                 buttons[i].setForeground(fgColor);
             }
             buttons[i].setMargin(new Insets(3, 2, 1, 2));
+            buttons[i].setFocusPainted(false);
             buttons[i].setIconTextGap(0);
             buttons[i].setHorizontalTextPosition(JToggleButton.CENTER);
             buttons[i].setVerticalTextPosition(JToggleButton.BOTTOM);
--- a/jdk/src/share/classes/sun/util/locale/LanguageTag.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/src/share/classes/sun/util/locale/LanguageTag.java	Tue Feb 08 14:19:54 2011 -0800
@@ -421,11 +421,11 @@
         String region = baseLocale.getRegion();
         String variant = baseLocale.getVariant();
 
+        boolean hasSubtag = false;
+
         String privuseVar = null;   // store ill-formed variant subtags
 
-        if (language.length() == 0 || !isLanguage(language)) {
-            tag._language = UNDETERMINED;
-        } else {
+        if (language.length() > 0 && isLanguage(language)) {
             // Convert a deprecated language code used by Java to
             // a new code
             if (language.equals("iw")) {
@@ -440,10 +440,12 @@
 
         if (script.length() > 0 && isScript(script)) {
             tag._script = canonicalizeScript(script);
+            hasSubtag = true;
         }
 
         if (region.length() > 0 && isRegion(region)) {
             tag._region = canonicalizeRegion(region);
+            hasSubtag = true;
         }
 
         // Special handling for no_NO_NY - use nn_NO for language tag
@@ -468,6 +470,7 @@
             }
             if (variants != null) {
                 tag._variants = variants;
+                hasSubtag = true;
             }
             if (!varitr.isDone()) {
                 // ill-formed variant subtags
@@ -508,6 +511,7 @@
 
         if (extensions != null) {
             tag._extensions = extensions;
+            hasSubtag = true;
         }
 
         // append ill-formed variant subtags to private use
@@ -521,8 +525,12 @@
 
         if (privateuse != null) {
             tag._privateuse = privateuse;
-        } else if (tag._language.length() == 0) {
-            // use "und" if neither language nor privateuse is available
+        }
+
+        if (tag._language.length() == 0 && (hasSubtag || privateuse == null)) {
+            // use lang "und" when 1) no language is available AND
+            // 2) any of other subtags other than private use are available or
+            // no private use tag is available
             tag._language = UNDETERMINED;
         }
 
--- a/jdk/test/java/util/Locale/LocaleEnhanceTest.java	Tue Feb 08 14:19:11 2011 -0800
+++ b/jdk/test/java/util/Locale/LocaleEnhanceTest.java	Tue Feb 08 14:19:54 2011 -0800
@@ -478,6 +478,23 @@
             Locale locale = new Locale(test[0], test[1], test[2]);
             assertEquals("case " + i, test[3], locale.toLanguageTag());
         }
+
+        // test locales created from forLanguageTag
+        String[][] tests1 = {
+            // case is normalized during the round trip
+            { "EN-us", "en-US" },
+            { "en-Latn-US", "en-Latn-US" },
+            // reordering Unicode locale extensions
+            { "de-u-co-phonebk-ca-gregory", "de-u-ca-gregory-co-phonebk" },
+            // private use only language tag is preserved (no extra "und")
+            { "x-elmer", "x-elmer" },
+            { "x-lvariant-JP", "x-lvariant-JP" },
+        };
+        for (String[] test : tests1) {
+            Locale locale = Locale.forLanguageTag(test[0]);
+            assertEquals("case " + test[0], test[1], locale.toLanguageTag());
+        }
+
     }
 
     public void testForLanguageTag() {
@@ -488,9 +505,9 @@
 
         String[][] tests = {
             // private use tags only
-            { "x-abc", "und-x-abc" },
-            { "x-a-b-c", "und-x-a-b-c" },
-            { "x-a-12345678", "und-x-a-12345678" },
+            { "x-abc", "x-abc" },
+            { "x-a-b-c", "x-a-b-c" },
+            { "x-a-12345678", "x-a-12345678" },
 
             // grandfathered tags with preferred mappings
             { "i-ami", "ami" },
@@ -517,7 +534,7 @@
             // grandfathered irregular tags, no preferred mappings, drop illegal fields
             // from end.  If no subtag is mappable, fallback to 'und'
             { "i-default", "en-x-i-default" },
-            { "i-enochian", "und-x-i-enochian" },
+            { "i-enochian", "x-i-enochian" },
             { "i-mingo", "see-x-i-mingo" },
             { "en-GB-oed", "en-GB-x-oed" },
             { "zh-min", "nan-x-zh-min" },
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/RepaintManager/7013453/bug7013453.java	Tue Feb 08 14:19:54 2011 -0800
@@ -0,0 +1,103 @@
+/*
+ * 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 7013453
+   @summary BufferStrategyPaintManager.dispose will cause IllegalMonitorStateException in event thread
+   @author Pavel Porvatov
+*/
+
+import javax.swing.*;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+public class bug7013453 {
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                try {
+                    Method getPaintManagerMethod = RepaintManager.class.getDeclaredMethod("getPaintManager");
+
+                    getPaintManagerMethod.setAccessible(true);
+
+                    final Object paintManager = getPaintManagerMethod.invoke(RepaintManager.currentManager(new JLabel()));
+
+                    String paintManagerName = paintManager.getClass().getCanonicalName();
+
+                    if (!paintManagerName.equals("javax.swing.BufferStrategyPaintManager")) {
+                        System.out.println("The test is not suitable for the " + paintManagerName +
+                                " paint manager. The test skipped.");
+
+                        return;
+                    }
+
+                    final Field showingField = paintManager.getClass().getDeclaredField("showing");
+
+                    showingField.setAccessible(true);
+
+                    synchronized (paintManager) {
+                        showingField.setBoolean(paintManager, true);
+                    }
+
+                    // Postpone reset the showing field
+                    Thread thread = new Thread(new Runnable() {
+                        public void run() {
+                            try {
+                                Thread.sleep(500);
+                            } catch (InterruptedException e) {
+                                throw new RuntimeException(e);
+                            }
+
+                            synchronized (paintManager) {
+                                try {
+                                    showingField.setBoolean(paintManager, false);
+                                } catch (IllegalAccessException e) {
+                                    throw new RuntimeException(e);
+                                }
+                            }
+                        }
+                    });
+
+                    thread.start();
+
+                    Method disposeMethod = paintManager.getClass().getDeclaredMethod("dispose");
+
+                    disposeMethod.setAccessible(true);
+
+                    disposeMethod.invoke(paintManager);
+
+                    System.out.println("The test passed.");
+                } catch (NoSuchMethodException e) {
+                    throw new RuntimeException(e);
+                } catch (InvocationTargetException e) {
+                    throw new RuntimeException(e);
+                } catch (IllegalAccessException e) {
+                    throw new RuntimeException(e);
+                } catch (NoSuchFieldException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        });
+    }
+}