This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[classpath-095-merge-branch] Merge classpath bits into files copied into libjava
- From: Matthias Klose <doko at ubuntu dot com>
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Date: Thu, 17 May 2007 23:30:58 +0200
- Subject: [classpath-095-merge-branch] Merge classpath bits into files copied into libjava
Attached are the low hanging fruit merges for the bits mentioned in
http://gcc.gnu.org/ml/java/2007-05/msg00044.html
The diffs are attached as cp-merge.diff, the outstanding files are attached as
unmerged.diff.
Checked into the classpath-095-merge-branch.
Matthias
2007-05-17 Matthias Klose <doko@ubuntu.com>
Merged from classpath:
* gnu/java/nio/SelectorProviderImpl.java: Whitespace merge.
* java/lang/System.java(inheritedChannel): New.
* java/lang/Character.java: Remove stray`;'.
* java/net/MulticastSocket.java: Merged.
* java/text/DateFormatSymbols.java(getInstance): New, comment updates.
* java/text/Collator.java(getInstance): Merged.
* java/util/Calendar.java: New attributes ALL_STYLES, SHORT, LONG.
getDisplayName, getDisplayNames: New.
* java/util/logging/Logger.java: Merged.
* Regenerate .class and .h files.
2007-05-17 Matthias Klose <doko@ubuntu.com>
Merged from classpath:
* gnu/java/nio/SelectorProviderImpl.java: Whitespace merge.
* java/lang/System.java(inheritedChannel): New.
* java/lang/Character.java: Remove stray`;'.
* java/net/MulticastSocket.java: Merged.
* java/text/DateFormatSymbols.java(getInstance): New, comment updates.
* java/text/Collator.java(getInstance): Merged.
* java/util/Calendar.java: New attributes ALL_STYLES, SHORT, LONG.
getDisplayName, getDisplayNames: New.
* java/util/logging/Logger.java: Merged.
* Regenerate .class and .h files.
Index: gnu/java/nio/SelectorProviderImpl.java
===================================================================
--- gnu/java/nio/SelectorProviderImpl.java (revision 124801)
+++ gnu/java/nio/SelectorProviderImpl.java (working copy)
@@ -80,4 +80,5 @@
{
return new SocketChannelImpl (this);
}
+
}
Index: java/lang/System.java
===================================================================
--- java/lang/System.java (revision 124801)
+++ java/lang/System.java (working copy)
@@ -46,8 +46,11 @@
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.nio.channels.Channel;
+import java.nio.channels.spi.SelectorProvider;
import java.util.AbstractCollection;
import java.util.ArrayList;
import java.util.Collection;
@@ -649,6 +652,25 @@
*/
static native String getenv0(String name);
+ /**
+ * Returns the inherited channel of the VM.
+ *
+ * This wraps the inheritedChannel() call of the system's default
+ * {@link SelectorProvider}.
+ *
+ * @return the inherited channel of the VM
+ *
+ * @throws IOException If an I/O error occurs
+ * @throws SecurityException If an installed security manager denies access
+ * to RuntimePermission("inheritedChannel")
+ *
+ * @since 1.5
+ */
+ public static Channel inheritedChannel()
+ throws IOException
+ {
+ return SelectorProvider.provider().inheritedChannel();
+ }
/**
* This is a specialised <code>Collection</code>, providing
Index: java/lang/Character.java
===================================================================
--- java/lang/Character.java (revision 124801)
+++ java/lang/Character.java (working copy)
@@ -163,7 +163,7 @@
private final String canonicalName;
/** Enumeration for the <code>forName()</code> method */
- private enum NameType { CANONICAL, NO_SPACES, CONSTANT; };
+ private enum NameType { CANONICAL, NO_SPACES, CONSTANT; }
/**
* Constructor for strictly defined blocks.
Index: java/text/DateFormatSymbols.java
===================================================================
--- java/text/DateFormatSymbols.java (revision 124801)
+++ java/text/DateFormatSymbols.java (working copy)
@@ -1,5 +1,5 @@
/* DateFormatSymbols.java -- Format over a range of numbers
- Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,14 +38,25 @@
package java.text;
+import gnu.java.locale.LocaleHelper;
+
+import java.text.spi.DateFormatSymbolsProvider;
+
+import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import java.util.ServiceLoader;
+import java.util.TimeZone;
+
+import java.util.spi.TimeZoneNameProvider;
/**
* This class acts as container for locale specific date/time formatting
* information such as the days of the week and the months of the year.
* @author Per Bothner (bothner@cygnus.com)
+ *
* @date October 24, 1998.
*/
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
@@ -60,6 +71,15 @@
String[] shortMonths;
String[] shortWeekdays;
String[] weekdays;
+
+ /**
+ * The timezone strings supplied by the runtime.
+ */
+ private String[][] runtimeZoneStrings;
+
+ /**
+ * Custom timezone strings supplied by {@link #setZoneStrings()}.
+ */
private String[][] zoneStrings;
private static final long serialVersionUID = -5987973545549424702L;
@@ -91,11 +111,18 @@
/**
* This method initializes a new instance of <code>DateFormatSymbols</code>
* by loading the date format information for the specified locale.
+ * This constructor only obtains instances using the runtime's resources;
+ * to also include {@link java.text.spi.DateFormatSymbolsProvider} instances,
+ * call {@link #getInstance(java.util.Locale)} instead.
*
* @param locale The locale for which date formatting symbols should
* be loaded.
+ * @throws MissingResourceException if the resources for the specified
+ * locale could not be found or loaded.
+ * @see #getInstance(java.util.Locale)
*/
- public DateFormatSymbols (Locale locale) throws MissingResourceException
+ public DateFormatSymbols (Locale locale)
+ throws MissingResourceException
{
ResourceBundle res
= ResourceBundle.getBundle("gnu.java.locale.LocaleInformation", locale,
@@ -116,9 +143,16 @@
/**
* This method loads the format symbol information for the default
- * locale.
+ * locale. This constructor only obtains instances using the runtime's resources;
+ * to also include {@link java.text.spi.DateFormatSymbolsProvider} instances,
+ * call {@link #getInstance()} instead.
+ *
+ * @throws MissingResourceException if the resources for the default
+ * locale could not be found or loaded.
+ * @see #getInstance()
*/
- public DateFormatSymbols () throws MissingResourceException
+ public DateFormatSymbols()
+ throws MissingResourceException
{
this (Locale.getDefault());
}
@@ -499,4 +533,65 @@
^ hashCode(weekdays)
^ hashCode(zoneStrings));
}
+
+ /**
+ * Returns a {@link DateFormatSymbols} instance for the
+ * default locale obtained from either the runtime itself
+ * or one of the installed
+ * {@link java.text.spi.DateFormatSymbolsProvider} instances.
+ * This is equivalent to calling
+ * <code>getInstance(Locale.getDefault())</code>.
+ *
+ * @return a {@link DateFormatSymbols} instance for the default
+ * locale.
+ * @since 1.6
+ */
+ public static final DateFormatSymbols getInstance()
+ {
+ return getInstance(Locale.getDefault());
+ }
+
+ /**
+ * Returns a {@link DateFormatSymbols} instance for the
+ * specified locale obtained from either the runtime itself
+ * or one of the installed
+ * {@link java.text.spi.DateFormatSymbolsProvider} instances.
+ *
+ * @param locale the locale for which an instance should be
+ * returned.
+ * @return a {@link DateFormatSymbols} instance for the specified
+ * locale.
+ * @throws NullPointerException if <code>locale</code> is
+ * <code>null</code>.
+ * @since 1.6
+ */
+ public static final DateFormatSymbols getInstance(Locale locale)
+ {
+ try
+ {
+ DateFormatSymbols syms = new DateFormatSymbols(locale);
+ return syms;
+ }
+ catch (MissingResourceException e)
+ {
+ /* This means runtime support for the locale
+ * is not available, so we check providers. */
+ }
+ for (DateFormatSymbolsProvider p :
+ ServiceLoader.load(DateFormatSymbolsProvider.class))
+ {
+ for (Locale loc : p.getAvailableLocales())
+ {
+ if (loc.equals(locale))
+ {
+ DateFormatSymbols syms = p.getInstance(locale);
+ if (syms != null)
+ return syms;
+ break;
+ }
+ }
+ }
+ return getInstance(LocaleHelper.getFallbackLocale(locale));
+ }
+
}
Index: java/text/Collator.java
===================================================================
--- java/text/Collator.java (revision 124801)
+++ java/text/Collator.java (working copy)
@@ -38,10 +38,13 @@
package java.text;
+import java.text.spi.CollatorProvider;
+
import java.util.Comparator;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import java.util.ServiceLoader;
/**
* This class is the abstract superclass of classes which perform
@@ -286,7 +289,8 @@
/**
* This method returns an instance of <code>Collator</code> for the
* specified locale. If no <code>Collator</code> exists for the desired
- * locale, a <code>Collator</code> for the default locale will be returned.
+ * locale, the fallback procedure described in
+ * {@link java.util.spi.LocaleServiceProvider} is invoked.
*
* @param loc The desired locale to load a <code>Collator</code> for.
*
@@ -294,27 +298,52 @@
*/
public static Collator getInstance (Locale loc)
{
- ResourceBundle res;
String pattern;
try
{
- res = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
- loc, ClassLoader.getSystemClassLoader());
- pattern = res.getString("collation_rules");
+ ResourceBundle res =
+ ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+ loc, ClassLoader.getSystemClassLoader());
+ return new RuleBasedCollator(res.getString("collation_rules"));
}
catch (MissingResourceException x)
{
- pattern = "<0<1<2<3<4<5<6<7<8<9<A,a<b,B<c,C<d,D<e,E<f,F<g,G<h,H<i,I<j,J<k,K" +
- "<l,L<m,M<n,N<o,O<p,P<q,Q<r,R<s,S<t,T<u,U<v,V<w,W<x,X<y,Y<z,Z";
+ /* This means runtime support for the locale
+ * is not available, so we check providers. */
}
- try
- {
- return new RuleBasedCollator (pattern);
- }
catch (ParseException x)
{
throw (InternalError)new InternalError().initCause(x);
}
+ for (CollatorProvider p : ServiceLoader.load(CollatorProvider.class))
+ {
+ for (Locale l : p.getAvailableLocales())
+ {
+ if (l.equals(loc))
+ {
+ Collator c = p.getInstance(loc);
+ if (c != null)
+ return c;
+ break;
+ }
+ }
+ }
+ if (loc.equals(Locale.ROOT))
+ {
+ try
+ {
+ return new RuleBasedCollator("<0<1<2<3<4<5<6<7<8<9<A,a<b,B<c," +
+ "C<d,D<e,E<f,F<g,G<h,H<i,I<j,J<k,K" +
+ "<l,L<m,M<n,N<o,O<p,P<q,Q<r,R<s,S<t,"+
+ "T<u,U<v,V<w,W<x,X<y,Y<z,Z");
+ }
+ catch (ParseException x)
+ {
+ throw (InternalError)new InternalError().initCause(x);
+ }
+ }
+ // FIXME
+ return getInstance(Locale.US);
}
/**
Index: java/net/MulticastSocket.java
===================================================================
--- java/net/MulticastSocket.java (revision 124801)
+++ java/net/MulticastSocket.java (working copy)
@@ -1,5 +1,5 @@
/* MulticastSocket.java -- Class for using multicast sockets
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2007
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -338,7 +338,7 @@
/**
* Sets the "Time to Live" value for a socket. The value must be between
- * 1 and 255.
+ * 0 and 255, inclusive.
*
* @param ttl The new TTL value
*
@@ -351,7 +351,7 @@
if (isClosed())
throw new SocketException("socket is closed");
- if (ttl <= 0 || ttl > 255)
+ if (ttl < 0 || ttl > 255)
throw new IllegalArgumentException("Invalid ttl: " + ttl);
getImpl().setTimeToLive(ttl);
Index: java/util/logging/Logger.java
===================================================================
--- java/util/logging/Logger.java (revision 124801)
+++ java/util/logging/Logger.java (working copy)
@@ -1,5 +1,5 @@
/* Logger.java -- a class for logging messages
- Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -276,8 +276,8 @@
LogManager lm = LogManager.getLogManager();
Logger result;
- /* Throw NullPointerException if name is null. */
- name.getClass();
+ if (name == null)
+ throw new NullPointerException();
/* Without synchronized(lm), it could happen that another thread
* would create a logger between our calls to getLogger and
@@ -1013,8 +1013,8 @@
public synchronized void addHandler(Handler handler)
throws SecurityException
{
- /* Throw a new NullPointerException if handler is null. */
- handler.getClass();
+ if (handler == null)
+ throw new NullPointerException();
/* An application is allowed to control an anonymous logger
* without having the permission to control the logging
@@ -1057,8 +1057,8 @@
if (!anonymous)
LogManager.getLogManager().checkAccess();
- /* Throw a new NullPointerException if handler is null. */
- handler.getClass();
+ if (handler == null)
+ throw new NullPointerException();
handlerList.remove(handler);
handlers = getHandlers();
@@ -1166,8 +1166,8 @@
*/
public synchronized void setParent(Logger parent)
{
- /* Throw a new NullPointerException if parent is null. */
- parent.getClass();
+ if (parent == null)
+ throw new NullPointerException();
if (this == root)
throw new IllegalArgumentException(
Index: java/util/Calendar.java
===================================================================
--- java/util/Calendar.java (revision 124801)
+++ java/util/Calendar.java (working copy)
@@ -43,9 +43,12 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.text.DateFormatSymbols;
+
/**
* This class is an abstract base class for Calendars, which can be
* used to convert between <code>Date</code> objects and a set of
@@ -99,6 +102,20 @@
* specific field by one, propagating overflows), or
* <code>add</code>ing/substracting a fixed amount to a field.
*
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Jochen Hoenicke (Jochen.Hoenicke@Informatik.Uni-Oldenburg.de)
+ * @author Warren Levy (warrenl@cygnus.com)
+ * @author Jeff Sturm (jsturm@one-point.com)
+ * @author Tom Tromey (tromey@redhat.com)
+ * @author Bryce McKinlay (mckinlay@redhat.com)
+ * @author Ingo Proetel (proetel@aicas.com)
+ * @author Jerry Quinn (jlquinn@optonline.net)
+ * @author Jeroen Frijters (jeroen@frijters.net)
+ * @author Noa Resare (noa@resare.com)
+ * @author Sven de Marothy (sven@physto.se)
+ * @author David Gilbert (david.gilbert@object-refinery.com)
+ * @author Olivier Jolly (olivier.jolly@pcedev.com)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @see Date
* @see GregorianCalendar
* @see TimeZone
@@ -326,6 +343,34 @@
public static final int PM = 1;
/**
+ * A style specifier for {@link #getDisplayNames(int,int,Locale)}
+ * stating that names should be returned in both long and short variants.
+ *
+ * @since 1.6
+ * @see #SHORT
+ * @see #LONG
+ */
+ public static final int ALL_STYLES = 0;
+
+ /**
+ * A style specifier for {@link #getDisplayName(int,int,Locale)}
+ * and {@link #getDisplayNames(int,int,Locale)} stating that names
+ * should be returned in their short variant if applicable.
+ *
+ * @since 1.6
+ */
+ public static final int SHORT = 1;
+
+ /**
+ * A style specifier for {@link #getDisplayName(int,int,Locale)}
+ * and {@link #getDisplayNames(int,int,Locale)} stating that names
+ * should be returned in their long variant if applicable.
+ *
+ * @since 1.6
+ */
+ public static final int LONG = 2;
+
+ /**
* The time fields. The array is indexed by the constants YEAR to
* DST_OFFSET.
* @serial
@@ -504,7 +549,7 @@
* Cache of locale->calendar-class mappings. This avoids having to do a ResourceBundle
* lookup for every getInstance call.
*/
- private static HashMap cache = new HashMap();
+ private static HashMap<Locale,Class> cache = new HashMap<Locale,Class>();
/** Preset argument types for calendar-class constructor lookup. */
private static Class[] ctorArgTypes = new Class[]
@@ -526,7 +571,7 @@
*/
public static synchronized Calendar getInstance(TimeZone zone, Locale locale)
{
- Class calendarClass = (Class) cache.get(locale);
+ Class calendarClass = cache.get(locale);
Throwable exception = null;
try
@@ -1326,4 +1371,205 @@
areFieldsSet = false;
}
}
+
+ /**
+ * Returns a localised textual representation of the current value
+ * of the given field using the specified style. If there is no
+ * applicable textual representation (e.g. the field has a numeric
+ * value), then <code>null</code> is returned. If one does exist,
+ * then the value is obtained from {@link #get(int)} and converted
+ * appropriately. For example, if the <code>MONTH</code> field is
+ * requested, then <code>get(MONTH)</code> is called. This is then
+ * converted to a textual representation based on its value and
+ * the style requested; if the <code>LONG</code> style is requested
+ * and the returned value is <code>11</code> from a
+ * {@link GregorianCalendar} implementation, then <code>"December"</code>
+ * is returned. By default, a textual representation is available
+ * for all fields which have an applicable value obtainable from
+ * {@link java.text.DateFormatSymbols}.
+ *
+ * @param field the calendar field whose textual representation should
+ * be obtained.
+ * @param style the style to use; either {@link #LONG} or {@link #SHORT}.
+ * @param locale the locale to use for translation.
+ * @return the textual representation of the given field in the specified
+ * style, or <code>null</code> if none is applicable.
+ * @throws IllegalArgumentException if <code>field</code> or <code>style</code>
+ * or invalid, or the calendar is non-lenient
+ * and has invalid values.
+ * @throws NullPointerException if <code>locale</code> is <code>null</code>.
+ * @since 1.6
+ */
+ public String getDisplayName(int field, int style, Locale locale)
+ {
+ if (field < 0 || field >= FIELD_COUNT)
+ throw new IllegalArgumentException("The field value, " + field +
+ ", is invalid.");
+ if (style != SHORT && style != LONG)
+ throw new IllegalArgumentException("The style must be either " +
+ "short or long.");
+ if (field == YEAR || field == WEEK_OF_YEAR ||
+ field == WEEK_OF_MONTH || field == DAY_OF_MONTH ||
+ field == DAY_OF_YEAR || field == DAY_OF_WEEK_IN_MONTH ||
+ field == HOUR || field == HOUR_OF_DAY || field == MINUTE ||
+ field == SECOND || field == MILLISECOND)
+ return null;
+
+ int value = get(field);
+ DateFormatSymbols syms = DateFormatSymbols.getInstance(locale);
+ if (field == ERA)
+ return syms.getEras()[value];
+ if (field == MONTH)
+ if (style == LONG)
+ return syms.getMonths()[value];
+ else
+ return syms.getShortMonths()[value];
+ if (field == DAY_OF_WEEK)
+ if (style == LONG)
+ return syms.getWeekdays()[value];
+ else
+ return syms.getShortWeekdays()[value];
+ if (field == AM_PM)
+ return syms.getAmPmStrings()[value];
+ if (field == ZONE_OFFSET)
+ if (style == LONG)
+ return syms.getZoneStrings()[value][1];
+ else
+ return syms.getZoneStrings()[value][2];
+ if (field == DST_OFFSET)
+ if (style == LONG)
+ return syms.getZoneStrings()[value][3];
+ else
+ return syms.getZoneStrings()[value][4];
+
+ throw new InternalError("Failed to resolve field " + field +
+ " with style " + style + " for locale " +
+ locale);
+ }
+
+ /**
+ * Returns a map linking all specified textual representations
+ * of the given field to their numerical values. The textual
+ * representations included are determined by the specified
+ * style and locale. For example, if the style <code>LONG</code>
+ * is specified and the German locale, then the map will
+ * contain "Montag" to {@link #MONDAY}, "Dienstag" to
+ * {@link #TUESDAY}, "Mittwoch" to {@link #WEDNESDAY} and
+ * so on. The default implementation uses the values returned
+ * by {@link DateFormatSymbols} so, for example, the style
+ * {@link #ALL_STYLES} and the field {@link #MONTH} will return
+ * a map filled with the values returned from
+ * {@link DateFormatSymbols#getMonths()} and
+ * {@link DateFormatSymbols#getShortMonths()}. If there are
+ * no textual representations for a given field (usually because
+ * it is purely numeric, such as the year in the
+ * {@link GregorianCalendar}), <code>null</code> is returned.
+ *
+ * @param field the calendar field whose textual representation should
+ * be obtained.
+ * @param style the style to use; either {@link #LONG}, {@link #SHORT}
+ * or {@link ALL_STYLES}.
+ * @param locale the locale to use for translation.
+ * @return a map of the textual representations of the given field in the
+ * specified style to their numeric values, or <code>null</code>
+ * if none is applicable.
+ * @throws IllegalArgumentException if <code>field</code> or <code>style</code>
+ * or invalid, or the calendar is non-lenient
+ * and has invalid values.
+ * @throws NullPointerException if <code>locale</code> is <code>null</code>.
+ * @since 1.6
+ */
+ public Map<String,Integer> getDisplayNames(int field, int style, Locale locale)
+ {
+ if (field < 0 || field >= FIELD_COUNT)
+ throw new IllegalArgumentException("The field value, " + field +
+ ", is invalid.");
+ if (style != SHORT && style != LONG && style != ALL_STYLES)
+ throw new IllegalArgumentException("The style must be either " +
+ "short, long or all styles.");
+ if (field == YEAR || field == WEEK_OF_YEAR ||
+ field == WEEK_OF_MONTH || field == DAY_OF_MONTH ||
+ field == DAY_OF_YEAR || field == DAY_OF_WEEK_IN_MONTH ||
+ field == HOUR || field == HOUR_OF_DAY || field == MINUTE ||
+ field == SECOND || field == MILLISECOND)
+ return null;
+
+ DateFormatSymbols syms = DateFormatSymbols.getInstance(locale);
+ Map<String,Integer> map = new HashMap<String,Integer>();
+ if (field == ERA)
+ {
+ String[] eras = syms.getEras();
+ for (int a = 0; a < eras.length; ++a)
+ map.put(eras[a], a);
+ return map;
+ }
+ if (field == MONTH)
+ {
+ if (style == LONG || style == ALL_STYLES)
+ {
+ String[] months = syms.getMonths();
+ for (int a = 0; a < months.length; ++a)
+ map.put(months[a], a);
+ }
+ if (style == SHORT || style == ALL_STYLES)
+ {
+ String[] months = syms.getShortMonths();
+ for (int a = 0; a < months.length; ++a)
+ map.put(months[a], a);
+ }
+ return map;
+ }
+ if (field == DAY_OF_WEEK)
+ {
+ if (style == LONG || style == ALL_STYLES)
+ {
+ String[] weekdays = syms.getWeekdays();
+ for (int a = SUNDAY; a < weekdays.length; ++a)
+ map.put(weekdays[a], a);
+ }
+ if (style == SHORT || style == ALL_STYLES)
+ {
+ String[] weekdays = syms.getShortWeekdays();
+ for (int a = SUNDAY; a < weekdays.length; ++a)
+ map.put(weekdays[a], a);
+ }
+ return map;
+ }
+ if (field == AM_PM)
+ {
+ String[] ampms = syms.getAmPmStrings();
+ for (int a = 0; a < ampms.length; ++a)
+ map.put(ampms[a], a);
+ return map;
+ }
+ if (field == ZONE_OFFSET)
+ {
+ String[][] zones = syms.getZoneStrings();
+ for (int a = 0; a < zones.length; ++a)
+ {
+ if (style == LONG || style == ALL_STYLES)
+ map.put(zones[a][1], a);
+ if (style == SHORT || style == ALL_STYLES)
+ map.put(zones[a][2], a);
+ }
+ return map;
+ }
+ if (field == DST_OFFSET)
+ {
+ String[][] zones = syms.getZoneStrings();
+ for (int a = 0; a < zones.length; ++a)
+ {
+ if (style == LONG || style == ALL_STYLES)
+ map.put(zones[a][3], a);
+ if (style == SHORT || style == ALL_STYLES)
+ map.put(zones[a][4], a);
+ }
+ return map;
+ }
+
+ throw new InternalError("Failed to resolve field " + field +
+ " with style " + style + " for locale " +
+ locale);
+ }
+
}
Index: java/lang/System.java
===================================================================
--- java/lang/System.java (Revision 124574)
+++ java/lang/System.java (Arbeitskopie)
@@ -362,6 +365,7 @@
* <dt>gnu.java.io.encoding_scheme_alias.iso-latin-_?</dt> <dd>8859_?</dd>
* <dt>gnu.java.io.encoding_scheme_alias.latin?</dt> <dd>8859_?</dd>
* <dt>gnu.java.io.encoding_scheme_alias.utf-8</dt> <dd>UTF8</dd>
+ * <dt>gnu.java.util.zoneinfo.dir</dt> <dd>Root of zoneinfo tree</dd>
* <dt>gnu.javax.print.server</dt> <dd>Hostname of external CUPS server.</dd>
* </dl>
*
Index: java/lang/Class.java
===================================================================
--- java/lang/Class.java (Revision 124574)
+++ java/lang/Class.java (Arbeitskopie)
@@ -1126,15 +1127,7 @@
if (!Modifier.isPublic(constructor.getModifiers())
|| !Modifier.isPublic(VMClass.getModifiers(this, true)))
{
- final Constructor finalConstructor = constructor;
- AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- finalConstructor.setAccessible(true);
- return null;
- }
- });
+ setAccessible(constructor);
}
synchronized(this)
{
Index: java/text/DateFormatSymbols.java
===================================================================
--- java/text/DateFormatSymbols.java (Revision 124574)
+++ java/text/DateFormatSymbols.java (Arbeitskopie)
@@ -83,22 +104,52 @@
return res.getString(name).split("\u00ae");
}
- private String[][] getZoneStrings(ResourceBundle res)
+ private String[][] getZoneStrings(ResourceBundle res, Locale locale)
{
+ List<String[]> allZones = new ArrayList<String[]>();
try
{
int index = 0;
String data = res.getString("zoneStrings");
String[] zones = data.split("\u00a9");
- String[][] array = new String[zones.length][];
for (int a = 0; a < zones.length; ++a)
- array[a] = zones[a].split("\u00ae");
- return array;
+ allZones.add(zones[a].split("\u00ae"));
}
catch (MissingResourceException e)
{
- return new String[0][];
+ /* This means runtime support for the locale
+ * is not available, so we just include providers. */
}
+ for (TimeZoneNameProvider p :
+ ServiceLoader.load(TimeZoneNameProvider.class))
+ {
+ for (Locale loc : p.getAvailableLocales())
+ {
+ if (loc.equals(locale))
+ {
+ for (String id : TimeZone.getAvailableIDs())
+ {
+ String[] z = new String[5];
+ z[0] = id;
+ z[1] = p.getDisplayName(id, false,
+ TimeZone.LONG,
+ locale);
+ z[2] = p.getDisplayName(id, false,
+ TimeZone.SHORT,
+ locale);
+ z[3] = p.getDisplayName(id, true,
+ TimeZone.LONG,
+ locale);
+ z[4] = p.getDisplayName(id, true,
+ TimeZone.SHORT,
+ locale);
+ allZones.add(z);
+ }
+ break;
+ }
+ }
+ }
+ return allZones.toArray(new String[allZones.size()][]);
}
private String[] formatsForKey(ResourceBundle res, String key)
@@ -131,7 +189,7 @@
shortMonths = getStringArray(res, "shortMonths");
shortWeekdays = getStringArray(res, "shortWeekdays");
weekdays = getStringArray(res, "weekdays");
- zoneStrings = getZoneStrings(res);
+ runtimeZoneStrings = getZoneStrings(res, locale);
dateFormats = formatsForKey(res, "DateFormat");
timeFormats = formatsForKey(res, "TimeFormat");
}
@@ -274,12 +339,21 @@
* <li>3 - The long name of the time zone (daylight savings time).</li>
* <li>4 - the short name of the time zone (daylight savings time).</li>
* </ul>
+ * <p>
+ * If {@link #setZoneStrings(String[][])} has been called, then the value
+ * passed to this will be returned. Otherwise the returned array contains
+ * zone names provided by the runtime environment and any
+ * {@link java.util.spi.TimeZoneProvider} instances.
+ * </p>
*
* @return The list of time zone display strings.
+ * @see #setZoneStrings(String[][])
*/
- public String[] [] getZoneStrings ()
+ public String[][] getZoneStrings()
{
- return zoneStrings;
+ if (zoneStrings != null)
+ return zoneStrings;
+ return runtimeZoneStrings;
}
/**
Index: java/net/NetworkInterface.java
===================================================================
--- java/net/NetworkInterface.java (Revision 124574)
+++ java/net/NetworkInterface.java (Arbeitskopie)
@@ -100,7 +96,8 @@
public Enumeration<InetAddress> getInetAddresses()
{
SecurityManager s = System.getSecurityManager();
- Vector inetAddresses = new Vector(netif.addresses);
+ Vector<InetAddress> inetAddresses
+ = new Vector<InetAddress>(netif.addresses);
if (s == null)
return inetAddresses.elements();
Index: java/util/Currency.java
===================================================================
--- java/util/Currency.java (Revision 124574)
+++ java/util/Currency.java (Arbeitskopie)
@@ -44,6 +44,8 @@
import java.io.ObjectStreamException;
import java.io.Serializable;
+import java.util.spi.CurrencyNameProvider;
+
/**
* Representation of a currency for a particular locale. Each currency
* is identified by its ISO 4217 code, and only one instance of this
@@ -402,8 +404,35 @@
*/
public String getSymbol(Locale locale)
{
- return LocaleHelper.getLocalizedString(locale, currencyCode,
- "currenciesSymbol", false, true);
+ String property = "currenciesSymbol." + currencyCode;
+ try
+ {
+ return ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+ locale).getString(property);
+ }
+ catch (MissingResourceException exception)
+ {
+ /* This means runtime support for the locale
+ * is not available, so we check providers. */
+ }
+ for (CurrencyNameProvider p :
+ ServiceLoader.load(CurrencyNameProvider.class))
+ {
+ for (Locale loc : p.getAvailableLocales())
+ {
+ if (loc.equals(locale))
+ {
+ String localizedString = p.getSymbol(currencyCode,
+ locale);
+ if (localizedString != null)
+ return localizedString;
+ break;
+ }
+ }
+ }
+ if (locale.equals(Locale.ROOT)) // Base case
+ return currencyCode;
+ return getSymbol(LocaleHelper.getFallbackLocale(locale));
}
/**