Skip to content

Remove JAXB dependencies from XML encoding #1978

Description

@kevinherron

milo-encoding-xml depends on jakarta.xml.bind-api and jaxb-runtime, but its JAXB usage is limited to DatatypeConverter calls in OpcUaXmlEncoder and OpcUaXmlDecoder. XML reading and writing use DOM and StAX, with no JAXB marshalling or annotated model classes.

Replacing these conversion calls with JDK functionality and small internal helpers would remove the JAXB dependency chain.

Proposed change

Remove the dependencies in two steps:

  1. Remove jaxb-runtime. The JAXB API includes a default DatatypeConverterImpl, so the conversion calls appear to work without a separate runtime provider. Verify this with the runtime absent from the test classpath.
  2. Replace DatatypeConverter with internal conversion helpers and remove jakarta.xml.bind-api.

Most replacements can use JDK functionality:

  • Integer and boolean conversions with XML lexical validation.
  • Floating-point conversions with support for INF, -INF, and NaN.
  • java.util.Base64 with appropriate whitespace and padding handling.
  • javax.xml.datatype.DatatypeFactory for date/time parsing, which JAXB already uses internally.

Compatibility and verification

Preserve valid OPC UA XML representations and existing decoding-error handling. Cover XML whitespace, numeric boundaries, floating-point special values, Base64, and date/time offsets and fractional seconds.

Review malformed-input behavior explicitly. The existing JAXB implementation accepts some invalid integer forms and can silently overflow or narrow values. Replacements should follow OPC UA/XML Schema requirements, with intentional behavior changes documented and tested.

Verify that the XML encoding tests pass without JAXB or its transitive dependencies on the classpath.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions