Skip to content

Commit

Permalink
ResourceBundle.java (tryBundle): Use Class.isAssignableFrom rather th…
Browse files Browse the repository at this point in the history
…an catching ClassCastException.

	* java/util/ResourceBundle.java (tryBundle): Use
	Class.isAssignableFrom rather than catching ClassCastException.

From-SVN: r89542
  • Loading branch information
Tom Tromey authored and Tom Tromey committed Oct 25, 2004
1 parent 6fc058d commit 4cd2687
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions libjava/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2004-10-25 Tom Tromey <tromey@redhat.com>

* java/util/ResourceBundle.java (tryBundle): Use
Class.isAssignableFrom rather than catching ClassCastException.

2004-10-25 Tom Tromey <tromey@redhat.com>

* gnu/java/text/WordBreakIterator.java (WordBreakIterator): Don't
Expand Down
10 changes: 8 additions & 2 deletions libjava/java/util/ResourceBundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,18 @@ private static ResourceBundle tryBundle(String localizedName,
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)
{
Expand Down

0 comments on commit 4cd2687

Please sign in to comment.