diff --git a/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml b/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml index 3a7ebc5c771a..54a6b41f1120 100644 --- a/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml +++ b/dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml @@ -2536,11 +2536,6 @@ org.eclipse.persistence.core 3.0.2 - - org.eclipse.persistence - org.eclipse.persistence.core - 4.0.0-M3 - org.eclipse.persistence org.eclipse.persistence.jpa.jpql diff --git a/dev/cnf/oss_dependencies.maven b/dev/cnf/oss_dependencies.maven index b11db0c9c1ed..55dff86671fa 100644 --- a/dev/cnf/oss_dependencies.maven +++ b/dev/cnf/oss_dependencies.maven @@ -503,7 +503,6 @@ org.eclipse.persistence:org.eclipse.persistence.antlr:2.7.10 org.eclipse.persistence:org.eclipse.persistence.asm:9.3.0 org.eclipse.persistence:org.eclipse.persistence.core:2.7.10 org.eclipse.persistence:org.eclipse.persistence.core:3.0.2 -org.eclipse.persistence:org.eclipse.persistence.core:4.0.0-M3 org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:2.7.10 org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:3.0.2 org.eclipse.persistence:org.eclipse.persistence.jpa.modelgen.processor:2.7.10 diff --git a/dev/io.openliberty.jakarta.xmlBinding.4.0/.classpath b/dev/io.openliberty.jakarta.xmlBinding.4.0/.classpath index a662f9fe3fc1..95ed115d1a15 100644 --- a/dev/io.openliberty.jakarta.xmlBinding.4.0/.classpath +++ b/dev/io.openliberty.jakarta.xmlBinding.4.0/.classpath @@ -1,7 +1,10 @@ - - + + + + + diff --git a/dev/io.openliberty.jakarta.xmlBinding.4.0/bnd.bnd b/dev/io.openliberty.jakarta.xmlBinding.4.0/bnd.bnd index 658dfe655c34..3e5c7d5822ad 100644 --- a/dev/io.openliberty.jakarta.xmlBinding.4.0/bnd.bnd +++ b/dev/io.openliberty.jakarta.xmlBinding.4.0/bnd.bnd @@ -18,8 +18,7 @@ Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=11))" Bundle-SymbolicName: io.openliberty.jakarta.xmlBinding.4.0; singleton:=true -Export-Package: jakarta.xml.bind.*;thread-context=true;version="4.0", \ - io.openliberty.jakarta.xmlBinding.*;version="4.0" +Export-Package: jakarta.xml.bind.*;thread-context=true;version="4.0" Service-Component: \ io.openliberty.jakarta.xmlBinding._4_0_${replace;${bVersion};\\.;_}.ResourceProvider; \ @@ -39,11 +38,9 @@ DynamicImport-Package: \ org.glassfish.jaxb.* Include-Resource:\ - @${repo;jakarta.xml.bind:jakarta.xml.bind-api;4.0.0;EXACT}!/!(META-INF/maven/*|module-info.class), \ - io/openliberty/jakarta=${bin}/io/openliberty/jakarta, \ - jakarta/xml/bind=${bin}/jakarta/xml/bind + @${repo;jakarta.xml.bind:jakarta.xml.bind-api;4.0.0;EXACT}!/!(META-INF/maven/*|module-info.class) -instrument.classesExcludes: jakarta/**/*.class +instrument.disabled: true publish.wlp.jar.suffix: dev/api/spec diff --git a/dev/io.openliberty.jakarta.xmlBinding.4.0/resources/io/openliberty/jakarta/xmlbinding/resources/JAXBMessages.nlsprops b/dev/io.openliberty.jakarta.xmlBinding.4.0/resources/io/openliberty/jakarta/xmlbinding/resources/JAXBMessages.nlsprops deleted file mode 100644 index 2c2a4d9cce35..000000000000 --- a/dev/io.openliberty.jakarta.xmlBinding.4.0/resources/io/openliberty/jakarta/xmlbinding/resources/JAXBMessages.nlsprops +++ /dev/null @@ -1,30 +0,0 @@ -############################################################################### -# Copyright (c) 2022 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### - -# NLS_MESSAGEFORMAT_ALL -# -#CMVCPATHNAME io.openliberty.jakarta.xmlbinding.4.0/resources/io/openliberty/jakarta/xmlbinding/resources/JAXBMessages.nlsprops -#ISMESSAGEFILE TRUE -#COMPONENTPREFIX CWWKW -#COMPONENTNAMEFOR CWWKW WebSphere XML Binding Tools Code -#RANGE 1400 - 1499 -#Message range shared with com.ibm.ws.jaxb.tools, com.ibm.ws.jaxb.tools.2.3, io.openliberty.xmlbinding.3.0.internal.tools, and io.openliberty.jakarta.xmlBinding.4.0 -# -#NLS_MESSAGEFORMAT_VAR -#NLS_ENCODING=UNICODE - -warning.property.map.jaxbcontextfactory.not.found=CWWKW1404W: The jakarta.xml.bind.JAXBContextFactory property was found in the Properties map and set to {0}, but the specified implementation cannot load. The default reference implementation will be used. -warning.property.map.jaxbcontextfactory.not.found.explanation=The JAXBContextFactory property is set to an alternate implementation but the specified XML Binding implementation is not available on the application class path. -warning.property.map.jaxbcontextfactory.not.found.useraction=Configure the alternate XML Binding implementation to be available to the application class path, or the default reference implementation will be used. - -warning.system.property.jaxbcontextfactory.not.found=CWWKW1405W: The specified System Property: jakarta.xml.bind.JAXBContextFactory is set to {0}, but is not available. The default value will be used. See {1} -warning.system.property.jaxbcontextfactory.not.found.explanation=The JAXBContextFactory is set to an alternate implementation but the specified XML Binding implementation is not available on the application class path. -warning.system.property.jaxbcontextfactory.not.found.useraction=Configure the alternate XML Binding implementation to be available to the application class path, or the default reference implementation will be used. diff --git a/dev/io.openliberty.jakarta.xmlBinding.4.0/src/io/openliberty/jakarta/xmlbinding/JaxbConstants.java b/dev/io.openliberty.jakarta.xmlBinding.4.0/src/io/openliberty/jakarta/xmlbinding/JaxbConstants.java deleted file mode 100644 index 72e3869e2d71..000000000000 --- a/dev/io.openliberty.jakarta.xmlBinding.4.0/src/io/openliberty/jakarta/xmlbinding/JaxbConstants.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package io.openliberty.jakarta.xmlbinding; - -import java.util.ResourceBundle; - -public class JaxbConstants { - public static final String TR_GROUP = "Jaxb"; - - public static final String TR_RESOURCE_BUNDLE = "io.openliberty.jakarta.xmlbinding.resources.JAXBMessages"; - - public static final String WARNING_PROPERTY_MAP_JAXBCONTEXTFACTORY = "warning.property.map.jaxbcontextfactory.not.found"; - - public static final String WARNING_SYSTEM_PROPERTY_JAXBCONTEXTFACTORY = "warning.system.property.jaxbcontextfactory.not.found"; - - public static final ResourceBundle messages = ResourceBundle.getBundle(TR_RESOURCE_BUNDLE); -} diff --git a/dev/io.openliberty.jakarta.xmlBinding.4.0/src/io/openliberty/jakarta/xmlbinding/JaxbToolsUtil.java b/dev/io.openliberty.jakarta.xmlBinding.4.0/src/io/openliberty/jakarta/xmlbinding/JaxbToolsUtil.java deleted file mode 100644 index 4c6e38c6525d..000000000000 --- a/dev/io.openliberty.jakarta.xmlBinding.4.0/src/io/openliberty/jakarta/xmlbinding/JaxbToolsUtil.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2022 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package io.openliberty.jakarta.xmlbinding; - -/** - * The general utility for io.openliberty.xmlbinding.tools projects. - */ -public class JaxbToolsUtil { - /** - * get the localized message provided in the message files in the io.openliberty.xmlbinding.tools. - * - * @param msgKey - * @return - */ - public static String formatMessage(String msgKey) { - String msg; - try { - msg = JaxbConstants.messages.getString(msgKey); - } catch (Exception ex) { - // no FFDC required - return msgKey; - } - - return msg; - } -} diff --git a/dev/io.openliberty.jakarta.xmlBinding.4.0/src/jakarta/xml/bind/ContextFinder.java b/dev/io.openliberty.jakarta.xmlBinding.4.0/src/jakarta/xml/bind/ContextFinder.java deleted file mode 100644 index 7fc5537a9e42..000000000000 --- a/dev/io.openliberty.jakarta.xmlBinding.4.0/src/jakarta/xml/bind/ContextFinder.java +++ /dev/null @@ -1,550 +0,0 @@ -/* - * Copyright (c) 2003, 2022 Oracle and/or its affiliates. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Distribution License v. 1.0, which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -package jakarta.xml.bind; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import java.util.Iterator; -import java.util.Map; -import java.util.Properties; -import java.util.logging.ConsoleHandler; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.ibm.websphere.ras.Tr; -import com.ibm.websphere.ras.TraceComponent; -import com.ibm.websphere.ras.annotation.Trivial; -import com.ibm.ws.ffdc.annotation.FFDCIgnore; - -import io.openliberty.jakarta.xmlbinding.JaxbConstants; -import io.openliberty.jakarta.xmlbinding.JaxbToolsUtil; - -/** - * This class is package private and therefore is not exposed as part of the - * Jakarta XML Binding API. - * - * This code is designed to implement the XML Binding spec pluggability feature - * - * @author - * @see JAXBContext - */ -class ContextFinder { - - - // Liberty Change Start - private static final TraceComponent tc = Tr.register(ContextFinder.class); - // Liberty Change End - - private static final Logger logger; - - /** - * When JAXB is in J2SE, rt.jar has to have a JAXB implementation. - * However, rt.jar cannot have META-INF/services/jakarta.xml.bind.JAXBContext - * because if it has, it will take precedence over any file that applications have - * in their jar files. - * - *

