Hi Paul, Alan,

I've read your latest comments. Before getting back to you on those items, I felt it's important we get the classloader handling correctly. If it's as what I suspected (as I described in the last email), we may have problem with using ServiceLoader.

I've read Paul's explanation, esp. the delegation to ClassLoader.getSystemResourceAsStream part. It looks right as it's stated in the spec. But I do remember it was the issue for CR6723276 and I did change it to Object.class.getResourceAsStream (without a way to call bootstrap classloader).

Just as Paul said, the classloader stuff is quite tricky. I had three dummy jars that I've been running tests with. I haven't had problems loading those jars. But the tests were under 'normal' conditions, that is, the usual jdk classloader hierarchy was followed.

Also, dummy jars may work. But I should at least test Xerces. So that's what I'm going to do as well.

--Joe

On 8/30/2012 8:47 AM, Paul Sandoz wrote:
On Aug 30, 2012, at 8:59 AM, Joe Wang<huizhe.w...@oracle.com>  wrote:

Alan, Paul,

While I was writing a summery as you suggested below, I noticed an issue with 
using ServiceLoader.  I was trying to use the word 'delegate' but found the 
ServiceLoader might be doing sth. different than the original jaxp process.

Here's the spec:
The ServiceLoader.load(service) is equivalent to ServiceLoader.load(service, 
Thread.currentThread().getContextClassLoader()) where "loader - The class loader to 
be used to load provider-configuration files and provider classes, or null if the system 
class loader (or, failing that, the bootstrap class loader) is to be used "


Somehow, our earlier discussion concluded that the original process I created, 
where the context class loader is tried first, if no provider found, bootstrap 
classloader will be tried next, could be 'delegated' to the ServiceLoader.  But 
the above didn't really showed that. When I looked at the code, it actually 
simply returns false if loader.getResources fails to find a provider.
The CL.getResources will also delegate to the parent CL if one is present which 
should eventually get to the bootstrap CL.


  Also, it calls ClassLoader.getSystemResources when loader=null.  The later 
would be a regression to CR6723276 if we had called ServiceLoader.load(service, 
loader) with loader=null.


Seems as OK as i said in the previous email, since 
Object.class.getResourceAsStream does:

      public InputStream getResourceAsStream(String name) {
         name = resolveName(name);
         ClassLoader cl = getClassLoader0(); //<--- This will be null for 
Object.class
         if (cl==null) {
             // A system class.
             return ClassLoader.getSystemResourceAsStream(name);  //<--- Look!
         }
         return cl.getResourceAsStream(name);
     }

This area is complicated i think you need to write some SL tests.

Paul.

Reply via email to