JDK-8005954 : JAXP Plugability Layer should use java.util.ServiceLoader
  • Type: Enhancement
  • Component: xml
  • Sub-Component: jaxp
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2013-01-09
  • Updated: 2017-05-17
  • Resolved: 2013-04-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b89Fixed
Related Reports
Cloners :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
JAXP defines a Plugability Layer that specifies how it will locate an implementation or service provider. In the Java API documentation, the Plugability Layer is described in all of the factories including 
javax.xml.datatype.DatatypeFactory, javax.xml.parsers.DocumentBuilderFactory, javax.xml.parsers.SAXParserFactory, javax.xml.stream.XMLEventFactory, javax.xml.stream.XMLInputFactory, javax.xml.stream.XMLOutputFactory, javax.xml.transform.TransformerFactory, javax.xml.validation.SchemaFactory, and javax.xml.xpath.XPathFactory.

The process is best described in javax.xml.datatype.DatatypeFactory as follows.

Quote from the Java API Documentation of javax.xml.datatype.DatatypeFactory:

newInstance() is used to create a new DatatypeFactory. The following implementation resolution mechanisms are used in the following order:

1. If the system property specified by DATATYPEFACTORY_PROPERTY, "javax.xml.datatype.DatatypeFactory", exists, a class with the name of the property's value is instantiated. Any Exception thrown during the instantiation process is wrapped as a DatatypeConfigurationException. 

2. If the file ${JAVA_HOME}/lib/jaxp.properties exists, it is loaded in a Properties Object. The Properties Object is then queried for the property as documented in the prior step and processed as documented in the prior step. 

3. The services resolution mechanism is used, e.g. META-INF/services/java.xml.datatype.DatatypeFactory. Any Exception thrown during the instantiation process is wrapped as a DatatypeConfigurationException. 

4. The final mechanism is to attempt to instantiate the Class specified by DATATYPEFACTORY_IMPLEMENTATION_CLASS. Any Exception thrown during the instantiation process is wrapped as a DatatypeConfigurationException. 


In a module system, the location of a service provider will be centered around finding modules that provide the service. The process defined in the JAXP Plugability Layer will need to be modified accordingly. This change request is targeted to changing the 3rd step, the basis of the process. Other changes will be requested in the future as the general solutions in the areas of module finding and loading become clearer (for example, if there may be a preferred service, or if there's a way to pick a specific provider).


Below is the change for the 3rd step. 

In javax.xml.datatype.DatatypeFactory, the description of the process is in the beginning of the class, while for all other factories, it is in the newInstance method. The descriptions were slightly different among different factories. With this change, all of them will use the same text as follows.

3. Using the service-provider loading facility defined by the java.util.ServiceLoader class to attempt to locate and load an implementation of the service. Any Exception thrown during the instantiation process is wrapped as a ConfigurationException.

Comments
It is for JEP162. The test code is still on preparing and has not been push into either openjdk or sqe repo. Mark it as "sqe-testdev-needed" temporarily
19-07-2013