JDK-8185264 : Release Note: JAXBContext cannot be created with java.base classes as parameters for JAXBContext#newInstance method
  • Type: Sub-task
  • Component: xml
  • Sub-Component: jaxb
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2017-07-25
  • Updated: 2018-05-02
  • Resolved: 2018-04-25
Description
Calling JAXBContext#newInstance(Class[] classesToBeBound) and JAXBContext#newInstance(Class[] classesToBeBound, Map<String,?> properties ) with classes from java.base as parameters for "classesToBeBound" causes JAXBException, with following description:
Package java.lang with JAXB class (class name) defined in a module java.base must be open to at least java.xml.bind module.

Generally passing java.base classes to JAXBContext is unnecessary and should be avoided with an exception for using javax.xml.bind.JAXBElement with an array as its root type.

Workaround: declare openness propagation for those explicitly with --add-opens
For example:
--add-opens��java.base/java.lang=java.xml.bind
Comments
The Java EE modules have been removed from the JDK as of JDK 11.
25-04-2018