harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paulex Yang <paulex.y...@gmail.com>
Subject Re: [classlib][nio-charset] RI is inconsistent with spec when loading charset provider
Date Thu, 03 Aug 2006 10:03:30 GMT
Andrew Zhang wrote:
> Hi, all
> Things are a little bit complex when I tried to implement this 
> workaround.
> Consider availableCharsets() method from Charset.java, which loads 
> provider
> classes from configuration file.
> Please see my comments inline.
> final ClassLoader cl = getContextClassLoader();
>  if (null != cl) { // what shall we do if context class loader is null?
>   try {
>    //  context classloader is used to get resources.
>    Enumeration e = cl
>    // Examine each configuration file
>    while (e.hasMoreElements()) {
> // here, context classloader is used to load class.
> // If system classloader is used as backup when context classloader 
> fails to
> load, it seems illogical, because it's context classloader who get
> resources.
> // It should be the same classloader who gets resources and loads
> corresponding classes.
>     loadConfiguredCharsets((URL) e.nextElement(), cl, charsets);
>    }
>   } catch (IOException ex) {
>    // Unexpected ClassLoader exception, ignore
>   }
>  }
> If we put another copy code after this section, using "system 
> classloader"
> instead of "context classloader", it also seems illogical. What shall 
> we do
> if context classloader fails to load a provider charset class? Should it
> throw an error as spec requires or pass silently?
Hmm... I think more serious problem here is that the classloader is used 
not only to load the CharsetProvider class, but also to load the 
configuration files, so if we choose to try context classloader then 
system classloader, they may load different config files! IMHO, the 
behavior will be contradict with both RI and spec. I suggest we give up 
the *third way* and choose one(RI or spec) to follow, from others' 
comments, Sun has been aware of this for long time, so they must have 
reason not to fix the codes, maybe just because this is a not trivial 
difference(it may be significant for server application which has multi 
classloaders and special charsets), so I suggest we follow RI.

> To sum up, it's hard to follow RI, and comply with spec 
> simultaneously.  We
> have to choose one of them. Spec or RI?
> I don't think RI would change its behaviour in later release. In fact, 
> the
> "bug" still exists in SUN 6.0 rc version. Personally, +1 for following 
> RI.
> Any comments or better suggestions?
> Thanks!

Paulex Yang
China Software Development Lab

Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org

View raw message