This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [classpath-095-merge-branch] Merge classpath bits into files copied into libjava


Tom Tromey schrieb:
>>>>>> "Matthias" == Matthias Klose <doko@ubuntu.com> writes:
> 
> Matthias> The diffs are attached as cp-merge.diff, the outstanding
> Matthias> files are attached as unmerged.diff.
> 
> I didn't see unmerged.diff... do you still have this?  I think there
> may be a few other simple-ish merges we could do.

attached

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));
   }
 
   /**

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]