< prev index next >
src/java.xml.bind/share/classes/javax/xml/bind/ContextFinder.java
Print this page
@@ -180,10 +180,13 @@
Class spFactory,
ClassLoader classLoader,
Map properties) throws JAXBException {
try {
+
+ ModuleUtil.delegateAddOpensToImplModule(contextPathClasses, spFactory);
+
/*
* javax.xml.bind.context.factory points to a class which has a
* static method called 'createContext' that
* returns a javax.xml.JAXBContext.
*/
@@ -213,12 +216,10 @@
if (!(context instanceof JAXBContext)) {
// the cast would fail, so generate an exception with a nice message
throw handleClassCastException(context.getClass(), JAXBContext.class);
}
- ModuleUtil.delegateAddOpensToImplModule(contextPathClasses, spFactory);
-
return (JAXBContext) context;
} catch (InvocationTargetException x) {
// throw if it is exception not to be wrapped
// otherwise, wrap with a JAXBException
Throwable e = handleInvocationTargetException(x);
@@ -272,19 +273,19 @@
static JAXBContext newInstance(Class[] classes,
Map properties,
Class spFactory) throws JAXBException {
try {
+ ModuleUtil.delegateAddOpensToImplModule(classes, spFactory);
Method m = spFactory.getMethod("createContext", Class[].class, Map.class);
Object obj = instantiateProviderIfNecessary(spFactory);
Object context = m.invoke(obj, classes, properties);
if (!(context instanceof JAXBContext)) {
// the cast would fail, so generate an exception with a nice message
throw handleClassCastException(context.getClass(), JAXBContext.class);
}
- ModuleUtil.delegateAddOpensToImplModule(classes, spFactory);
return (JAXBContext) context;
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new JAXBException(e);
} catch (InvocationTargetException e) {
@@ -326,13 +327,12 @@
JAXBContextFactory obj = ServiceLoaderUtil.firstByServiceLoader(
JAXBContextFactory.class, logger, EXCEPTION_HANDLER);
if (obj != null) {
- JAXBContext context = obj.createContext(contextPath, classLoader, properties);
ModuleUtil.delegateAddOpensToImplModule(contextPathClasses, obj.getClass());
- return context;
+ return obj.createContext(contextPath, classLoader, properties);
}
// to ensure backwards compatibility
factoryName = firstByServiceLoaderDeprecated(JAXBContext.class, classLoader);
if (factoryName != null) return newInstance(contextPath, contextPathClasses, factoryName, classLoader, properties);
@@ -383,13 +383,12 @@
JAXBContextFactory factory =
ServiceLoaderUtil.firstByServiceLoader(JAXBContextFactory.class, logger, EXCEPTION_HANDLER);
if (factory != null) {
- JAXBContext context = factory.createContext(classes, properties);
ModuleUtil.delegateAddOpensToImplModule(classes, factory.getClass());
- return context;
+ return factory.createContext(classes, properties);
}
// to ensure backwards compatibility
String className = firstByServiceLoaderDeprecated(JAXBContext.class, getContextClassLoader());
if (className != null) return newInstance(classes, properties, className);
< prev index next >