mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 20:24:46 +00:00
HHH-17579 fix classloader issues with JAXBContext since JDK11
This commit is contained in:
parent
037336ea83
commit
d1f1e6e8b9
@ -9,6 +9,7 @@
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import javax.tools.FileObject;
|
||||
@ -120,7 +121,14 @@ public <T> T getJaxbRoot(InputStream stream, Class<T> clazz, Schema schema)
|
||||
ContextProvidingValidationEventHandler handler = new ContextProvidingValidationEventHandler();
|
||||
try {
|
||||
staxEventReader = new JpaNamespaceTransformingEventReader( staxEventReader );
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance( ObjectFactory.class );
|
||||
|
||||
// Class.getClassLoader() may return null if the class was loaded by the bootstrap class loader,
|
||||
// but since we don't expect the annotation processor to be loaded by that class loader,
|
||||
// we expect the return to be non-null and hence cast
|
||||
ClassLoader cl = NullnessUtil.castNonNull( ObjectFactory.class.getClassLoader() );
|
||||
String packageName = NullnessUtil.castNonNull( ObjectFactory.class.getPackage() ).getName();
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance( packageName, cl );
|
||||
|
||||
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||
unmarshaller.setSchema( schema );
|
||||
unmarshaller.setEventHandler( handler );
|
||||
|
Loading…
x
Reference in New Issue
Block a user