From cdf0f01c92a73c44d69eb26b6c2a01798d2f2bf2 Mon Sep 17 00:00:00 2001 From: Pavel Porvatov Date: Thu, 7 Oct 2010 12:48:16 +0400 Subject: [PATCH 01/12] 6979793: closed/javax/swing/JFileChooser/6396844/TwentyThousandTest fails due FileNotFound exc Reviewed-by: malenkov --- .../6396844/TwentyThousandTest.java | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 jdk/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java diff --git a/jdk/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java b/jdk/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java new file mode 100644 index 00000000000..2e244a380d6 --- /dev/null +++ b/jdk/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 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 + * 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 6396844 + * @summary Tests memory leak for 20000 files + * @author Sergey Malenkov + * @run main/othervm/timeout=1000 -mx256m TwentyThousandTest + */ + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileWriter; + +public class TwentyThousandTest implements ActionListener, Runnable { + + private static final int FILES = 20000; + private static final int ATTEMPTS = 100; + 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 JFileChooser CHOOSER; + + private static String tmpDir; + + public static void main(String[] args) throws Exception { + tmpDir = System.getProperty("java.io.tmpdir"); + + if (tmpDir.length() == 0) { //'java.io.tmpdir' isn't guaranteed to be defined + tmpDir = System.getProperty("user.home"); + } + + System.out.println("Temp directory: " + tmpDir); + + System.out.println("Creating " + FILES + " files"); + + for (int i = 0; i < FILES; i++) { + File file = getTempFile(i); + + FileWriter writer = new FileWriter(file); + writer.write("File " + i); + writer.close(); + } + + for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { + if (laf.getClassName().contains("Motif")) { + continue; + } + + UIManager.setLookAndFeel(laf.getClassName()); + + System.out.println("Do " + ATTEMPTS + " attempts for " + laf.getClassName()); + + for ( int i = 0; i < ATTEMPTS; i++ ) { + System.out.print(i + " "); + + doAttempt(); + } + + System.out.println(); + + CHOOSER = null; + } + + System.out.println("Removing " + FILES + " files"); + + for (int i = 0; i < FILES; i++) { + getTempFile(i).delete(); + } + + System.out.println( "Test passed successfully" ); + } + + private static File getTempFile(int i) { + return new File(tmpDir, "temp" + i + ".txt"); + } + + private static void doAttempt() throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + if ( ALWAYS_NEW_INSTANCE || ( CHOOSER == null ) ) + CHOOSER = new JFileChooser(tmpDir); + + if ( UPDATE_UI_EACH_INTERVAL ) + CHOOSER.updateUI(); + + if ( AUTO_CLOSE_DIALOG ) { + Thread t = new Thread( new TwentyThousandTest( CHOOSER ) ); + t.start(); + CHOOSER.showOpenDialog( null ); + } else { + CHOOSER.showOpenDialog( null ); + } + } + }); + + // Allow to collect garbage by GC + Thread.sleep(1000); + + System.gc(); + } + + private final JFileChooser chooser; + + TwentyThousandTest( JFileChooser chooser ) { + this.chooser = chooser; + } + + public void run() { + while ( !this.chooser.isShowing() ) { + try { + Thread.sleep( 30 ); + } catch ( InterruptedException exception ) { + exception.printStackTrace(); + } + } + Timer timer = new Timer( INTERVAL, this ); + timer.setRepeats( false ); + timer.start(); + } + + public void actionPerformed( ActionEvent event ) { + this.chooser.cancelSelection(); + } +} From 1e7137761d9a750e9417c537b07bf4f5108c5ecd Mon Sep 17 00:00:00 2001 From: Alex Menkov Date: Thu, 7 Oct 2010 18:13:20 +0400 Subject: [PATCH 02/12] 6984047: sound sources needs vendor rebranding changes (jdk7 only) Reviewed-by: ohair --- .../share/classes/com/sun/media/sound/RealTimeSequencer.java | 2 +- jdk/src/share/classes/javax/sound/sampled/AudioSystem.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java b/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java index a66d672f258..96ea4775fe4 100644 --- a/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java +++ b/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java @@ -1069,7 +1069,7 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon private static class RealTimeSequencerInfo extends MidiDevice.Info { private static final String name = "Real Time Sequencer"; - private static final String vendor = "Sun Microsystems"; + private static final String vendor = "Oracle Corporation"; private static final String description = "Software sequencer"; private static final String version = "Version 1.0"; diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java index d5f4e38c94e..3724cc2cdac 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java @@ -63,7 +63,7 @@ import com.sun.media.sound.JDK13Services; *

Properties can be used to specify the default mixer * for specific line types. * Both system properties and a properties file are considered. - * In the Sun reference implementation, the properties file is + * In the Oracle reference implementation, the properties file is * "lib/sound.properties" in the JRE * directory. If a property exists both as a system property and in the * properties file, the system property takes precedence. If none is From b6584fa0ab933043fadc719d2050d96ab0a85edf Mon Sep 17 00:00:00 2001 From: Alex Menkov Date: Thu, 7 Oct 2010 18:23:13 +0400 Subject: [PATCH 03/12] 6986335: 10 regtest failures (test/javax/sound/midi/Gervil) due AudioFloatConverter.PCM_FLOAT not found Reviewed-by: dav --- .../midi/Gervill/AudioFloatConverter/ToFloatArray.java | 2 +- .../Gervill/SoftAudioSynthesizer/DummySourceDataLine.java | 8 ++++---- .../midi/Gervill/SoftSynthesizer/DummySourceDataLine.java | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/jdk/test/javax/sound/midi/Gervill/AudioFloatConverter/ToFloatArray.java b/jdk/test/javax/sound/midi/Gervill/AudioFloatConverter/ToFloatArray.java index 639b9db34e9..52c0491f101 100644 --- a/jdk/test/javax/sound/midi/Gervill/AudioFloatConverter/ToFloatArray.java +++ b/jdk/test/javax/sound/midi/Gervill/AudioFloatConverter/ToFloatArray.java @@ -47,7 +47,7 @@ public class ToFloatArray { for (int big = 0; big < 2; big+=1) for (int bits = 32; bits <= 64; bits+=32) { AudioFormat frm = new AudioFormat( - AudioFloatConverter.PCM_FLOAT, + AudioFormat.Encoding.PCM_FLOAT, 44100, bits, 1, bits/8, 44100, big==1); byte[] buff = new byte[testarray.length * frm.getFrameSize()]; diff --git a/jdk/test/javax/sound/midi/Gervill/SoftAudioSynthesizer/DummySourceDataLine.java b/jdk/test/javax/sound/midi/Gervill/SoftAudioSynthesizer/DummySourceDataLine.java index ae8ea108971..9f3ff0c956a 100644 --- a/jdk/test/javax/sound/midi/Gervill/SoftAudioSynthesizer/DummySourceDataLine.java +++ b/jdk/test/javax/sound/midi/Gervill/SoftAudioSynthesizer/DummySourceDataLine.java @@ -84,16 +84,16 @@ public class DummySourceDataLine implements SourceDataLine { AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, true)); } - formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, + formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, false)); - formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, + formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, true)); - formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, + formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, false)); - formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, + formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, true)); } diff --git a/jdk/test/javax/sound/midi/Gervill/SoftSynthesizer/DummySourceDataLine.java b/jdk/test/javax/sound/midi/Gervill/SoftSynthesizer/DummySourceDataLine.java index ae8ea108971..9f3ff0c956a 100644 --- a/jdk/test/javax/sound/midi/Gervill/SoftSynthesizer/DummySourceDataLine.java +++ b/jdk/test/javax/sound/midi/Gervill/SoftSynthesizer/DummySourceDataLine.java @@ -84,16 +84,16 @@ public class DummySourceDataLine implements SourceDataLine { AudioSystem.NOT_SPECIFIED, bits, channels, channels * bits / 8, AudioSystem.NOT_SPECIFIED, true)); } - formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, + formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, false)); - formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, + formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 32, channels, channels * 4, AudioSystem.NOT_SPECIFIED, true)); - formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, + formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, false)); - formats.add(new AudioFormat(AudioFloatConverter.PCM_FLOAT, + formats.add(new AudioFormat(Encoding.PCM_FLOAT, AudioSystem.NOT_SPECIFIED, 64, channels, channels * 8, AudioSystem.NOT_SPECIFIED, true)); } From 55f7d8222a6844ff8b492c5df17dee7ae26b64d2 Mon Sep 17 00:00:00 2001 From: Yuka Kamiya Date: Fri, 8 Oct 2010 09:50:56 +0900 Subject: [PATCH 04/12] 6970930: RuleBasedCollator.compare(String,null) throws IAE (should be NPE) Reviewed-by: okutsu --- .../classes/java/text/RuleBasedCollator.java | 6 ++ jdk/test/java/text/Collator/Bug6970930.java | 78 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 jdk/test/java/text/Collator/Bug6970930.java diff --git a/jdk/src/share/classes/java/text/RuleBasedCollator.java b/jdk/src/share/classes/java/text/RuleBasedCollator.java index 8d5aa510913..495ca917992 100644 --- a/jdk/src/share/classes/java/text/RuleBasedCollator.java +++ b/jdk/src/share/classes/java/text/RuleBasedCollator.java @@ -335,9 +335,15 @@ public class RuleBasedCollator extends Collator{ * collation rules. Returns information about whether a string is less * than, greater than or equal to another string in a language. * This can be overriden in a subclass. + * + * @exception NullPointerException if source or target is null. */ public synchronized int compare(String source, String target) { + if (source == null || target == null) { + throw new NullPointerException(); + } + // The basic algorithm here is that we use CollationElementIterators // to step through both the source and target strings. We compare each // collation element in the source string against the corresponding one diff --git a/jdk/test/java/text/Collator/Bug6970930.java b/jdk/test/java/text/Collator/Bug6970930.java new file mode 100644 index 00000000000..f20cd831a9b --- /dev/null +++ b/jdk/test/java/text/Collator/Bug6970930.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 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 + * 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 6970930 + * @summary verify that compare() throws NPE instead of IAE when an argument is null. + */ +import java.text.*; + +public class Bug6970930 { + + private static boolean err = false; + + public static void main(String[] args) { + // Check if compare() throws NPE. + test1(null, null); + test1("\"foo\"", null); + test1(null, "\"bar\""); + + if (err) { + throw new RuntimeException("Failed."); + } else { + System.out.println("Passed."); + } + } + + private static void test1(String s1, String s2) { + RuleBasedCollator col = null; + + try { + col = new RuleBasedCollator("< a < b"); + } + catch (ParseException e) { + err = true; + System.err.println(e); + } + + try { + col.compare("foo", "bar"); // This line is necessary to reproduce the bug. + col.compare(s1, s2); + + err = true; + System.err.println("No exception was thrown for compare(" + + s1 + ", " + s2 + ")."); + } + catch (NullPointerException e) { + System.out.println("NPE was thrown as expected for compare(" + + s1 + ", " + s2 + ")."); + } + catch (Exception e) { + err = true; + System.err.println("Unexpected exception was thrown for compare(" + + s1 + ", " + s2 + "): " + e); + } + } + +} From 822884735dbaa7fb94f4b14143a6cdfb64b9fd47 Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Tue, 12 Oct 2010 17:09:14 -0700 Subject: [PATCH 05/12] 6989440: tomcat test from dacapo benchmark fails with ConcurrentModificationException Reviewed-by: okutsu --- .../sun/util/LocaleServiceProviderPool.java | 16 +++-- jdk/test/java/util/Locale/Bug6989440.java | 62 +++++++++++++++++++ 2 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 jdk/test/java/util/Locale/Bug6989440.java diff --git a/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java b/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java index 8c45c6fd6c9..5b6c04e883b 100644 --- a/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java +++ b/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java @@ -84,7 +84,7 @@ public final class LocaleServiceProviderPool { * static. This could be non-static later, so that they could have * different sets for each locale sensitive services. */ - private static List availableJRELocales = null; + private static volatile List availableJRELocales = null; /** * Provider locales for this locale sensitive service. @@ -252,12 +252,16 @@ public final class LocaleServiceProviderPool { * * @return list of the available JRE locales */ - private synchronized List getJRELocales() { + private List getJRELocales() { if (availableJRELocales == null) { - Locale[] allLocales = LocaleData.getAvailableLocales(); - availableJRELocales = new ArrayList(allLocales.length); - for (Locale locale : allLocales) { - availableJRELocales.add(getLookupLocale(locale)); + synchronized (LocaleServiceProviderPool.class) { + if (availableJRELocales == null) { + Locale[] allLocales = LocaleData.getAvailableLocales(); + availableJRELocales = new ArrayList(allLocales.length); + for (Locale locale : allLocales) { + availableJRELocales.add(getLookupLocale(locale)); + } + } } } return availableJRELocales; diff --git a/jdk/test/java/util/Locale/Bug6989440.java b/jdk/test/java/util/Locale/Bug6989440.java new file mode 100644 index 00000000000..ebf62f98807 --- /dev/null +++ b/jdk/test/java/util/Locale/Bug6989440.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 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 + * 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 6989440 + * @summary Verify ConcurrentModificationException is not thrown with multiple + * thread accesses. + * @compile -XDignore.symbol.file=true Bug6989440.java + * @run main Bug6989440 + */ +import java.text.spi.DateFormatProvider; +import java.util.spi.LocaleNameProvider; +import java.util.spi.LocaleServiceProvider; +import java.util.spi.TimeZoneNameProvider; + +import sun.util.LocaleServiceProviderPool; + +public class Bug6989440 { + public static void main(String[] args) { + TestThread t1 = new TestThread(LocaleNameProvider.class); + TestThread t2 = new TestThread(TimeZoneNameProvider.class); + TestThread t3 = new TestThread(DateFormatProvider.class); + + t1.start(); + t2.start(); + t3.start(); + } + + static class TestThread extends Thread { + private Class cls; + + public TestThread(Class providerClass) { + cls = providerClass; + } + + public void run() { + LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(cls); + pool.getAvailableLocales(); + } + } +} From 571e75371e8253db32c7ea29a0597c1e3f51ea3b Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Wed, 13 Oct 2010 15:18:34 +0400 Subject: [PATCH 06/12] 6603635: links to tutorials broken in JTable API doc Reviewed-by: alexp --- jdk/src/share/classes/javax/swing/JTable.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/javax/swing/JTable.java b/jdk/src/share/classes/javax/swing/JTable.java index 7842410e772..386b2a4628a 100644 --- a/jdk/src/share/classes/javax/swing/JTable.java +++ b/jdk/src/share/classes/javax/swing/JTable.java @@ -2491,7 +2491,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable * The default value of this property is defined by the look * and feel implementation. *

- * This is a JavaBeans bound property. + * This is a JavaBeans bound property. * * @param selectionForeground the Color to use in the foreground * for selected list items @@ -2529,7 +2529,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable * The default value of this property is defined by the look * and feel implementation. *

- * This is a JavaBeans bound property. + * This is a JavaBeans bound property. * * @param selectionBackground the Color to use for the background * of selected cells From 6445f22ebc9d97fc2c1fd958830164afbf95d8c4 Mon Sep 17 00:00:00 2001 From: Pavel Porvatov Date: Thu, 14 Oct 2010 13:33:00 +0400 Subject: [PATCH 07/12] 6984643: Unable to instantiate JFileChooser with a minimal BasicL&F descendant installed Reviewed-by: alexp --- .../swing/plaf/basic/BasicFileChooserUI.java | 16 +++++ .../swing/plaf/basic/BasicLookAndFeel.java | 1 + .../javax/swing/plaf/basic/Test6984643.java | 64 +++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 jdk/test/javax/swing/plaf/basic/Test6984643.java diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java index 6e2e8157f00..7ee7de687af 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicFileChooserUI.java @@ -141,6 +141,22 @@ public class BasicFileChooserUI extends FileChooserUI { private JPanel accessoryPanel = null; private Handler handler; + /** + * Creates a {@code BasicFileChooserUI} implementation + * for the specified component. By default + * the {@code BasicLookAndFeel} class uses + * {@code createUI} methods of all basic UIs classes + * to instantiate UIs. + * + * @param c the {@code JFileChooser} which needs a UI + * @return the {@code BasicFileChooserUI} object + * + * @see UIDefaults#getUI(JComponent) + * @since 1.7 + */ + public static ComponentUI createUI(JComponent c) { + return new BasicFileChooserUI((JFileChooser) c); + } public BasicFileChooserUI(JFileChooser b) { } diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java index b451759eaaf..a41915a7278 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicLookAndFeel.java @@ -269,6 +269,7 @@ public abstract class BasicLookAndFeel extends LookAndFeel implements Serializab "InternalFrameUI", basicPackageName + "BasicInternalFrameUI", "DesktopPaneUI", basicPackageName + "BasicDesktopPaneUI", "DesktopIconUI", basicPackageName + "BasicDesktopIconUI", + "FileChooserUI", basicPackageName + "BasicFileChooserUI", "OptionPaneUI", basicPackageName + "BasicOptionPaneUI", "PanelUI", basicPackageName + "BasicPanelUI", "ViewportUI", basicPackageName + "BasicViewportUI", diff --git a/jdk/test/javax/swing/plaf/basic/Test6984643.java b/jdk/test/javax/swing/plaf/basic/Test6984643.java new file mode 100644 index 00000000000..57df156026a --- /dev/null +++ b/jdk/test/javax/swing/plaf/basic/Test6984643.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 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 + * 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 6984643 + * @summary Unable to instantiate JFileChooser with a minimal BasicL&F descendant installed + * @author Pavel Porvatov + */ + +import javax.swing.*; +import javax.swing.plaf.basic.BasicLookAndFeel; + +public class Test6984643 { + public static void main(String[] args) throws Exception { + UIManager.setLookAndFeel(new BasicLookAndFeel() { + public String getName() { + return "A name"; + } + + public String getID() { + return "An id"; + } + + public String getDescription() { + return "A description"; + } + + public boolean isNativeLookAndFeel() { + return false; + } + + public boolean isSupportedLookAndFeel() { + return true; + } + }); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + new JFileChooser(); + } + }); + } +} From b269b5a65cda7ee81bb0dd1275e5cc901ff0e03e Mon Sep 17 00:00:00 2001 From: Alexander Potochkin Date: Thu, 14 Oct 2010 18:46:05 +0400 Subject: [PATCH 08/12] 6986385: JLayer should implement accessible interface Reviewed-by: rupashka --- jdk/src/share/classes/javax/swing/JLayer.java | 19 +++++++- .../accessibility/6986385/bug6986385.java | 47 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 jdk/test/javax/accessibility/6986385/bug6986385.java diff --git a/jdk/src/share/classes/javax/swing/JLayer.java b/jdk/src/share/classes/javax/swing/JLayer.java index eab0bf4ab2f..c01c4450767 100644 --- a/jdk/src/share/classes/javax/swing/JLayer.java +++ b/jdk/src/share/classes/javax/swing/JLayer.java @@ -29,6 +29,7 @@ import sun.awt.AWTAccessor; import javax.swing.plaf.LayerUI; import javax.swing.border.Border; +import javax.accessibility.*; import java.awt.*; import java.awt.event.*; import java.beans.PropertyChangeEvent; @@ -149,7 +150,7 @@ import java.security.PrivilegedAction; */ public final class JLayer extends JComponent - implements Scrollable, PropertyChangeListener { + implements Scrollable, PropertyChangeListener, Accessible { private V view; // this field is necessary because JComponent.ui is transient // when layerUI is serializable @@ -665,6 +666,22 @@ public final class JLayer } } + /** + * Gets the AccessibleContext associated with this {@code JLayer}. + * + * @return the AccessibleContext associated with this {@code JLayer}. + */ + public AccessibleContext getAccessibleContext() { + if (accessibleContext == null) { + accessibleContext = new AccessibleJComponent() { + public AccessibleRole getAccessibleRole() { + return AccessibleRole.PANEL; + } + }; + } + return accessibleContext; + } + /** * static AWTEventListener to be shared with all AbstractLayerUIs */ diff --git a/jdk/test/javax/accessibility/6986385/bug6986385.java b/jdk/test/javax/accessibility/6986385/bug6986385.java new file mode 100644 index 00000000000..8ad6078f7b1 --- /dev/null +++ b/jdk/test/javax/accessibility/6986385/bug6986385.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 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 + * 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 6986385 + @summary JLayer should implement accessible interface + @author Alexander Potochkin + @run main bug6986385 +*/ + +import javax.swing.*; +import javax.accessibility.AccessibleContext; +import javax.accessibility.AccessibleRole; + +public class bug6986385 { + + public static void main(String... args) throws Exception { + JLayer l = new JLayer(); + AccessibleContext acc = l.getAccessibleContext(); + if (acc == null) { + throw new RuntimeException("JLayer's AccessibleContext is null"); + } + if (acc.getAccessibleRole() != AccessibleRole.PANEL) { + throw new RuntimeException("JLayer's AccessibleRole must be PANEL"); + } + } +} From 1fdf430197ba69b00bc7ffccb07a2f241cdd3197 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Thu, 14 Oct 2010 11:37:22 -0700 Subject: [PATCH 09/12] 6575419: Solaris : XSetICFoucs is not called with Java application at appropriate timing Reviewed-by: okutsu --- jdk/src/solaris/classes/sun/awt/X11InputMethod.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/src/solaris/classes/sun/awt/X11InputMethod.java b/jdk/src/solaris/classes/sun/awt/X11InputMethod.java index b87877c8386..d958283afa6 100644 --- a/jdk/src/solaris/classes/sun/awt/X11InputMethod.java +++ b/jdk/src/solaris/classes/sun/awt/X11InputMethod.java @@ -96,6 +96,7 @@ public abstract class X11InputMethod extends InputMethodAdapter { private Component awtFocussedComponent = null; private Component lastXICFocussedComponent = null; private boolean isLastXICActive = false; + private boolean isLastTemporary = false; private boolean isActive = false; private boolean isActiveClient = false; private static Map[] highlightStyles; @@ -349,7 +350,7 @@ public abstract class X11InputMethod extends InputMethodAdapter { current focussed component, change the XIC focus to the newly focussed component. */ - if (lastXICFocussedComponentPeer != awtFocussedComponentPeer || + if (isLastTemporary || lastXICFocussedComponentPeer != awtFocussedComponentPeer || isLastXICActive != haveActiveClient()) { if (lastXICFocussedComponentPeer != null) { setXICFocus(lastXICFocussedComponentPeer, false, isLastXICActive); @@ -401,6 +402,7 @@ public abstract class X11InputMethod extends InputMethodAdapter { */ lastXICFocussedComponent = awtFocussedComponent; isLastXICActive = isAc; + isLastTemporary = isTemporary; isActive = false; } From 9fc2bd47e3bc29e9a2685197d819fd8796bb1193 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Thu, 14 Oct 2010 12:33:20 -0700 Subject: [PATCH 10/12] 6991013: Serialized form for java.util.Locale contains typos Reviewed-by: peytoia --- jdk/src/share/classes/java/util/Locale.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/java/util/Locale.java b/jdk/src/share/classes/java/util/Locale.java index 1043c8792c4..4fad48f2d92 100644 --- a/jdk/src/share/classes/java/util/Locale.java +++ b/jdk/src/share/classes/java/util/Locale.java @@ -1941,7 +1941,7 @@ public final class Locale implements Cloneable, Serializable { * @serialField variant String * variant subtags separated by LOWLINE characters. (See getVariant()) * @serialField hashcode int - * deprectated, for forward compatibility only + * deprecated, for forward compatibility only * @serialField script String * script subtag in title case (See getScript()) * @serialField extensions String @@ -1979,7 +1979,7 @@ public final class Locale implements Cloneable, Serializable { } /** - * Deserialize this Locale. + * Deserializes this Locale. * @param in the ObjectInputStream to read * @throws IOException * @throws ClassNotFoundException From b3cbd07d1ab672752f73482419eff717f9ad947d Mon Sep 17 00:00:00 2001 From: Masayoshi Okutsu Date: Fri, 15 Oct 2010 16:46:18 +0900 Subject: [PATCH 11/12] 6638110: (tz) TimeZone.getDisplayName(...) spec is inconsistent with implementation for unavailable locales Reviewed-by: peytoia --- jdk/src/share/classes/java/util/TimeZone.java | 94 +++++++++++++------ 1 file changed, 64 insertions(+), 30 deletions(-) diff --git a/jdk/src/share/classes/java/util/TimeZone.java b/jdk/src/share/classes/java/util/TimeZone.java index b759f9126d5..682c3323754 100644 --- a/jdk/src/share/classes/java/util/TimeZone.java +++ b/jdk/src/share/classes/java/util/TimeZone.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -302,60 +302,94 @@ abstract public class TimeZone implements Serializable, Cloneable { } /** - * Returns a name of this time zone suitable for presentation to the user - * in the default locale. - * This method returns the long name, not including daylight savings. - * If the display name is not available for the locale, - * then this method returns a string in the - * normalized custom ID format. + * Returns a long standard time name of this {@code TimeZone} suitable for + * presentation to the user in the default locale. + * + *

This method is equivalent to: + *

+ * getDisplayName(false, {@link #LONG}, + * Locale.getDefault({@link Locale.Category#DISPLAY})) + *
+ * * @return the human-readable name of this time zone in the default locale. * @since 1.2 + * @see #getDisplayName(boolean, int, Locale) + * @see Locale#getDefault(Locale.Category) + * @see Locale.Category */ public final String getDisplayName() { - return getDisplayName(false, LONG, Locale.getDefault(Locale.Category.DISPLAY)); + return getDisplayName(false, LONG, + Locale.getDefault(Locale.Category.DISPLAY)); } /** - * Returns a name of this time zone suitable for presentation to the user - * in the specified locale. - * This method returns the long name, not including daylight savings. - * If the display name is not available for the locale, - * then this method returns a string in the - * normalized custom ID format. + * Returns a long standard time name of this {@code TimeZone} suitable for + * presentation to the user in the specified {@code locale}. + * + *

This method is equivalent to: + *

+ * getDisplayName(false, {@link #LONG}, locale) + *
+ * * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. + * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 + * @see #getDisplayName(boolean, int, Locale) */ public final String getDisplayName(Locale locale) { return getDisplayName(false, LONG, locale); } /** - * Returns a name of this time zone suitable for presentation to the user - * in the default locale. - * If the display name is not available for the locale, then this - * method returns a string in the - * normalized custom ID format. - * @param daylight if true, return the daylight savings name. - * @param style either LONG or SHORT + * Returns a name in the specified {@code style} of this {@code TimeZone} + * suitable for presentation to the user in the default locale. If the + * specified {@code daylight} is {@code true}, a daylight saving time name + * is returned. Otherwise, a standard time name is returned. + * + *

This method is equivalent to: + *

+ * getDisplayName(daylight, style, + * Locale.getDefault({@link Locale.Category#DISPLAY})) + *
+ * + * @param daylight if {@code true}, return the daylight saving time name. + * @param style either {@link #LONG} or {@link #SHORT} * @return the human-readable name of this time zone in the default locale. + * @exception IllegalArgumentException if {@code style} is invalid. * @since 1.2 + * @see #getDisplayName(boolean, int, Locale) + * @see Locale#getDefault(Locale.Category) + * @see Locale.Category */ public final String getDisplayName(boolean daylight, int style) { - return getDisplayName(daylight, style, Locale.getDefault(Locale.Category.DISPLAY)); + return getDisplayName(daylight, style, + Locale.getDefault(Locale.Category.DISPLAY)); } /** - * Returns a name of this time zone suitable for presentation to the user - * in the specified locale. - * If the display name is not available for the locale, - * then this method returns a string in the - * normalized custom ID format. - * @param daylight if true, return the daylight savings name. - * @param style either LONG or SHORT + * Returns a name in the specified {@code style} of this {@code TimeZone} + * suitable for presentation to the user in the specified {@code + * locale}. If the specified {@code daylight} is {@code true}, a daylight + * saving time name is returned. Otherwise, a standard time name is + * returned. + * + *

When looking up a time zone name, the {@linkplain + * ResourceBundle.Control#getCandidateLocales(String,Locale) default + * Locale search path of ResourceBundle} derived + * from the specified {@code locale} is used. (No {@linkplain + * ResourceBundle.Control#getFallbackLocale(String,Locale) fallback + * Locale} search is performed.) If a time zone name in any + * {@code Locale} of the search path, including {@link Locale#ROOT}, is + * found, the name is returned. Otherwise, a string in the + * normalized custom ID format is returned. + * + * @param daylight if {@code true}, return the daylight saving time name. + * @param style either {@link #LONG} or {@link #SHORT} * @param locale the locale in which to supply the display name. * @return the human-readable name of this time zone in the given locale. - * @exception IllegalArgumentException style is invalid. + * @exception IllegalArgumentException if {@code style} is invalid. + * @exception NullPointerException if {@code locale} is {@code null}. * @since 1.2 */ public String getDisplayName(boolean daylight, int style, Locale locale) { From 8df28ab0e3a21732bb3622c78cc74a15ce656f51 Mon Sep 17 00:00:00 2001 From: Yoshito Umaoka Date: Mon, 18 Oct 2010 14:45:00 -0700 Subject: [PATCH 12/12] 6992272: I18N: Locale.getDisplayName() and toString() return empty if just script is set Reviewed-by: srl --- jdk/src/share/classes/java/util/Locale.java | 46 +++++++++++------ .../java/util/Locale/LocaleEnhanceTest.java | 49 +++++++++++++++++++ 2 files changed, 80 insertions(+), 15 deletions(-) diff --git a/jdk/src/share/classes/java/util/Locale.java b/jdk/src/share/classes/java/util/Locale.java index 4fad48f2d92..483da25f431 100644 --- a/jdk/src/share/classes/java/util/Locale.java +++ b/jdk/src/share/classes/java/util/Locale.java @@ -1715,6 +1715,7 @@ public final class Locale implements Cloneable, Serializable { OpenListResourceBundle bundle = LocaleData.getLocaleNames(inLocale); String languageName = getDisplayLanguage(inLocale); + String scriptName = getDisplayScript(inLocale); String countryName = getDisplayCountry(inLocale); String[] variantNames = getDisplayVariantArray(bundle, inLocale); @@ -1735,25 +1736,40 @@ public final class Locale implements Cloneable, Serializable { String mainName = null; String[] qualifierNames = null; - // The main name is the language, or if there is no language, the country. - // If there is neither language nor country (an anomalous situation) then - // the display name is simply the variant's display name. - if (languageName.length() != 0) { - mainName = languageName; - if (countryName.length() != 0) { - qualifierNames = new String[variantNames.length + 1]; - System.arraycopy(variantNames, 0, qualifierNames, 1, variantNames.length); - qualifierNames[0] = countryName; + // The main name is the language, or if there is no language, the script, + // then if no script, the country. If there is no language/script/country + // (an anomalous situation) then the display name is simply the variant's + // display name. + if (languageName.length() == 0 && scriptName.length() == 0 && countryName.length() == 0) { + if (variantNames.length == 0) { + return ""; + } else { + return formatList(variantNames, listPattern, listCompositionPattern); } - else qualifierNames = variantNames; } - else if (countryName.length() != 0) { - mainName = countryName; - qualifierNames = variantNames; + ArrayList names = new ArrayList(4); + if (languageName.length() != 0) { + names.add(languageName); } - else { - return formatList(variantNames, listPattern, listCompositionPattern); + if (scriptName.length() != 0) { + names.add(scriptName); } + if (countryName.length() != 0) { + names.add(countryName); + } + if (variantNames.length != 0) { + for (String var : variantNames) { + names.add(var); + } + } + + // The first one in the main name + mainName = names.get(0); + + // Others are qualifiers + int numNames = names.size(); + qualifierNames = (numNames > 1) ? + names.subList(1, numNames).toArray(new String[numNames - 1]) : new String[0]; // Create an array whose first element is the number of remaining // elements. This serves as a selector into a ChoiceFormat pattern from diff --git a/jdk/test/java/util/Locale/LocaleEnhanceTest.java b/jdk/test/java/util/Locale/LocaleEnhanceTest.java index a4416a4789e..44e6eaadff8 100644 --- a/jdk/test/java/util/Locale/LocaleEnhanceTest.java +++ b/jdk/test/java/util/Locale/LocaleEnhanceTest.java @@ -614,6 +614,55 @@ public class LocaleEnhanceTest extends LocaleTestFmwk { assertEquals("hans DE", "Simplified Han", hansLocale.getDisplayScript(Locale.GERMANY)); } + public void testGetDisplayName() { + final Locale[] testLocales = { + Locale.ROOT, + new Locale("en"), + new Locale("en", "US"), + new Locale("", "US"), + new Locale("no", "NO", "NY"), + new Locale("", "", "NY"), + Locale.forLanguageTag("zh-Hans"), + Locale.forLanguageTag("zh-Hant"), + Locale.forLanguageTag("zh-Hans-CN"), + Locale.forLanguageTag("und-Hans"), + }; + + final String[] displayNameEnglish = { + "", + "English", + "English (United States)", + "United States", + "Norwegian (Norway,Nynorsk)", + "Nynorsk", + "Chinese (Simplified Han)", + "Chinese (Traditional Han)", + "Chinese (Simplified Han,China)", + "Simplified Han", + }; + + final String[] displayNameSimplifiedChinese = { + "", + "\u82f1\u6587", + "\u82f1\u6587 (\u7f8e\u56fd)", + "\u7f8e\u56fd", + "\u632a\u5a01\u6587 (\u632a\u5a01,Nynorsk)", + "Nynorsk", + "\u4e2d\u6587 (\u7b80\u4f53\u4e2d\u6587)", + "\u4e2d\u6587 (\u7e41\u4f53\u4e2d\u6587)", + "\u4e2d\u6587 (\u7b80\u4f53\u4e2d\u6587,\u4e2d\u56fd)", + "\u7b80\u4f53\u4e2d\u6587", + }; + + for (int i = 0; i < testLocales.length; i++) { + Locale loc = testLocales[i]; + assertEquals("English display name for " + loc.toLanguageTag(), + displayNameEnglish[i], loc.getDisplayName(Locale.ENGLISH)); + assertEquals("Simplified Chinese display name for " + loc.toLanguageTag(), + displayNameSimplifiedChinese[i], loc.getDisplayName(Locale.CHINA)); + } + } + /// /// Builder tests ///