Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8185721 JAXB api openness propagation fails for JAXB annotated classes inner types
  3. JDK-8185722

Release Note: JAXB does not open packages with inner types of JAXB annotated classes

XMLWordPrintable

    • Verified

      `JAXBContext` specifies that classes annotated with `@XmlRootType` should be specified at context creation time to `JAXBContext.newInstance(Class[] classesToBeBound, ...)`

      If the client classes are in a named module, than openness of the packages containing these classes is not propagated correctly when the root JAXB classes reference JAXB types in another package.

      For example, given the following Java classes:

      `@XmlRootElement2 class Foo { Bar b;} `
      `@XmlType class Bar { FooBar fb;} `
      `@XmlType class FooBar { int x; } `

      The invocation of `JAXBContext.newInstance(Foo.class`) registers `Foo` and the statically referenced classes, `Bar` and `FooBar.`

      If `Bar` and `FooBar` are in different package than `Foo`, than openness is not propagated for them with current implementation.

      The issue can be worked around by opening the package with the `opens` directive in the module declaration. Alternatively, the `--add-opens` command line option can be used to open the package:

      For example:
      `--add-opens foo.mymodule/bar.baz=ALL-UNNAMED` (for JAXB-RI on classpath)
      `--add-opens foo.mymodule/bar.baz=<jaxb-impl>` (for JABX implementations on the application module path)

            rgrigoriadi Roman Grigoriadi (Inactive)
            rgrigoriadi Roman Grigoriadi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: