Skip to content

Turn netex-java-model into a JPMS module - #301

Draft
t2gran wants to merge 1 commit into
masterfrom
java-module
Draft

t2gran wants to merge 1 commit into
masterfrom
java-module

Conversation

@t2gran

@t2gran t2gran commented Sep 21, 2026

Copy link
Copy Markdown

Summary

Turns netex-java-model into a proper JPMS module by adding a module-info.java
(org.entur.netex.java.model), replacing the Automatic-Module-Name manifest
entry that was there before. Also renames org.rutebanken.util to
org.rutebanken.netex.util for consistency with the other
org.rutebanken.netex.* packages.

This needs to land as 3.x — the package rename breaks anyone importing
org.rutebanken.util.* directly (the four XmlAdapter classes).

What's in module-info.java

  • requires transitive on jakarta.xml.bind, java.xml, and
    org.apache.commons.lang3 — their types leak into our public API
    (JAXBException, QName/XMLGregorianCalendar on NeTExValidator, and
    OmitNullsToStringStyle extends ToStringStyle), so callers need readability
    to them too.
  • The generated packages (org.rutebanken.netex.model, net.opengis.gml._3,
    uk.org.siri.siri) are opensed to jakarta.xml.bind,
    org.glassfish.jaxb.runtime, and org.apache.commons.lang3. XJC generates
    field-level JAXB access (@XmlAccessorType(FIELD)) and the generated
    toString() uses ReflectionToStringBuilder, both of which need reflective
    field access. All three targets were confirmed necessary by removing each
    one and rerunning mvn clean test until it broke — nothing here is a guess.
  • mvn clean test is verifying the module-info.java - no other automatic
    tests/verification is needed.

Open questions for review

  • Should exports/opens be narrowed further? Right now everything
    compiled from the schema is exported. net.opengis.gml._3 and
    uk.org.siri.siri have to stay exported (model getters return those types
    directly), but org.rutebanken.netex (just OmitNullsToStringStyle) and
    org.rutebanken.netex.util (the XmlAdapters) are only ever referenced
    from generated code in the same module — they may not need to be exported
    at all, possibly just opens ... to org.glassfish.jaxb.runtime for the
    adapters so JAXB can still instantiate them reflectively.
  • PublicationDeliveryClient doesn't look like it belongs in a model
    library.
    It's a raw HttpURLConnection POST client with no timeouts,
    auth, or retry handling, and it's the only place that needs slf4j for its
    own sake (NeTExValidator uses slf4j regardless, so removing the client
    doesn't drop the dependency, just this one usage of it). Candidate for
    removal in this same 3.x bump, or split into a separate module — needs a
    decision before merge since it's a real API removal.
  • Why is uk.org.siri.siri a dependency at all? It's not us pulling in
    something unrelated — NeTEx_siri.xsd is part of NeTEx's own official
    schema (bundled in the NeTEx repo we download from), and it's used by 7
    DataObject*/subscription-related classes for a SIRI-based real-time
    query/subscription API layer. Since XJC compiles transitively from
    NeTEx_publication.xsd, this gets generated whether or not any given
    consumer uses it.
  • io.github.threeten-jaxb:threeten-jaxb-core should be inlined. Its
    DurationXmlAdapter is ~8 lines wrapping Duration.parse/.toString().
    Not worth a dependency (and its module) for that — copy it into
    org.rutebanken.netex.util alongside the other adapters and drop the
    dependency.

None of the four items above are implemented in this PR — flagging them here
for discussion before deciding what else goes into the 3.x bump.

Adds module-info.java declaring org.entur.netex.java.model, replacing
the Automatic-Module-Name manifest entry. requires transitive is used
for jakarta.xml.bind, java.xml and org.apache.commons.lang3 since their
types leak into the public API (JAXBException, QName/XMLGregorianCalendar,
OmitNullsToStringStyle extends ToStringStyle).

The generated model packages (org.rutebanken.netex.model, net.opengis.gml._3,
uk.org.siri.siri) use field-level JAXB access, so they're opened to
jakarta.xml.bind, org.glassfish.jaxb.runtime and org.apache.commons.lang3 -
verified by running with each opens target removed until `mvn clean test`
passed cleanly on the module path (Surefire auto-detects module-info.java
and runs on the module path).

Also renames org.rutebanken.util to org.rutebanken.netex.util for
consistency with the other org.rutebanken.netex.* packages.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@t2gran
t2gran marked this pull request as draft September 21, 2026 11:00
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant