[ http://issues.apache.org/jira/browse/XALANJ-1993?page=all ]
Brian Minchau updated XALANJ-1993:
----------------------------------
Fix Version: 2.7
> proposed fix to ClassCastException in org.apache.xml.res.XMLMessages
> --------------------------------------------------------------------
>
> Key: XALANJ-1993
> URL: http://issues.apache.org/jira/browse/XALANJ-1993
> Project: XalanJ2
> Type: Bug
> Components: Diagnostic-messages-resources
> Environment: ibm jdk 1.3 and 1.4
> Reporter: Carlo Marchiori
> Fix For: 2.7
>
> IBM jdks do not implements correctly the contract of the method
> java.util.ResourceBundle.getBundle (). In fact they search for a property
> file implementation of the bundle before the list implementation.
> The result is that a ClassCastException happens in the class
> org.apache.xml.res.XMLMessages, specifically in the method
> -------------------------------------
> public static ListResourceBundle loadResourceBundle(String className)
> throws MissingResourceException
> {
> Locale locale = Locale.getDefault();
> try
> {
> return (ListResourceBundle)ResourceBundle.getBundle(className,
> locale);
> -------------------------------------
> I propose that xalan recognises this problem and so adopts a workaround in
> the source tree. My workaround first checks if the bundle loaded is a
> ListResourceBundle; if not it wraps it with an adapter.
> -----------------------------------------------------------------
> //return (ListResourceBundle)ResourceBundle.getBundle(className,
> locale);
> ResourceBundle bundle = ResourceBundle.getBundle(className, locale);
> if (bundle instanceof PropertyResourceBundle)
> {
> return new ListResourceBundleAdapter (bundle);
> }
> else
> {
> return (ListResourceBundle) bundle;
> }
> ----------------------------------------------------------------------
> My adapter implementation is
> --------------------------------------------------------------------------
> public class ListResourceBundleAdapter extends ListResourceBundle
> {
> Object [][] contents;
>
> public ListResourceBundleAdapter (ResourceBundle bundle)
> {
> Enumeration keys = bundle.getKeys();
> LinkedList list = new LinkedList ();
>
> while (keys.hasMoreElements())
> {
> String key = (String) keys.nextElement();
> Object value = bundle.getObject(key);
> Object [] pair = new Object [] {key, value};
> list.add(pair);
> }
>
> contents = (Object [][]) list.toArray(new Object [list.size()]
> []);
> }
> /* (non-Javadoc)
> * @see java.util.ListResourceBundle#getContents()
> */
> protected Object[][] getContents()
> {
> return contents;
> }
> }
> --------------------------------------------------------------------------
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]