[ 
https://issues.apache.org/jira/browse/KARAF-7084?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17309302#comment-17309302
 ] 

Grzegorz Grzybek commented on KARAF-7084:
-----------------------------------------

Knowing that "Karaf specs" modules are supposed to enhance the discovery 
mechanisms highlighted in JAXP specification, I believe it is wise to assume 
few requirements:
* karaf/specs/java.xml[.ws] libraries should shade/replace _original_ discovery 
mechanisms from JAXP 1.6 and further JDK9+ releases which don't increment JAXP 
specification version without touching anything else
* we should keep every possible discovery step (like checking 
{{jaxp.properties}} file or some system properties) and only add _OSGi locator_ 
step before proceeding to {{ServiceLoader}} usage
* we should change _every_ JAXP factory and also JAXB/SAAJ/JAX-RS/JAX-WS
* we also should change the Activation API discovery mechanism when searching 
for:
** {{META-INF/mailcap}}
** {{META-INF/mime.types}}

[~gnodet] confirmed that Karaf's {{specs}} module is an incarnation of SMX 
{{locator}} + {{activator}} libraries that themselves are based on JAXP APIs 
that _may_ (please confirm [~gnodet]) date back to very old APIs from before 
the time where {{ServiceLoader}} was used everywhere.

I wanted to track down the JAXP API source code to work on two goals:
* Karaf's XML spec libraries for JDK8 should go to {{endorsed}} directory and 
should be based on real JAXP source code from jdk8u repositories
* Karaf's XML spec libraries for JDK9+ (effectively JDK11+) should be used with 
{{--patch-module=java.xml}} and should be based on real *post-JAXP* source code 
from jdk11u repositories

