JDK-6665217 : SchemaFactory.newInstance does not check context class loader in 1.6
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-02-20
  • Updated: 2012-06-09
  • Resolved: 2008-03-11
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
The documentation for SchemaFactory.newInstance includes:

"The (context) class loader is asked for service provider provider-configuration files matching javax.xml.validation.SchemaFactory in the resource directory META-INF/services"

This does not work as expected.  The context class loader is not consulted.  In javax.xml.validation.SecuritySupport.getResources there is the code fragment:

                    if (cl == null) {
                        enumeration = ClassLoader.getSystemResources(name);
                    } else {
                        enumeration = cl.getSystemResources(name);
                    }

getSystemResouces is a static method, so both parts of the if are doing the same thing.

I believe the code should read:

                    if (cl == null) {
                        enumeration = ClassLoader.getSystemResources(name);
                    } else {
                        enumeration = cl.getResources(name);
                    }

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create a jar file containing a META-INF/services definition for schema factory and set the context class loader to a url class loader pointing at the jar.  When  SchemaFactory.newInstance is called, the context class loader is not consulted.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Service definition in context class loader should be checked.
ACTUAL -
It is not.

REPRODUCIBILITY :
This bug can be reproduced always.

Comments
EVALUATION This is a duplicate of 6354969. A request was made to integrate the patch into jdk6 update releases but it has not been done. I'm upgrading the priority and re-sending the request since this is a violation of the specification.
11-03-2008