In Java 8 and earlier, the default JAXP provider can be specified by way
of a system property, or by making an appropriate factory implementation
available from the context class loader. While this still functions in
Java 9, with the increased isolation of modules it is very difficult to
change the default JAXP provider classes to classes from modules. Prior
to Java 9 it was possible to install JAXP implementation classes which
acted as a proxy to non-classpath classes; however the introduction of
modules prevents this trick from working because the system default
classes are not generally accessible.
A better solution is to add a setter method which allows a Class<?
extends JAXPType> or Supplier<JAXPType> to be installed by sufficiently
privileged callers, which would take the place of the global default and
would be returned before falling back to the old system property based
mechanism.
The affected types include:
javax.xml.datatype.DatatypeFactory
javax.xml.parsers.DocumentBuilderFactory
javax.xml.parsers.SAXParserFactory
javax.xml.validation.SchemaFactory
javax.xml.transform.sax.SAXTransformerFactory
javax.xml.stream.XMLEventFactory
javax.xml.stream.XMLInputFactory
javax.xml.stream.XMLOutputFactory
javax.xml.xpath.XPathFactory
Also org.xml.sax.XMLReader implementations are located in a similar
manner. Other "FactoryFinder"-style APIs might also benefit in a
similar manner, however if they reside in upgradeable modules it is
likely less urgent.
of a system property, or by making an appropriate factory implementation
available from the context class loader. While this still functions in
Java 9, with the increased isolation of modules it is very difficult to
change the default JAXP provider classes to classes from modules. Prior
to Java 9 it was possible to install JAXP implementation classes which
acted as a proxy to non-classpath classes; however the introduction of
modules prevents this trick from working because the system default
classes are not generally accessible.
A better solution is to add a setter method which allows a Class<?
extends JAXPType> or Supplier<JAXPType> to be installed by sufficiently
privileged callers, which would take the place of the global default and
would be returned before falling back to the old system property based
mechanism.
The affected types include:
javax.xml.datatype.DatatypeFactory
javax.xml.parsers.DocumentBuilderFactory
javax.xml.parsers.SAXParserFactory
javax.xml.validation.SchemaFactory
javax.xml.transform.sax.SAXTransformerFactory
javax.xml.stream.XMLEventFactory
javax.xml.stream.XMLInputFactory
javax.xml.stream.XMLOutputFactory
javax.xml.xpath.XPathFactory
Also org.xml.sax.XMLReader implementations are located in a similar
manner. Other "FactoryFinder"-style APIs might also benefit in a
similar manner, however if they reside in upgradeable modules it is
likely less urgent.
- relates to
-
JDK-8169778 Add new public methods to get new instances of the JAXP factories builtin system-default implementations
- Resolved