[ 
http://issues.apache.org/jira/browse/XALANJ-1993?page=comments#action_57524 ]
     
Ilene Seelemann commented on XALANJ-1993:
-----------------------------------------

I haven't been able to reproduce this issue using IBM JDK 1.3.1.  It looks as 
if the ListResourceBundles are being looked up and found correctly.  The JDK 
first tries to load the class specified in the ResourceBundle.getResourceBundle 
method and then if that fails it looks for a .properties file with the same 
name.

I could see you getting the ClassCastException if for some reason you don't 
have the ListResourceBundle files, but you do have .properties files lying 
around.  Once upon a time I think we used .properties files instead of the 
classes.

Or maybe I'm missing something.  Can you describe your environment in more 
detail?

Thanks.

> 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

>
> 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
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to