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]

[BC + Trunk] Patch: FYI: ResourceBundle update


I'm checking this in on the BC branch and the trunk.

This is a refinement to my ResourceBundle patch from last week.  It
turns out Eclipse relies on us not instantiating a class that has the
same name as a resource bundle but does not extend ResourceBundle.  I
added a comment to this effect as well.

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>
	* java/util/ResourceBundle.java (tryBundle): Use
	Class.isAssignableFrom rather than catching ClassCastException.

Index: java/util/ResourceBundle.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/util/ResourceBundle.java,v
retrieving revision 1.23.24.3
diff -u -r1.23.24.3 ResourceBundle.java
--- java/util/ResourceBundle.java 21 Oct 2004 01:39:58 -0000 1.23.24.3
+++ java/util/ResourceBundle.java 25 Oct 2004 17:07:07 -0000
@@ -473,12 +473,18 @@
           rbClass = Class.forName(localizedName);
         else
           rbClass = classloader.loadClass(localizedName);
-        bundle = (ResourceBundle) rbClass.newInstance();
+	// Note that we do the check up front instead of catching
+	// ClassCastException.  The reason for this is that some crazy
+	// programs (Eclipse) have classes that do not extend
+	// ResourceBundle but that have the same name as a property
+	// bundle; in fact Eclipse relies on ResourceBundle not
+	// instantiating these classes.
+	if (ResourceBundle.class.isAssignableFrom(rbClass))
+	  bundle = (ResourceBundle) rbClass.newInstance();
       }
     catch (IllegalAccessException ex) {}
     catch (InstantiationException ex) {}
     catch (ClassNotFoundException ex) {}
-    catch (ClassCastException ex) {}
 
     if (bundle == null)
       {


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