Fortunately, with [JEP 369|https://openjdk.java.net/jeps/369] we can finally 
see entire history of all (relevant) JDKs (including JDK8) in GitHub. For me 
personally it's much easier to track history of individual files/packages in 
Git than in Mercurial.

So here's what I found in https://github.com/openjdk/jdk8u/tree/master/jaxp:
{noformat}
* (2017-10-19 17:03:20 +0100) 9dff2c4611 8186080: Transform XML interfaces 
8188880: A JAXB JCK test failure found after 8186080 <Aleksei Efimov>
* (2017-04-06 21:26:31 +0300) bab2bdb000 8176731: JCK tests in 
api/javax_xml/transform/ spec conformance started failing after 8172469 
<Aleksei Efimov>
* (2017-03-07 13:49:26 +0300) c435b236e9 8172469: Transform Transformer 
Exceptions <Aleksei Efimov>
* (2014-01-28 09:20:40 -0800) 951552b79f 8032392: Spec: 
javax.xml.stream.XMLEventFactory/XMLOutputFactory/XMLInputFactory.newFactory(String,
 ClassLoader) referring to ServiceLoader.load(Class, ClassLoader) <Joe Wang>
* (2013-12-23 11:26:36 -0800) 8164cbcdd1 8029236: Update copyright year to 
match last edit in jdk8 jaxp repository for 2013 <Joe Wang>
* (2013-12-12 11:36:40 -0800) a1f10b3f0b 8029895: 
XMLOutputFactory.newFactory(String, ClassLoader) - incorrect specification <Joe 
Wang>
* (2013-12-04 00:17:12 -0800) fcc3014ea5 8027973: Error in the documentation 
for newFactory method of the javax.xml.stream factories <Joe Wang>
*   (2013-10-11 19:49:44 +0100) 5528179e83 Merge <Chris Hegarty>
|\  
| * (2013-07-17 18:46:28 +0200) dee5d80756 8013502: Improve stream factories 
<Daniel Fuchs>
* | (2013-10-04 19:15:10 +0200) 785483b7a9 8025745: Clarify API documentation 
of JAXP factories <Daniel Fuchs>
|/  
* (2013-06-06 20:40:43 +0400) 53ae44836c 8009579: Xpathexception does not honor 
initcause() <Aleksej Efimov>
* (2013-05-10 09:23:22 -0700) 8620b1e2d7 8014333: javadoc error in JAXP 1.5 
patch <Joe Wang>
* (2013-05-08 23:38:03 -0700) f0330c4199 8011653: Upgrade JDK8 to JAXP 1.5 <Joe 
Wang>
* (2013-04-17 15:23:19 +0200) 9a94591b8e 8005954: JAXP Plugability Layer should 
use java.util.ServiceLoader <Daniel Fuchs>
* (2013-02-18 11:33:35 -0800) 8b12f5abcc 6657673: Issues with JAXP <Joe Wang>
* (2013-02-05 14:56:34 +0000) 3d09f6b621 8007389: Remove uses of _ as 
identifier in jaxp <Eric McCorkle>
* (2012-12-27 18:17:58 -0800) c04f299d28 8005473: Warnings compiling jaxp <Joe 
Wang>
* (2012-08-17 09:49:42 -0700) 5d2e65169c 7191547: 
XMLEventFactory.newFactory(String factoryId, ClassLoader loader) does not work 
as expected <Joe Wang>
* (2012-04-17 11:17:59 -0700) db4db38876 7160380: Sync JDK8 with JAXP 1.4.5 
<Joe Wang>
* (2012-04-12 08:38:26 -0700) 60663487f6 7160496: Rename JDK8 JAXP source 
directory <Joe Wang>
{noformat}

There are no major changes after 2013.

Checking the same for 
https://github.com/openjdk/jdk11u/tree/master/src/java.xml/share/classes, and 
including the refactorings related to modularization I found that {{8032392}} 
bug:
bq. Spec: 
javax.xml.stream.XMLEventFactory/XMLOutputFactory/XMLInputFactory.newFactory(String,
 ClassLoader) referring to ServiceLoader.load(Class, ClassLoader)

is present in both JDK8 and JDK11. Then {{2098d07f0f 8172469: Transform 
Transformer Exceptions}} is also added to both JDK8 and JDK11 around 2017.
I found some synchronization with Xerces/Xalan, but the very interesting thing 
is https://github.com/openjdk/jdk11u/commit/ed903000ea related to 
https://bugs.openjdk.java.net/browse/JDK-8081248:
bq. JDK-8081248 – Implement JEP 268: XML Catalog API

Even if JDK-8081248 mentions {{jaxp}} Jira component, there's no sign that any 
new JAXP specification was released through JSR process...

> Not every factory access from JAXP (specs/java.xml) goes through OsgiLocator
> ----------------------------------------------------------------------------
>
>                 Key: KARAF-7084
>                 URL: https://issues.apache.org/jira/browse/KARAF-7084
>             Project: Karaf
>          Issue Type: Bug
>            Reporter: Grzegorz Grzybek
>            Assignee: Grzegorz Grzybek
>            Priority: Major
>             Fix For: 4.3.2
>
>
> I was checking this code:
> {code:java}
> System.out.println("== JAXP");
> info(DatatypeFactory.class, DatatypeFactory.newInstance());
> info(DocumentBuilderFactory.class, DocumentBuilderFactory.newInstance());
> info(SAXParserFactory.class, SAXParserFactory.newInstance());
> info(XMLEventFactory.class, XMLEventFactory.newInstance());
> info(XMLInputFactory.class, XMLInputFactory.newInstance());
> info(XMLOutputFactory.class, XMLOutputFactory.newInstance());
> info(TransformerFactory.class, TransformerFactory.newInstance());
> info(SchemaFactory.class, 
> SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI));
> info(XPathFactory.class, XPathFactory.newInstance());
> System.out.println("== SAAJ");
> try {
>     info(MessageFactory.class, MessageFactory.newInstance());
>     info(SOAPConnectionFactory.class, SOAPConnectionFactory.newInstance());
>     info(SOAPFactory.class, SOAPFactory.newInstance());
> } catch (Throwable ignored) {
> }
> System.out.println("== JAX-WS");
> try {
>     info(Provider.class, Provider.provider());
> } catch (Throwable ignored) {
> }
> System.out.println("== JAXB");
> try {
>     info(JAXBContext.class, JAXBContext.newInstance("grgr.test.jaxb.model", 
> getClass().getClassLoader()));
>     Class<?> cfClass = 
> FrameworkUtil.getBundle(this.getClass()).adapt(BundleWiring.class).getClassLoader().loadClass("com.sun.xml.bind.v2.ContextFactory");
>     System.out.println("ContextFactory class = " + cfClass);
> } catch (Throwable ignored) {
> }
> ...
> private void info(Class<?> clazz, Object service) {
>     System.out.printf(" - %s: %s%n", clazz, service.getClass().getName());
>     System.out.printf(" - %s%n", FrameworkUtil.getBundle(service.getClass()));
> }
> {code}
> TO see if I really can get implementations of JAXP interfaces, if given 
> interface is implemented in a bundle with proper 
> {{/META-INF/services/<service-name>}}. It works well with _some_ JAXP 
> interfaces and with SAAJ. However it doesn't work with:
> * javax.xml.validation.SchemaFactory
> * javax.xml.xpath.XPathFactory
> * org.xml.sax.helpers.XMLReaderFactory (here there's not even a shaded 
> factory in {{java.xml}} Karaf spec)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to