- * When the user bundles his own Jakarta XML Binding implementation, we'd like to use it, and we - * want the platform default to be used only when there's no other Jakarta XML Binding provider. - * - *

- * For this reason, we have to hard-code the class name into the API. - */ - //XXX: should we define and rely on "default" in jakarta? - static final String DEFAULT_FACTORY_CLASS = "org.glassfish.jaxb.runtime.v2.ContextFactory"; - - static { - logger = Logger.getLogger("jakarta.xml.bind"); - try { - if (AccessController.doPrivileged(new GetPropertyAction("jaxb.debug")) != null) { - // disconnect the logger from a bigger framework (if any) - // and take the matters into our own hands - logger.setUseParentHandlers(false); - logger.setLevel(Level.ALL); - ConsoleHandler handler = new ConsoleHandler(); - handler.setLevel(Level.ALL); - logger.addHandler(handler); - } else { - // don't change the setting of this logger - // to honor what other frameworks - // have done on configurations. - } - } catch (Throwable t) { - // just to be extra safe. in particular System.getProperty may throw - // SecurityException. - } - } - - private static ServiceLoaderUtil.ExceptionHandler EXCEPTION_HANDLER = - new ServiceLoaderUtil.ExceptionHandler() { - @Override - public JAXBException createException(Throwable throwable, String message) { - return new JAXBException(message, throwable); - } - }; - - /** - * If the {@link InvocationTargetException} wraps an exception that shouldn't be wrapped, - * throw the wrapped exception. Otherwise returns exception to be wrapped for further processing. - */ - private static Throwable handleInvocationTargetException(InvocationTargetException x) throws JAXBException { - Throwable t = x.getTargetException(); - if (t != null) { - if (t instanceof JAXBException) - // one of our exceptions, just re-throw - throw (JAXBException) t; - if (t instanceof RuntimeException) - // avoid wrapping exceptions unnecessarily - throw (RuntimeException) t; - if (t instanceof Error) - throw (Error) t; - return t; - } - return x; - } - - - /** - * Determine if two types (JAXBContext in this case) will generate a ClassCastException. - * - * For example, (targetType)originalType - * - * @param originalType - * The Class object of the type being cast - * @param targetType - * The Class object of the type that is being cast to - * @return JAXBException to be thrown. - */ - private static JAXBException handleClassCastException(Class originalType, Class targetType) { - final URL targetTypeURL = which(targetType); - - return new JAXBException(Messages.format(Messages.ILLEGAL_CAST, - // we don't care where the impl class is, we want to know where JAXBContext lives in the impl - // class' ClassLoader - getClassClassLoader(originalType).getResource("jakarta/xml/bind/JAXBContext.class"), - targetTypeURL)); - } - - /** - * Create an instance of a class using the specified ClassLoader - */ - static JAXBContext newInstance(String contextPath, - Class[] contextPathClasses, - String className, - ClassLoader classLoader, - Map properties) throws JAXBException { - - try { - Class spFactory = ServiceLoaderUtil.safeLoadClass(className, DEFAULT_FACTORY_CLASS, classLoader); - return newInstance(contextPath, contextPathClasses, spFactory, classLoader, properties); - } catch (ClassNotFoundException x) { - throw new JAXBException(Messages.format(Messages.DEFAULT_PROVIDER_NOT_FOUND), x); - } catch (RuntimeException | JAXBException x) { - // avoid wrapping RuntimeException to JAXBException, - // because it indicates a bug in this code. - // JAXBException re-thrown as is - throw x; - } catch (Exception x) { - // can't catch JAXBException because the method is hidden behind - // reflection. Root element collisions detected in the call to - // createContext() are reported as JAXBExceptions - just re-throw it - // some other type of exception - just wrap it - throw new JAXBException(Messages.format(Messages.COULD_NOT_INSTANTIATE, className, x), x); - } - } - - static JAXBContext newInstance(String contextPath, - Class[] contextPathClasses, - Class spFactory, - ClassLoader classLoader, - Map properties) throws JAXBException { - - try { - - ModuleUtil.delegateAddOpensToImplModule(contextPathClasses, spFactory); - - /* - * jakarta.xml.bind.context.factory points to a class which has a - * static method called 'createContext' that - * returns a jakarta.xml.bind.JAXBContext. - */ - - Object context = null; - - // first check the method that takes Map as the third parameter. - // this is added in 2.0. - try { - Method m = spFactory.getMethod("createContext", String.class, ClassLoader.class, Map.class); - // any failure in invoking this method would be considered fatal - Object obj = instantiateProviderIfNecessary(spFactory); - context = m.invoke(obj, contextPath, classLoader, properties); - } catch (NoSuchMethodException ignored) { - // it's not an error for the provider not to have this method. - } - - if (context == null) { - // try the old method that doesn't take properties. compatible with 1.0. - // it is an error for an implementation not to have both forms of the createContext method. - Method m = spFactory.getMethod("createContext", String.class, ClassLoader.class); - Object obj = instantiateProviderIfNecessary(spFactory); - // any failure in invoking this method would be considered fatal - context = m.invoke(obj, contextPath, classLoader); - } - - if (!(context instanceof JAXBContext)) { - // the cast would fail, so generate an exception with a nice message - throw handleClassCastException(context.getClass(), JAXBContext.class); - } - - return (JAXBContext) context; - } catch (InvocationTargetException x) { - // throw if it is exception not to be wrapped - // otherwise, wrap with a JAXBException - Throwable e = handleInvocationTargetException(x); - throw new JAXBException(Messages.format(Messages.COULD_NOT_INSTANTIATE, spFactory, e), e); - - } catch (Exception x) { - // can't catch JAXBException because the method is hidden behind - // reflection. Root element collisions detected in the call to - // createContext() are reported as JAXBExceptions - just re-throw it - // some other type of exception - just wrap it - throw new JAXBException(Messages.format(Messages.COULD_NOT_INSTANTIATE, spFactory, x), x); - } - } - - private static Object instantiateProviderIfNecessary(final Class implClass) throws JAXBException { - try { - if (JAXBContextFactory.class.isAssignableFrom(implClass)) { - return AccessController.doPrivileged(new PrivilegedExceptionAction() { - @Override - public Object run() throws Exception { - return implClass.getConstructor().newInstance(); - } - }); - } - return null; - } catch (PrivilegedActionException x) { - Throwable e = (x.getCause() == null) ? x : x.getCause(); - throw new JAXBException(Messages.format(Messages.COULD_NOT_INSTANTIATE, implClass, e), e); - } - } - - /** - * Create an instance of a class using the thread context ClassLoader - */ - private static JAXBContext newInstance(Class[] classes, Map properties, String className) throws JAXBException { - return newInstance(classes, properties, className, getContextClassLoader()); - } - - /** - * Create an instance of a class using passed in ClassLoader - */ - private static JAXBContext newInstance(Class[] classes, Map properties, String className, ClassLoader loader) throws JAXBException { - - Class spi; - try { - spi = ServiceLoaderUtil.safeLoadClass(className, DEFAULT_FACTORY_CLASS, loader); - } catch (ClassNotFoundException e) { - throw new JAXBException(Messages.format(Messages.DEFAULT_PROVIDER_NOT_FOUND), e); - } - - if (logger.isLoggable(Level.FINE)) { - // extra check to avoid costly which operation if not logged - logger.log(Level.FINE, "loaded {0} from {1}", new Object[]{className, which(spi)}); - } - - return newInstance(classes, properties, spi); - } - - 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); - } - return (JAXBContext) context; - - } catch (NoSuchMethodException | IllegalAccessException e) { - throw new JAXBException(e); - } catch (InvocationTargetException e) { - // throw if it is exception not to be wrapped - // otherwise, wrap with a JAXBException - Throwable x = handleInvocationTargetException(e); - - throw new JAXBException(x); - } - } - - static JAXBContext find(String factoryId, - String contextPath, - ClassLoader classLoader, - Map properties) throws JAXBException { - - if (contextPath == null || contextPath.isEmpty()) { - // no context is specified - throw new JAXBException(Messages.format(Messages.NO_PACKAGE_IN_CONTEXTPATH)); - } - - //ModuleUtil is mr-jar class, scans context path for jaxb classes on jdk9 and higher - Class[] contextPathClasses = ModuleUtil.getClassesFromContextPath(contextPath, classLoader); - - String factoryName = classNameFromSystemProperties(); - - // Liberty Change Start: Add Message log for warning if third-party impl is configured but not loaded - if (factoryName != null) { - try { - return newInstance(contextPath, contextPathClasses, factoryName, classLoader, properties); - } catch (JAXBException x) { - if(x.getMessage().contains(Messages.format(Messages.DEFAULT_PROVIDER_NOT_FOUND))) { - // Only log the message about the system property being set but no implementation being found - // as we want the RI to be used as a backup. - Tr.warning(tc, JaxbToolsUtil.formatMessage(JaxbConstants.WARNING_SYSTEM_PROPERTY_JAXBCONTEXTFACTORY), factoryName, x.getMessage()); - } else { - throw x; - } - } - } - - if (properties != null && !properties.isEmpty()) { - Object factory = properties.get(factoryId); - if (factory != null) { - if (factory instanceof String) { - factoryName = (String) factory; - - if (factoryName != null) { - try { - return newInstance(contextPath, contextPathClasses, factoryName, classLoader, properties); - } catch (JAXBException x) { - if(x.getMessage().contains(Messages.format(Messages.DEFAULT_PROVIDER_NOT_FOUND))) { - // Only log the message about the system property being set but no implementation being found - // as we want the RI to be used as a backup. - Tr.warning(tc, JaxbToolsUtil.formatMessage(JaxbConstants.WARNING_PROPERTY_MAP_JAXBCONTEXTFACTORY), factoryName, x.getMessage()); - } else { - throw x; - } - } - } - } else { - throw new JAXBException(Messages.format(Messages.ILLEGAL_CAST, factory.getClass().getName(), "String")); - } - } - } - // Liberty Change End - - - JAXBContextFactory obj = ServiceLoaderUtil.firstByServiceLoader( - JAXBContextFactory.class, logger, EXCEPTION_HANDLER); - - if (obj != null) { - ModuleUtil.delegateAddOpensToImplModule(contextPathClasses, obj.getClass()); - return obj.createContext(contextPath, classLoader, properties); - } - - Iterable> ctxFactories = ServiceLoaderUtil.lookupsUsingOSGiServiceLoader( - JAXBContext.JAXB_CONTEXT_FACTORY, logger); - - if (ctxFactories != null) { - for (Class ctxFactory : ctxFactories) { - try { - return newInstance(contextPath, contextPathClasses, ctxFactory, classLoader, properties); - } catch (Throwable t) { - logger.log(Level.FINE, t, () -> "Error instantiating provivder " + ctxFactory); - } - } - } - - // else no provider found - logger.fine("Trying to create the platform default provider"); - return newInstance(contextPath, contextPathClasses, DEFAULT_FACTORY_CLASS, classLoader, properties); - } - - static JAXBContext find(Class[] classes, Map properties) throws JAXBException { - String factoryClassName = classNameFromSystemProperties(); - // Liberty Change Start: Add Message log for warning if third-party impl is configured but not loaded - if (factoryClassName != null) { - try { - return newInstance(classes, properties, factoryClassName); - } catch (JAXBException x) { - if(x.getMessage().contains(Messages.format(Messages.DEFAULT_PROVIDER_NOT_FOUND))) { - // Only log the message about the system property being set but no implementation being found - // as we want the RI to be used as a backup. - Tr.warning(tc, JaxbConstants.WARNING_SYSTEM_PROPERTY_JAXBCONTEXTFACTORY, factoryClassName, x.getMessage()); - } else { - throw x; - } - } - } - - if (properties != null && !properties.isEmpty()) { - Object ctxFactory = properties.get(JAXBContext.JAXB_CONTEXT_FACTORY); - if (ctxFactory != null) { - if (ctxFactory instanceof String) { - factoryClassName = (String) ctxFactory; - if (factoryClassName != null) { - try { - return newInstance(classes, properties, factoryClassName); - } catch (JAXBException x) { - if(x.getMessage().contains(Messages.format(Messages.DEFAULT_PROVIDER_NOT_FOUND))) { - // Only log the message about the system property being set but no implementation being found - // as we want the RI to be used as a backup. - Tr.warning(tc, JaxbToolsUtil.formatMessage(JaxbConstants.WARNING_PROPERTY_MAP_JAXBCONTEXTFACTORY), factoryClassName, x.getMessage()); - - } else { - throw x; - } - } - } - } else { - throw new JAXBException(Messages.format(Messages.ILLEGAL_CAST, ctxFactory.getClass().getName(), "String")); - } - } - } - // Liberty Change End: Add Message log for warning if third-party impl is configured but not loaded - - - JAXBContextFactory factory = - ServiceLoaderUtil.firstByServiceLoader(JAXBContextFactory.class, logger, EXCEPTION_HANDLER); - - if (factory != null) { - ModuleUtil.delegateAddOpensToImplModule(classes, factory.getClass()); - return factory.createContext(classes, properties); - } - - logger.fine("Trying to create the platform default provider"); - Class ctxFactoryClass = - ServiceLoaderUtil.lookupUsingOSGiServiceLoader(JAXBContext.JAXB_CONTEXT_FACTORY, logger); - - if (ctxFactoryClass != null) { - return newInstance(classes, properties, ctxFactoryClass); - } - - // else no provider found - logger.fine("Trying to create the platform default provider"); - return newInstance(classes, properties, DEFAULT_FACTORY_CLASS); - } - - private static String classNameFromSystemProperties() throws JAXBException { - - String factoryClassName = getSystemProperty(JAXBContext.JAXB_CONTEXT_FACTORY); - if (factoryClassName != null) { - return factoryClassName; - } - - return null; - } - - private static String getSystemProperty(String property) { - logger.log(Level.FINE, "Checking system property {0}", property); - String value = AccessController.doPrivileged(new GetPropertyAction(property)); - if (value != null) { - logger.log(Level.FINE, " found {0}", value); - } else { - logger.log(Level.FINE, " not found"); - } - return value; - } - - /** - * Search the given ClassLoader for an instance of the specified class and - * return a string representation of the URL that points to the resource. - * - * @param clazz - * The class to search for - * @param loader - * The ClassLoader to search. If this parameter is null, then the - * system class loader will be searched - * @return - * the URL for the class or null if it wasn't found - */ - static URL which(Class clazz, ClassLoader loader) { - - String classnameAsResource = clazz.getName().replace('.', '/') + ".class"; - - if (loader == null) { - loader = getSystemClassLoader(); - } - - return loader.getResource(classnameAsResource); - } - - /** - * Get the URL for the Class from it's ClassLoader. - * - * Convenience method for {@link #which(Class, ClassLoader)}. - * - * Equivalent to calling: which(clazz, clazz.getClassLoader()) - * - * @param clazz - * The class to search for - * @return - * the URL for the class or null if it wasn't found - */ - static URL which(Class clazz) { - return which(clazz, getClassClassLoader(clazz)); - } - - private static ClassLoader getContextClassLoader() { - if (System.getSecurityManager() == null) { - return Thread.currentThread().getContextClassLoader(); - } else { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public ClassLoader run() { - return Thread.currentThread().getContextClassLoader(); - } - }); - } - } - - private static ClassLoader getClassClassLoader(final Class c) { - if (System.getSecurityManager() == null) { - return c.getClassLoader(); - } else { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public ClassLoader run() { - return c.getClassLoader(); - } - }); - } - } - - private static ClassLoader getSystemClassLoader() { - if (System.getSecurityManager() == null) { - return ClassLoader.getSystemClassLoader(); - } else { - return AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public ClassLoader run() { - return ClassLoader.getSystemClassLoader(); - } - }); - } - } - -} diff --git a/dev/io.openliberty.xmlBinding.4.0.internal_fat/build.gradle b/dev/io.openliberty.xmlBinding.4.0.internal_fat/build.gradle index a1925d19b1b6..0d9fe7d3f0e5 100644 --- a/dev/io.openliberty.xmlBinding.4.0.internal_fat/build.gradle +++ b/dev/io.openliberty.xmlBinding.4.0.internal_fat/build.gradle @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2018 IBM Corporation and others. + * Copyright (c) 2022 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -16,7 +16,7 @@ configurations { dependencies { appLibs 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.+' appLibs 'org.eclipse.persistence:org.eclipse.persistence.asm:9.3.+' - appLibs 'org.eclipse.persistence:org.eclipse.persistence.core:4.0.+' + appLibs 'io.openliberty.org.eclipse.persistence:org.eclipse.persistence.core:4.0+' appLibs 'org.eclipse.persistence:org.eclipse.persistence.moxy:4.0.+' } diff --git a/dev/io.openliberty.xmlBinding.4.0.internal_fat/publish/servers/jaxb_fat/schemaEE10.xml b/dev/io.openliberty.xmlBinding.4.0.internal_fat/publish/servers/jaxb_fat/schemaEE10.xml index 7b29d287ebba..8a53aa40bb93 100644 --- a/dev/io.openliberty.xmlBinding.4.0.internal_fat/publish/servers/jaxb_fat/schemaEE10.xml +++ b/dev/io.openliberty.xmlBinding.4.0.internal_fat/publish/servers/jaxb_fat/schemaEE10.xml @@ -1,5 +1,5 @@ - + diff --git a/dev/io.openliberty.xmlBinding.4.0.internal_fat/publish/servers/jaxb_thirdpartyimpl_fat/schemaEE10.xml b/dev/io.openliberty.xmlBinding.4.0.internal_fat/publish/servers/jaxb_thirdpartyimpl_fat/schemaEE10.xml index a41c83c07700..7b97076188c8 100644 --- a/dev/io.openliberty.xmlBinding.4.0.internal_fat/publish/servers/jaxb_thirdpartyimpl_fat/schemaEE10.xml +++ b/dev/io.openliberty.xmlBinding.4.0.internal_fat/publish/servers/jaxb_thirdpartyimpl_fat/schemaEE10.xml @@ -1,5 +1,5 @@ - + diff --git a/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/dataobjects/ObjectFactory.java b/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/dataobjects/ObjectFactory.java index ecb6f290399c..ec052a5cf13f 100644 --- a/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/dataobjects/ObjectFactory.java +++ b/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/dataobjects/ObjectFactory.java @@ -20,10 +20,10 @@ @XmlRegistry public class ObjectFactory { - private final static QName _Image_QName = new QName("https://jaxb.web.dataobjects/", "Image"); - private final static QName _Items_QName = new QName("https://jaxb.web.dataobjects/", "Items"); - private final static QName _PurchaseOrderType_QName = new QName("https://jaxb.web.dataobjects/", "PurchaseOrderType"); - private final static QName _ShippingAddress_QName = new QName("https://jaxb.web.dataobjects/", "ShippingAddress"); + private final static QName _Image_QName = new QName("http://jaxb.web.dataobjects/", "Image"); + private final static QName _Items_QName = new QName("http://jaxb.web.dataobjects/", "Items"); + private final static QName _PurchaseOrderType_QName = new QName("http://jaxb.web.dataobjects/", "PurchaseOrderType"); + private final static QName _ShippingAddress_QName = new QName("http://jaxb.web.dataobjects/", "ShippingAddress"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: mtomservice @@ -69,17 +69,17 @@ public ShippingAddress createShippingAddress() { * Create an instance of {@link JAXBElement }{@code <}{@link GetAttachmentResponse }{@code >}} * */ - @XmlElementDecl(namespace = "https://jaxb.web.dataobjects/", name = "Image") + @XmlElementDecl(namespace = "http://jaxb.web.dataobjects/", name = "Image") public JAXBElement createGetAttachmentResponse(Image value) { return new JAXBElement(_Image_QName, Image.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link SendAttachment }{@code >}} - * private final static QName _ShippingAddress_QName = new QName("https://jaxb.web.dataobjects/", "ShippingAddress"); + * private final static QName _ShippingAddress_QName = new QName("http://jaxb.web.dataobjects/", "ShippingAddress"); * */ - @XmlElementDecl(namespace = "https://jaxb.web.dataobjects/", name = "Items") + @XmlElementDecl(namespace = "http://jaxb.web.dataobjects/", name = "Items") public JAXBElement createItems(Items value) { return new JAXBElement(_Items_QName, Items.class, null, value); } @@ -87,10 +87,10 @@ public JAXBElement createItems(Items value) { /** * Create an instance of {@link JAXBElement }{@code <}{@link SendAttachmentResponse }{@code >}} * - * private final static QName _PurchaseOrderType_QName = new QName("https://jaxb.web.dataobjects/", "PurchaseOrderType"); + * private final static QName _PurchaseOrderType_QName = new QName("http://jaxb.web.dataobjects/", "PurchaseOrderType"); * */ - @XmlElementDecl(namespace = "https://jaxb.web.dataobjects/", name = "PurchaseOrderType") + @XmlElementDecl(namespace = "http://jaxb.web.dataobjects/", name = "PurchaseOrderType") public JAXBElement createPurchaseOrderType(PurchaseOrderType value) { return new JAXBElement(_PurchaseOrderType_QName, PurchaseOrderType.class, null, value); } @@ -99,7 +99,7 @@ public JAXBElement createPurchaseOrderType(PurchaseOrderType * Create an instance of {@link JAXBElement }{@code <}{@link GetAttachment }{@code >}} * */ - @XmlElementDecl(namespace = "https://jaxb.web.dataobjects/", name = "ShippingAddress") + @XmlElementDecl(namespace = "http://jaxb.web.dataobjects/", name = "ShippingAddress") public JAXBElement createShippingAddress(ShippingAddress value) { return new JAXBElement(_ShippingAddress_QName, ShippingAddress.class, null, value); } diff --git a/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/dataobjects/package-info.java b/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/dataobjects/package-info.java index 4c81775fae20..cba1b0ed9336 100755 --- a/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/dataobjects/package-info.java +++ b/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/dataobjects/package-info.java @@ -13,7 +13,7 @@ @XmlJavaTypeAdapter(NormalizedStringAdapter.class), @XmlJavaTypeAdapter(HexBinaryAdapter.class) }) @XmlSchema( - namespace = "https://jaxb.web.dataobjects/", + namespace = "http://jaxb.web.dataobjects/", elementFormDefault = XmlNsForm.QUALIFIED, xmlns = { @XmlNs(prefix = "ns0", namespaceURI = "http://jaxb.web.dataobjects/") diff --git a/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/utils/JAXBContextUtils.java b/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/utils/JAXBContextUtils.java index 1c4eb819689f..aae202694b77 100644 --- a/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/utils/JAXBContextUtils.java +++ b/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/utils/JAXBContextUtils.java @@ -18,7 +18,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; -import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,6 +47,7 @@ public class JAXBContextUtils { public static Items ITEMS = null; public static ShippingAddress SHIPPING_ADDRESS = null; public static PurchaseOrderType PURCHASE_ORDER_TYPE = null; + private static XMLGregorianCalendar shipDate = null; public static JAXBContext setupJAXBContext() throws Exception { return JAXBContext.newInstance("jaxb.web.dataobjects"); @@ -130,7 +130,7 @@ public static PurchaseOrderType getPurchaseOrderType() { pot.setBillTo(getShippingAddress()); pot.setItems(getItems()); pot.setComment("New Order"); - pot.setOrderDate(createDate()); + pot.setOrderDate(getDate()); pot.setShipTo(getShippingAddress()); PURCHASE_ORDER_TYPE = pot; return PURCHASE_ORDER_TYPE; @@ -150,7 +150,7 @@ public static List createItemsList() { item.setPrice(price); item.setQuantity(15); - item.setShipDate(createDate()); + item.setShipDate(getDate()); Item item2 = new Item(); @@ -159,7 +159,7 @@ public static List createItemsList() { BigDecimal price2 = new BigDecimal(135165.999999999898); item2.setPrice(price2); item2.setQuantity(1251); - item2.setShipDate(createDate()); + item2.setShipDate(getDate()); List itemList = new ArrayList(); itemList.add(item); @@ -187,29 +187,28 @@ public static ShippingAddress getShippingAddress() { } } - public static XMLGregorianCalendar createDate() { + public static XMLGregorianCalendar getDate() { + if (shipDate == null) { - String pattern = "yyyy-MM-dd"; - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); + String pattern = "yyyy-MM-dd"; + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); - Date date; - XMLGregorianCalendar shipDate = null; - try { - date = simpleDateFormat.parse("2018-09-09"); + Date date; + XMLGregorianCalendar sd = null; + try { + date = simpleDateFormat.parse("2018-09-09"); - // Gregorian Calendar object creation - GregorianCalendar gc = new GregorianCalendar(); - - // giving current date and time to gc - gc.setTime(date); + sd = DatatypeFactory.newInstance().newXMLGregorianCalendar(new SimpleDateFormat("yyyy-MM-dd").format(date)); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + shipDate = sd; - shipDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(gc); - } catch (Exception e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); + return sd; + } else { + return shipDate; } - - return shipDate; } /** diff --git a/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/utils/JAXBXMLSchemaConstants.java b/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/utils/JAXBXMLSchemaConstants.java index db49cb2a5d56..f6e53ea5b6c8 100644 --- a/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/utils/JAXBXMLSchemaConstants.java +++ b/dev/io.openliberty.xmlBinding.4.0.internal_fat/test-applications/jaxbApp/src/jaxb/web/utils/JAXBXMLSchemaConstants.java @@ -15,42 +15,42 @@ */ public class JAXBXMLSchemaConstants { - public static final String EXPECTED_PURCHASEORDERTYPE_MARSHALLED_RESULT = "\n" - + " \n" - + " Test Name\n" - + " 505 E Maple\n" - + " Austin\n" - + " Texas\n" - + " 77777\n" - + " \n" - + " \n" - + " Test Name\n" - + " 505 E Maple\n" - + " Austin\n" - + " Texas\n" - + " 77777\n" - + " \n" - + " New Order\n" - + " \n" - + " \n" - + " Test Product\n" - + " 15\n" - + " 59872326\n" - + " I'm a test product\n" - + " 2018-09-09-05:00\n" - + " \n" - + " \n" - + " Test Product 2\n" - + " 1251\n" - + " 135165.999999999883584678173065185546875\n" - + " I'm another test product\n" - + " 2018-09-09-05:00\n" - + " \n" - + " Test Product Test Product 2\n" - + " \n" - + ""; + public static final String EXPECTED_PURCHASEORDERTYPE_MARSHALLED_RESULT = "\n" + + " \n" + + " Test Name\n" + + " 505 E Maple\n" + + " Austin\n" + + " Texas\n" + + " 77777\n" + + " \n" + + " \n" + + " Test Name\n" + + " 505 E Maple\n" + + " Austin\n" + + " Texas\n" + + " 77777\n" + + " \n" + + " New Order\n" + + " \n" + + " \n" + + " Test Product\n" + + " 15\n" + + " 59872326\n" + + " I'm a test product\n" + + " 2018-09-09\n" + + " \n" + + " \n" + + " Test Product 2\n" + + " 1251\n" + + " 135165.999999999883584678173065185546875\n" + + " I'm another test product\n" + + " 2018-09-09\n" + + " \n" + + " Test Product Test Product 2\n" + + " \n" + + ""; - public static final String EXPECTED_ITEM_MARSHALLED_RESULT = "\n" + public static final String EXPECTED_ITEM_MARSHALLED_RESULT = "\n" + " \n" + " Test Product\n" + " 15\n" @@ -67,7 +67,7 @@ public class JAXBXMLSchemaConstants { + " \n" + ""; - public static final String EXPECTED_SHIPPINGADDRESS_MARSHALLED_RESULT = "\n" + public static final String EXPECTED_SHIPPINGADDRESS_MARSHALLED_RESULT = "\n" + " Test Name\n" + " 505 E Maple\n" + " Austin\n" @@ -75,13 +75,12 @@ public class JAXBXMLSchemaConstants { + " 77777\n" + ""; - public final static String EXPECTED_MOXY_SCHEMA_VALUE = "\n" - + "\n" + public final static String EXPECTED_MOXY_SCHEMA_VALUE = "\n" + " \n" + " \n" + " \n" + " \n" - + " \n" + + " \n" + " \n" + " \n" + " \n" @@ -108,10 +107,10 @@ public class JAXBXMLSchemaConstants { + " \n" + " \n" + " \n" - + " \n" - + " \n" + + " \n" + + " \n" + " \n" - + " \n" + + " \n" + " \n" + " \n" + " \n" @@ -125,113 +124,102 @@ public class JAXBXMLSchemaConstants { + " \n" + " \n" + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + ""; - public final static String EXPECTED_RI_SCHEMA_VALUE = "\n" - + "\n" - + "\n" - + " \n" - + " \n" - + " \n" - + "\n" - + " \n" - + "\n" - + " \n" - + "\n" - + " \n" - + "\n" - + " \n" - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + "\n"; + public final static String EXPECTED_RI_SCHEMA_VALUE = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; - public static final String EXPECTED_RI_PURCHASEORDERTYPE_MARSHALLED_RESULT = "\n" - + " \n" - + " Test Name\n" - + " 505 E Maple\n" - + " Austin\n" - + " Texas\n" - + " 77777\n" - + " \n" - + " \n" - + " Test Name\n" - + " 505 E Maple\n" - + " Austin\n" - + " Texas\n" - + " 77777\n" - + " \n" - + " New Order\n" - + " \n" - + " \n" - + " Test Product\n" - + " 15\n" - + " 59872326\n" - + " I'm a test product\n" - + " 2018-09-09-05:00\n" - + " \n" - + " \n" - + " Test Product 2\n" - + " 1251\n" - + " 135165.999999999883584678173065185546875\n" - + " I'm another test product\n" - + " 2018-09-09-05:00\n" - + " \n" - + " Test Product Test Product 2\n" - + " \n" + public static final String EXPECTED_RI_PURCHASEORDERTYPE_MARSHALLED_RESULT = "\n" + + " \n" + + " Test Name\n" + + " 505 E Maple\n" + + " Austin\n" + + " Texas\n" + + " 77777\n" + + " \n" + + " \n" + + " Test Name\n" + + " 505 E Maple\n" + + " Austin\n" + + " Texas\n" + + " 77777\n" + + " \n" + + " New Order\n" + + " \n" + + " \n" + + " Test Product\n" + + " 15\n" + + " 59872326\n" + + " I'm a test product\n" + + " 2018-09-09\n" + + " \n" + + " \n" + + " Test Product 2\n" + + " 1251\n" + + " 135165.999999999883584678173065185546875\n" + + " I'm another test product\n" + + " 2018-09-09\n" + + " \n" + + " Test Product Test Product 2\n" + + " \n" + ""; }