mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-13 17:33:10 +00:00
Merge
This commit is contained in:
commit
725109cea1
@ -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";
|
||||
|
||||
|
||||
@ -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 <code>source</code> or <code>target</code> 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
|
||||
|
||||
@ -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<String> names = new ArrayList<String>(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
|
||||
@ -1941,7 +1957,7 @@ public final class Locale implements Cloneable, Serializable {
|
||||
* @serialField variant String
|
||||
* variant subtags separated by LOWLINE characters. (See <a href="java/util/Locale.html#getVariant()">getVariant()</a>)
|
||||
* @serialField hashcode int
|
||||
* deprectated, for forward compatibility only
|
||||
* deprecated, for forward compatibility only
|
||||
* @serialField script String
|
||||
* script subtag in title case (See <a href="java/util/Locale.html#getScript()">getScript()</a>)
|
||||
* @serialField extensions String
|
||||
@ -1979,7 +1995,7 @@ public final class Locale implements Cloneable, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize this <code>Locale</code>.
|
||||
* Deserializes this <code>Locale</code>.
|
||||
* @param in the <code>ObjectInputStream</code> to read
|
||||
* @throws IOException
|
||||
* @throws ClassNotFoundException
|
||||
|
||||
@ -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
|
||||
* <a href="#NormalizedCustomID">normalized custom ID format</a>.
|
||||
* Returns a long standard time name of this {@code TimeZone} suitable for
|
||||
* presentation to the user in the default locale.
|
||||
*
|
||||
* <p>This method is equivalent to:
|
||||
* <pre><blockquote>
|
||||
* getDisplayName(false, {@link #LONG},
|
||||
* Locale.getDefault({@link Locale.Category#DISPLAY}))
|
||||
* </blockquote></pre>
|
||||
*
|
||||
* @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
|
||||
* <a href="#NormalizedCustomID">normalized custom ID format</a>.
|
||||
* Returns a long standard time name of this {@code TimeZone} suitable for
|
||||
* presentation to the user in the specified {@code locale}.
|
||||
*
|
||||
* <p>This method is equivalent to:
|
||||
* <pre><blockquote>
|
||||
* getDisplayName(false, {@link #LONG}, locale)
|
||||
* </blockquote></pre>
|
||||
*
|
||||
* @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
|
||||
* <a href="#NormalizedCustomID">normalized custom ID format</a>.
|
||||
* @param daylight if true, return the daylight savings name.
|
||||
* @param style either <code>LONG</code> or <code>SHORT</code>
|
||||
* 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.
|
||||
*
|
||||
* <p>This method is equivalent to:
|
||||
* <pre><blockquote>
|
||||
* getDisplayName(daylight, style,
|
||||
* Locale.getDefault({@link Locale.Category#DISPLAY}))
|
||||
* </blockquote></pre>
|
||||
*
|
||||
* @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
|
||||
* <a href="#NormalizedCustomID">normalized custom ID format</a>.
|
||||
* @param daylight if true, return the daylight savings name.
|
||||
* @param style either <code>LONG</code> or <code>SHORT</code>
|
||||
* 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.
|
||||
*
|
||||
* <p>When looking up a time zone name, the {@linkplain
|
||||
* ResourceBundle.Control#getCandidateLocales(String,Locale) default
|
||||
* <code>Locale</code> search path of <code>ResourceBundle</code>} derived
|
||||
* from the specified {@code locale} is used. (No {@linkplain
|
||||
* ResourceBundle.Control#getFallbackLocale(String,Locale) fallback
|
||||
* <code>Locale</code>} 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
|
||||
* <a href="#NormalizedCustomID">normalized custom ID format</a> 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) {
|
||||
|
||||
@ -63,7 +63,7 @@ import com.sun.media.sound.JDK13Services;
|
||||
* <p>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
|
||||
|
||||
@ -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<V extends Component>
|
||||
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<V extends Component>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
@ -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.
|
||||
* <p>
|
||||
* This is a <a href="http://java.sun.com/docs/books/tutorial/javabeans/whatis/beanDefinition.html">JavaBeans</a> bound property.
|
||||
* This is a <a href="http://java.sun.com/docs/books/tutorial/javabeans/properties/bound.html">JavaBeans</a> bound property.
|
||||
*
|
||||
* @param selectionForeground the <code>Color</code> 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.
|
||||
* <p>
|
||||
* This is a <a href="http://java.sun.com/docs/books/tutorial/javabeans/whatis/beanDefinition.html">JavaBeans</a> bound property.
|
||||
* This is a <a href="http://java.sun.com/docs/books/tutorial/javabeans/properties/bound.html">JavaBeans</a> bound property.
|
||||
*
|
||||
* @param selectionBackground the <code>Color</code> to use for the background
|
||||
* of selected cells
|
||||
|
||||
@ -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) {
|
||||
}
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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<Locale> availableJRELocales = null;
|
||||
private static volatile List<Locale> 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<Locale> getJRELocales() {
|
||||
private List<Locale> getJRELocales() {
|
||||
if (availableJRELocales == null) {
|
||||
Locale[] allLocales = LocaleData.getAvailableLocales();
|
||||
availableJRELocales = new ArrayList<Locale>(allLocales.length);
|
||||
for (Locale locale : allLocales) {
|
||||
availableJRELocales.add(getLookupLocale(locale));
|
||||
synchronized (LocaleServiceProviderPool.class) {
|
||||
if (availableJRELocales == null) {
|
||||
Locale[] allLocales = LocaleData.getAvailableLocales();
|
||||
availableJRELocales = new ArrayList<Locale>(allLocales.length);
|
||||
for (Locale locale : allLocales) {
|
||||
availableJRELocales.add(getLookupLocale(locale));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return availableJRELocales;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
78
jdk/test/java/text/Collator/Bug6970930.java
Normal file
78
jdk/test/java/text/Collator/Bug6970930.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
62
jdk/test/java/util/Locale/Bug6989440.java
Normal file
62
jdk/test/java/util/Locale/Bug6989440.java
Normal file
@ -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<? extends LocaleServiceProvider> cls;
|
||||
|
||||
public TestThread(Class<? extends LocaleServiceProvider> providerClass) {
|
||||
cls = providerClass;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(cls);
|
||||
pool.getAvailableLocales();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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
|
||||
///
|
||||
|
||||
47
jdk/test/javax/accessibility/6986385/bug6986385.java
Normal file
47
jdk/test/javax/accessibility/6986385/bug6986385.java
Normal file
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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()];
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
64
jdk/test/javax/swing/plaf/basic/Test6984643.java
Normal file
64
jdk/test/javax/swing/plaf/basic/Test6984643.java
Normal file
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user