The issue actually has nothing to do with support for namespaces, and
neither JAXB nor the JDK are at fault here. The problem is caused by a
latent bug in Plexus Classworlds that is triggered by a change in the
ClassLoader class in Java 9. It causes package annotations not to be
loaded. This ultimately manifests itself as problems with XML
namespaces because the package annotations that get missed in this
case define mappings between Java packages/classes and XML namespaces.

The net effect is the same as if you removed those annotations from
the JAXB code. Obviously neither JAXB nor the JDK can be blamed for
this.

Because of the specifics of the bug in Classworlds, it turns out that
it's possible to work around it by preloading the package-info classes
(which contain those package annotations), which is what the PR does.

Andreas

On Mon, Mar 25, 2019 at 7:01 AM Lennart Jörelid
<[email protected]> wrote:
>
> I merged this change to just not keep this stalled anymore.
>
> It seems that XML namespaces are somewhat under-explained in the development 
> community overall - implying that the support for them in may places is 
> lackluster.
> However, I basically think it is the wrong approach -
>
> XML is a standard, and it is important that all JDK versions produce the same 
> (and usable) XML from the same sources. Without tweaking the project itself.
>
>
> On Sun, Mar 24, 2019 at 11:15 PM Andreas Veithen <[email protected]> 
> wrote:
>>
>> On Mon, Oct 8, 2018 at 5:13 PM Lennart Jörelid
>> <[email protected]> wrote:
>> >
>> > Hello all,
>> >
>> > I am pondering the future of the JAXB2 Maven plugin, following three 
>> > rather problematic properties:
>> >
>> > The JAXB2-Maven-Plugin was implemented to delegate Java compilation and 
>> > XML or Schema compilation to the tools within the JDK.
>> > The JAXB support including tooling is removed from JDK 11 and onwards.
>> > The tooling contains subtle but rather serious bugs which has created a 
>> > decently complex mess of workarounds within the plugin. For example - the 
>> > XML schema created from one of the integration tests within the plugin 
>> > generates incorrect results in JDK9+, as shown in the snippet below. The 
>> > JDK8 schemagen tool generates a schema element [including child elements] 
>> > with correct namespace prefix, implying that the schema element correctly 
>> > resides within the XMLSchema namespace. The JDK9 and JDK10 schemagen tools 
>> > incorrectly generates a schema element without a namespace prefix, 
>> > implying that the schema element is placed within the targetNamespace, 
>> > which is normally the target of each schemagen compilation for each unique 
>> > XML namespace within the compilation unit.
>>
>> That issue is in fact caused by MNG-6506 and there is a workaround:
>> https://github.com/mojohaus/jaxb2-maven-plugin/pull/124.
>>
>> >
>> > Snippets:
>> >
>> > JDK 1.8 execution:
>> > ==================
>> > <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> > <xs:schema version="1.0" targetNamespace="http://acme.com/customer-api"; 
>> > xmlns:tns="http://acme.com/customer-api"; 
>> > xmlns:xs="http://www.w3.org/2001/XMLSchema";>
>> >
>> > JDK 9,10 execution:
>> > ================
>> > <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>> > <schema version="1.0" targetNamespace="http://acme.com/customer-api"; 
>> > xmlns:tns="http://acme.com/customer-api"; 
>> > xmlns:xs="http://www.w3.org/2001/XMLSchema";>
>> >
>> > So ... We have at least 3 options here:
>> >
>> > File a bug report against the development of JDK 9 and 10 (but if I 
>> > understand correctly, there is no development going on within these JDK 
>> > releases), and hope that this bug gets fixed.
>> > Find another tool to generate XML Schema from JAXB annotations. This seems 
>> > like a better way than the JDK tooling bug approach above, although it 
>> > requires a more-or-less complete rewrite of the plugin's internals. 
>> > Question: What polyglot Annotation processors or DSL generators do you 
>> > recommend?
>> > Just freeze development of JMP at JDK 8; simply put the codebase into 
>> > sunset. This is doable, but not really desirable.
>> >
>> > What do you think? Which way should we take?
>> >
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "mojohaus-dev" group.
>> > To unsubscribe from this group and stop receiving emails from it, send an 
>> > email to [email protected].
>> > To post to this group, send email to [email protected].
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msgid/mojohaus-dev/3bd959d7-c9d7-4d9d-ae8a-5034e07c25a6%40googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "mojohaus-dev" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/mojohaus-dev/4AQa45VHo3c/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/mojohaus-dev/CADx4_uVza9NDZTOg7DV%2BLqF_6pWr3pUAF-ffP5OWhpUd4K08JQ%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> --
> +==============================+
> | Bästa hälsningar,
> | [sw. "Best regards"]
> |
> | Lennart Jörelid
> | EAI Architect & Integrator
> |
> | jGuru Europe AB
> | Mölnlycke - Kista
> |
> | Email: [email protected]
> | URL:   www.jguru.se
> | Phone
> | (skype):    jgurueurope
> | (intl):     +46 708 507 603
> | (domestic): 0708 - 507 603
> +==============================+
>
> --
> You received this message because you are subscribed to the Google Groups 
> "mojohaus-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/mojohaus-dev/CAJ1fz80Rpe6_QXuQzZb59r1__rB%2B0OXVrPb4SLZhrR4yDK12qQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"mojohaus-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mojohaus-dev/CADx4_uXOZFrK39dN06NJsfY8R-SWXv9HEx_cLGmDn4yc9HrXKA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to