Patch: Fix for PR libgcj/1906

Tom Tromey tromey@redhat.com
Wed Feb 7 14:46:00 GMT 2001


I'm checking this in.  This fixes PR libgcj/1906.  I believe it is
fairly low risk, so I think it is acceptable pre-branch.

2001-02-07  Tom Tromey  <tromey@redhat.com>

	Fix for PR libgcj/1906:
	* java/text/MessageFormat.java (setLocale): Use named class
	literals.
	(forName): Removed.
	(format(Object,StringBuffer,FieldPosition)): Special case if
	argument is an Object[].

Tom

Index: java/text/MessageFormat.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/text/MessageFormat.java,v
retrieving revision 1.4
diff -u -r1.4 MessageFormat.java
--- MessageFormat.java	2000/03/07 19:55:27	1.4
+++ MessageFormat.java	2001/02/07 22:44:08
@@ -1,6 +1,6 @@
 // MessageFormat.java - Localized message formatting.
 
-/* Copyright (C) 1999  Free Software Foundation
+/* Copyright (C) 1999, 2001  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -45,19 +45,6 @@
   // Text to follow this element.
   String trailer;
 
-  // FIXME: shouldn't need this.
-  Class forName (String name)
-    {
-      try
-	{
-	  return Class.forName (name);
-	}
-      catch (ClassNotFoundException x)
-	{
-	}
-      return null;
-    }
-
   // Recompute the locale-based formatter.
   void setLocale (Locale loc)
     {
@@ -65,9 +52,7 @@
 	;
       else if (type.equals("number"))
 	{
-	  // FIXME: named class literal.
-	  // formatClass = Number.class;
-	  formatClass = forName ("java.lang.Number");
+	  formatClass = java.lang.Number.class;
 
 	  if (style == null)
 	    format = NumberFormat.getInstance(loc);
@@ -98,9 +83,7 @@
 	}
       else if (type.equals("time") || type.equals("date"))
 	{
-	  // FIXME: named class literal.
-	  // formatClass = Date.class;
-	  formatClass = forName ("java.util.Date");
+	  formatClass = java.util.Date.class;
 
 	  int val = DateFormat.DEFAULT;
 	  if (style == null)
@@ -127,9 +110,7 @@
 	}
       else if (type.equals("choice"))
 	{
-	  // FIXME: named class literal.
-	  // formatClass = Number.class;
-	  formatClass = forName ("java.lang.Number");
+	  formatClass = java.lang.Number.class;
 
 	  if (style == null)
 	    throw new
@@ -370,8 +351,19 @@
   public final StringBuffer format (Object singleArg, StringBuffer appendBuf,
 				    FieldPosition ignore)
     {
-      Object[] args = new Object[1];
-      args[0] = singleArg;
+      Object[] args;
+
+      if (singleArg instanceof Object[])
+	{
+	  // This isn't specified in any manual, but it follows the
+	  // JDK implementation.
+	  args = (Object[]) singleArg;
+	}
+      else
+	{
+	  args = new Object[1];
+	  args[0] = singleArg;
+	}
       return format (args, appendBuf, ignore);
     }
 


More information about the Java-patches mailing list