XmlJavaTypeAdapter (Java Platform SE 8 )
Keywords: javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter class
Date: 2026-04-22

javax.xml.bind.annotation.adapters

## Annotation Type XmlJavaTypeAdapter

-     @Retention(value=RUNTIME)
       @Target(value={PACKAGE,FIELD,METHOD,TYPE,PARAMETER})
      public @interface XmlJavaTypeAdapter

  Use an adapter that implements `XmlAdapter` for custom marshaling.

  Usage:

  The `@XmlJavaTypeAdapter` annotation can be used with the following program elements:

  - a JavaBean property
  - field
  - parameter
  - package
  - from within `XmlJavaTypeAdapters`

  When `@XmlJavaTypeAdapter` annotation is defined on a class, it applies to all references to the class.

  When `@XmlJavaTypeAdapter` annotation is defined at the package level it applies to all references from within the package to `@XmlJavaTypeAdapter.type()`.

  When `@XmlJavaTypeAdapter` annotation is defined on the field, property or parameter, then the annotation applies to the field, property or the parameter only.

  A `@XmlJavaTypeAdapter` annotation on a field, property or parameter overrides the `@XmlJavaTypeAdapter` annotation associated with the class being referenced by the field, property or parameter.

  A `@XmlJavaTypeAdapter` annotation on a class overrides the `@XmlJavaTypeAdapter` annotation specified at the package level for that class.

  This annotation can be used with the following other annotations: `XmlElement`, `XmlAttribute`, `XmlElementRef`, `XmlElementRefs`, `XmlAnyElement`. This can also be used at the package level with the following annotations: `XmlAccessorType`, `XmlSchema`, `XmlSchemaType`, `XmlSchemaTypes`.

  Example: See example in `XmlAdapter`

  Since:
    JAXB2.0
  See Also:
    `XmlAdapter`

- - ### Required Element Summary

    Required Elements
    Modifier and Type | Required Element and Description
    --- | ---
    `Class<? extends XmlAdapter>` | `value` Points to the class that converts a value type to a bound type or vice versa.

  - ### Optional Element Summary

    Optional Elements
    Modifier and Type | Optional Element and Description
    --- | ---
    `Class` | `type` If this annotation is used at the package level, then value of the type() must be specified.

- - ### Element Detail

    - #### value

          public abstract Class<? extends XmlAdapter> value

      Points to the class that converts a value type to a bound type or vice versa. See `XmlAdapter` for more details.

  - - #### type

          public abstract Class type

      If this annotation is used at the package level, then value of the type() must be specified.
      Default:
        javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT.class

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.