This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: classpath-0.95 merge
Andrew Haley schrieb:
> Matthias Klose writes:
> >
> > - I didn't update classes found in libjava, which were updated in
> > classpath/libjava except the necessary bits to make the merge build again.
>
> We really need to know what classes these were. I've been quite
> careful to copy all from changes to libjava to classpath upstream.
$ svn status classpath | grep '\.java$' | sed 's,[^/]*classpath/,,' | while read
f; do [ -f $f ] && echo $f; done
gnu/java/nio/SelectorProviderImpl.java
java/lang/String.java
java/lang/System.java
java/lang/Class.java
java/lang/Character.java
java/text/DateFormatSymbols.java
java/text/Collator.java
java/text/DecimalFormatSymbols.java
java/net/MulticastSocket.java
java/net/NetworkInterface.java
java/io/File.java
java/util/Currency.java
java/util/Calendar.java
java/util/logging/LogManager.java
java/util/logging/Logger.java
attached a diff for these files; at least for Class.java, it appears that the
changes were not merged for the last import.
Index: gnu/java/nio/SelectorProviderImpl.java
===================================================================
--- gnu/java/nio/SelectorProviderImpl.java (Revision 124574)
+++ gnu/java/nio/SelectorProviderImpl.java (Arbeitskopie)
@@ -117,4 +117,5 @@
{
return new SocketChannelImpl (this);
}
+
}
Index: java/lang/String.java
===================================================================
--- java/lang/String.java (Revision 124574)
+++ java/lang/String.java (Arbeitskopie)
@@ -1592,8 +1592,10 @@
if (begin == limit)
return "";
while (value[begin++] <= '\u0020');
+
int end = limit;
- while (value[--end] <= '\u0020');
+ while (value[--end] <= '\u0020')
+ ;
return substring(begin - offset - 1, end - offset + 1);
}
@@ -1988,4 +1990,17 @@
return Character.offsetByCodePoints(value, offset, count, offset + index,
codePointOffset);
}
+
+ /**
+ * Returns true if, and only if, {@link #length()}
+ * is <code>0</code>.
+ *
+ * @return true if the length of the string is zero.
+ * @since 1.6
+ */
+ public boolean isEmpty()
+ {
+ return count == 0;
+ }
+
}
Index: java/lang/System.java
===================================================================
--- java/lang/System.java (Revision 124574)
+++ java/lang/System.java (Arbeitskopie)
@@ -1,5 +1,5 @@
/* System.java -- useful methods to interface with the system
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,8 +42,11 @@
import gnu.classpath.SystemProperties;
import gnu.classpath.VMStackWalker;
+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.Collection;
import java.util.Collections;
@@ -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>
*
@@ -671,6 +675,25 @@
return VMRuntime.mapLibraryName(libname);
}
+ /**
+ * 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/Class.java
===================================================================
--- java/lang/Class.java (Revision 124574)
+++ java/lang/Class.java (Arbeitskopie)
@@ -45,6 +45,7 @@
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.annotation.Inherited;
+import java.lang.reflect.AccessibleObject;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -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)
{
@@ -1397,7 +1390,9 @@
{
try
{
- return (T[]) getMethod("values").invoke(null);
+ Method m = getMethod("values");
+ setAccessible(m);
+ return (T[]) m.invoke(null);
}
catch (NoSuchMethodException exception)
{
@@ -1787,5 +1782,18 @@
return VMClass.isMemberClass(this);
}
-
+ /**
+ * Utility method for use by classes in this package.
+ */
+ static void setAccessible(final AccessibleObject obj)
+ {
+ AccessController.doPrivileged(new PrivilegedAction()
+ {
+ public Object run()
+ {
+ obj.setAccessible(true);
+ return null;
+ }
+ });
+ }
}
Index: java/lang/Character.java
===================================================================
--- java/lang/Character.java (Revision 124574)
+++ java/lang/Character.java (Arbeitskopie)
@@ -156,7 +156,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 124574)
+++ java/text/DateFormatSymbols.java (Arbeitskopie)
@@ -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,26 @@
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)
+ * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @date October 24, 1998.
*/
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3.
@@ -60,6 +72,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;
@@ -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)
@@ -114,11 +165,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,
@@ -131,16 +189,23 @@
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");
}
/**
* 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());
}
@@ -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;
}
/**
@@ -537,4 +611,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 124574)
+++ java/text/Collator.java (Arbeitskopie)
@@ -40,10 +40,13 @@
import gnu.java.locale.LocaleHelper;
+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
@@ -285,7 +288,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.
*
@@ -293,27 +297,51 @@
*/
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);
+ }
+ }
+ return getInstance(LocaleHelper.getFallbackLocale(loc));
}
/**
Index: java/text/DecimalFormatSymbols.java
===================================================================
--- java/text/DecimalFormatSymbols.java (Revision 124574)
+++ java/text/DecimalFormatSymbols.java (Arbeitskopie)
@@ -1,5 +1,5 @@
/* DecimalFormatSymbols.java -- Format symbols used by DecimalFormat
- Copyright (C) 1999, 2000, 2001, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2004, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,13 +38,19 @@
package java.text;
+import gnu.java.locale.LocaleHelper;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
+
+import java.text.spi.DecimalFormatSymbolsProvider;
+
import java.util.Currency;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import java.util.ServiceLoader;
/**
* This class is a container for the symbols used by
@@ -80,6 +86,11 @@
/**
* This method initializes a new instance of
* <code>DecimalFormatSymbols</code> for the default locale.
+ * This constructor only obtains instances using the runtime's resources;
+ * to also include {@link java.text.spi.DateFormatSymbolsProvider} instances,
+ * call {@link #getInstance()} instead.
+ *
+ * @see #getInstance()
*/
public DecimalFormatSymbols ()
{
@@ -137,18 +148,19 @@
* international currency symbol will be set to the strings "?"
* and "XXX" respectively. This generally happens with language
* locales (those with no specified country), such as
- * <code>Locale.ENGLISH</code>.
+ * <code>Locale.ENGLISH</code>. This constructor only obtains
+ * instances using the runtime's resources; to also include
+ * {@link java.text.spi.DecimalFormatSymbolsProvider} instances,
+ * call {@link #getInstance(java.util.Locale)} instead.
*
* @param loc The local to load symbols for.
* @throws NullPointerException if the locale is null.
+ * @see #getInstance(java.util.Locale)
*/
public DecimalFormatSymbols (Locale loc)
{
ResourceBundle res;
- currency = Currency.getInstance("XXX");
- currencySymbol = "?";
- intlCurrencySymbol = "XXX";
try
{
res = ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
@@ -158,6 +170,9 @@
{
res = null;
}
+ currency = Currency.getInstance("XXX");
+ currencySymbol = "?";
+ intlCurrencySymbol = "XXX";
try
{
Currency localeCurrency = Currency.getInstance(loc);
@@ -684,4 +699,68 @@
serialVersionOnStream = 2;
}
+
+ /**
+ * Returns a {@link DecimalFormatSymbols} instance for the
+ * default locale obtained from either the runtime itself
+ * or one of the installed
+ * {@link java.text.spi.DecimalFormatSymbolsProvider} instances.
+ * This is equivalent to calling
+ * <code>getInstance(Locale.getDefault())</code>.
+ *
+ * @return a {@link DecimalFormatSymbols} instance for the default
+ * locale.
+ * @since 1.6
+ */
+ public static final DecimalFormatSymbols getInstance()
+ {
+ return getInstance(Locale.getDefault());
+ }
+
+ /**
+ * Returns a {@link DecimalFormatSymbols} instance for the
+ * specified locale obtained from either the runtime itself
+ * or one of the installed
+ * {@link java.text.spi.DecimalFormatSymbolsProvider} instances.
+ *
+ * @param locale the locale for which an instance should be
+ * returned.
+ * @return a {@link DecimalFormatSymbols} instance for the specified
+ * locale.
+ * @throws NullPointerException if <code>locale</code> is
+ * <code>null</code>.
+ * @since 1.6
+ */
+ public static final DecimalFormatSymbols getInstance(Locale locale)
+ {
+ try
+ {
+ if (!locale.equals(Locale.ROOT))
+ ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
+ locale,
+ ClassLoader.getSystemClassLoader());
+ return new DecimalFormatSymbols(locale);
+ }
+ catch (MissingResourceException x)
+ {
+ /* This means runtime support for the locale
+ * is not available, so we check providers. */
+ }
+ for (DecimalFormatSymbolsProvider p :
+ ServiceLoader.load(DecimalFormatSymbolsProvider.class))
+ {
+ for (Locale loc : p.getAvailableLocales())
+ {
+ if (loc.equals(locale))
+ {
+ DecimalFormatSymbols syms = p.getInstance(locale);
+ if (syms != null)
+ return syms;
+ break;
+ }
+ }
+ }
+ return getInstance(LocaleHelper.getFallbackLocale(locale));
+ }
+
}
Index: java/net/MulticastSocket.java
===================================================================
--- java/net/MulticastSocket.java (Revision 124574)
+++ java/net/MulticastSocket.java (Arbeitskopie)
@@ -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.
@@ -337,7 +337,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
*
@@ -350,7 +350,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/net/NetworkInterface.java
===================================================================
--- java/net/NetworkInterface.java (Revision 124574)
+++ java/net/NetworkInterface.java (Arbeitskopie)
@@ -40,12 +40,8 @@
import gnu.classpath.SystemProperties;
-import java.util.Collection;
-import java.util.Collections;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
import java.util.Vector;
/**
@@ -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/io/File.java
===================================================================
--- java/io/File.java (Revision 124574)
+++ java/io/File.java (Arbeitskopie)
@@ -164,6 +164,29 @@
}
/**
+ * This method tests whether or not the current thread is allowed to
+ * to execute the file pointed to by this object. This will be true if and
+ * and only if 1) the file exists and 2) the <code>SecurityManager</code>
+ * (if any) allows access to the file via it's <code>checkExec</code>
+ * method 3) the file is executable.
+ *
+ * @return <code>true</code> if execution is allowed,
+ * <code>false</code> otherwise
+ *
+ * @exception SecurityException If the <code>SecurityManager</code>
+ * does not allow access to the file
+ */
+ public boolean canExecute()
+ {
+ if (!VMFile.exists(path))
+ return false;
+
+ checkExec();
+
+ return VMFile.canExecute(path);
+ }
+
+ /**
* This method creates a new file of zero length with the same name as
* the path of this <code>File</code> object if an only if that file
* does not already exist.
@@ -1123,6 +1146,153 @@
}
/**
+ * This method sets the owner's read permission for the File represented by
+ * this object.
+ *
+ * It is the same as calling <code>setReadable(readable, true)</code>.
+ *
+ * @param <code>readable</code> <code>true</code> to set read permission,
+ * <code>false</code> to unset the read permission.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setReadable(boolean, boolean)
+ * @since 1.6
+ */
+ public boolean setReadable(boolean readable)
+ {
+ return setReadable(readable, true);
+ }
+
+ /**
+ * This method sets the read permissions for the File represented by
+ * this object.
+ *
+ * If <code>ownerOnly</code> is set to <code>true</code> then only the
+ * read permission bit for the owner of the file is changed.
+ *
+ * If <code>ownerOnly</code> is set to <code>false</code>, the file
+ * permissions are changed so that the file can be read by everyone.
+ *
+ * On unix like systems this sets the <code>user</code>, <code>group</code>
+ * and <code>other</code> read bits and is equal to call
+ * <code>chmod a+r</code> on the file.
+ *
+ * @param <code>readable</code> <code>true</code> to set read permission,
+ * <code>false</code> to unset the read permission.
+ * @param <code>ownerOnly</code> <code>true</code> to set read permission
+ * for owner only, <code>false</code> for all.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setReadable(boolean)
+ * @since 1.6
+ */
+ public boolean setReadable(boolean readable, boolean ownerOnly)
+ {
+ checkWrite();
+ return VMFile.setReadable(path, readable, ownerOnly);
+ }
+
+ /**
+ * This method sets the owner's write permission for the File represented by
+ * this object.
+ *
+ * It is the same as calling <code>setWritable(readable, true)</code>.
+ *
+ * @param <code>writable</code> <code>true</code> to set write permission,
+ * <code>false</code> to unset write permission.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setWritable(boolean, boolean)
+ * @since 1.6
+ */
+ public boolean setWritable(boolean writable)
+ {
+ return setWritable(writable, true);
+ }
+
+ /**
+ * This method sets the write permissions for the File represented by
+ * this object.
+ *
+ * If <code>ownerOnly</code> is set to <code>true</code> then only the
+ * write permission bit for the owner of the file is changed.
+ *
+ * If <code>ownerOnly</code> is set to <code>false</code>, the file
+ * permissions are changed so that the file can be written by everyone.
+ *
+ * On unix like systems this set the <code>user</code>, <code>group</code>
+ * and <code>other</code> write bits and is equal to call
+ * <code>chmod a+w</code> on the file.
+ *
+ * @param <code>writable</code> <code>true</code> to set write permission,
+ * <code>false</code> to unset write permission.
+ * @param <code>ownerOnly</code> <code>true</code> to set write permission
+ * for owner only, <code>false</code> for all.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setWritable(boolean)
+ * @since 1.6
+ */
+ public boolean setWritable(boolean writable, boolean ownerOnly)
+ {
+ checkWrite();
+ return VMFile.setWritable(path, writable, ownerOnly);
+ }
+
+ /**
+ * This method sets the owner's execute permission for the File represented
+ * by this object.
+ *
+ * It is the same as calling <code>setExecutable(readable, true)</code>.
+ *
+ * @param <code>executable</code> <code>true</code> to set execute permission,
+ * <code>false</code> to unset execute permission.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setExecutable(boolean, boolean)
+ * @since 1.6
+ */
+ public boolean setExecutable(boolean executable)
+ {
+ return setExecutable(executable, true);
+ }
+
+ /**
+ * This method sets the execute permissions for the File represented by
+ * this object.
+ *
+ * If <code>ownerOnly</code> is set to <code>true</code> then only the
+ * execute permission bit for the owner of the file is changed.
+ *
+ * If <code>ownerOnly</code> is set to <code>false</code>, the file
+ * permissions are changed so that the file can be executed by everyone.
+ *
+ * On unix like systems this set the <code>user</code>, <code>group</code>
+ * and <code>other</code> write bits and is equal to call
+ * <code>chmod a+x</code> on the file.
+ *
+ * @param <code>executable</code> <code>true</code> to set write permission,
+ * <code>false</code> to unset write permission.
+ * @param <code>ownerOnly</code> <code>true</code> to set write permission
+ * for owner only, <code>false</code> for all.
+ * @return <code>true</code> if the file permissions are changed,
+ * <code>false</code> otherwise.
+ * @exception SecurityException If write access of the file is not permitted.
+ * @see #setExecutable(boolean)
+ * @since 1.6
+ */
+ public boolean setExecutable(boolean executable, boolean ownerOnly)
+ {
+ checkWrite();
+ return VMFile.setExecutable(path, executable, ownerOnly);
+ }
+
+ /**
* This method sets the file represented by this object to be read only.
* A read only file or directory cannot be modified. Please note that
* GNU systems allow read only files to be deleted if the directory it
@@ -1315,6 +1485,15 @@
s.checkRead(path);
}
+ private void checkExec()
+ {
+ // Check the SecurityManager
+ SecurityManager s = System.getSecurityManager();
+
+ if (s != null)
+ s.checkExec(path);
+ }
+
/**
* Calling this method requests that the file represented by this object
* be deleted when the virtual machine exits. Note that this request cannot
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: java/util/Calendar.java
===================================================================
--- java/util/Calendar.java (Revision 124574)
+++ java/util/Calendar.java (Arbeitskopie)
@@ -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
@@ -527,7 +572,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[]
@@ -549,7 +594,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
@@ -1343,4 +1388,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/util/logging/LogManager.java
===================================================================
--- java/util/logging/LogManager.java (Revision 124574)
+++ java/util/logging/LogManager.java (Arbeitskopie)
@@ -1,6 +1,6 @@
/* LogManager.java -- a class for maintaining Loggers and managing
configuration properties
- Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -446,8 +446,8 @@
Iterator<WeakReference<Logger>> iter = loggers.values().iterator();
while (iter.hasNext())
- for (WeakReference<Logger> ref : loggers.values())
{
+ WeakReference<Logger> ref;
Logger logger;
ref = iter.next();
@@ -559,13 +559,21 @@
if ("handlers".equals(key))
{
- StringTokenizer tokenizer = new StringTokenizer(value);
+ // In Java 5 and earlier this was specified to be
+ // whitespace-separated, but in reality it also accepted
+ // commas (tomcat relied on this), and in Java 6 the
+ // documentation was updated to fit the implementation.
+ StringTokenizer tokenizer = new StringTokenizer(value,
+ " \t\n\r\f,");
while (tokenizer.hasMoreTokens())
{
String handlerName = tokenizer.nextToken();
Handler handler = (Handler)
createInstance(handlerName, Handler.class, key);
- Logger.root.addHandler(handler);
+ // Tomcat also relies on the implementation ignoring
+ // items in 'handlers' which are not class names.
+ if (handler != null)
+ Logger.root.addHandler(handler);
}
}
Index: java/util/logging/Logger.java
===================================================================
--- java/util/logging/Logger.java (Revision 124574)
+++ java/util/logging/Logger.java (Arbeitskopie)
@@ -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(