-
Sub-task
-
Resolution: Delivered
-
P4
-
9
-
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)
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)