Merge
diff --git a/src/java.activation/share/classes/javax/activation/CommandInfo.java b/src/java.activation/share/classes/javax/activation/CommandInfo.java
index b8dfd8b..b6312e0 100644
--- a/src/java.activation/share/classes/javax/activation/CommandInfo.java
+++ b/src/java.activation/share/classes/javax/activation/CommandInfo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,10 @@
 package javax.activation;
 
 import java.io.*;
-import java.beans.Beans;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 
 /**
  * The CommandInfo class is used by CommandMap implementations to
@@ -84,8 +87,15 @@
     /**
      * Return the instantiated JavaBean component.
      * <p>
-     * Begin by instantiating the component with
-     * {@code Beans.instantiate()}.
+     * If {@code java.beans.Beans} is visible then it's
+     * {@code java.beans.Beans#instantiate} method is invoked to instantiate
+     * the component as a JavaBeans component.
+     * When {@code java.beans.Beans} is not visible (when {@code java.desktop}
+     * module is not  readable or when the runtime image does not contain the
+     * {@code java.desktop} module) then the command's class is loaded and
+     * instantiated with its public no-args constructor.
+     * <p>
+     * The component class needs to be public.
      * <p>
      * If the bean implements the {@code javax.activation.CommandObject}
      * interface, call its {@code setCommandContext} method.
@@ -102,7 +112,7 @@
      * this method will check if it implements the
      * java.io.Externalizable interface. If it does, the bean's
      * readExternal method will be called if an InputStream
-     * can be acquired from the DataHandler.
+     * can be acquired from the DataHandler.<p>
      *
      * @param dh        The DataHandler that describes the data to be
      *                  passed to the command.
@@ -116,7 +126,7 @@
         Object new_bean = null;
 
         // try to instantiate the bean
-        new_bean = java.beans.Beans.instantiate(loader, className);
+        new_bean = Beans.instantiate(loader, className);
 
         // if we got one and it is a CommandObject
         if (new_bean != null) {
@@ -135,4 +145,86 @@
 
         return new_bean;
     }
+
+    /**
+     * Helper class to invoke Beans.instantiate reflectively or the equivalent
+     * with core reflection when module java.desktop is not readable.
+     */
+    private static final class Beans {
+        static final Method instantiateMethod;
+
+        static {
+            Method m;
+            try {
+                Class<?> c = Class.forName("java.beans.Beans");
+                m = c.getDeclaredMethod("instantiate", ClassLoader.class, String.class);
+            } catch (ClassNotFoundException e) {
+                m = null;
+            } catch (NoSuchMethodException e) {
+                m = null;
+            }
+            instantiateMethod = m;
+        }
+
+        /**
+         * Equivalent to invoking java.beans.Beans.instantiate(loader, cn)
+         */
+        static Object instantiate(ClassLoader loader, String cn)
+                throws IOException, ClassNotFoundException {
+
+            Exception exception;
+
+            if (instantiateMethod != null) {
+
+                // invoke Beans.instantiate
+                try {
+                    return instantiateMethod.invoke(null, loader, cn);
+                } catch (InvocationTargetException e) {
+                    exception = e;
+                } catch (IllegalAccessException e) {
+                    exception = e;
+                }
+
+            } else {
+
+                SecurityManager security = System.getSecurityManager();
+                if (security != null) {
+                    // if it's ok with the SecurityManager, it's ok with me.
+                    String cname = cn.replace('/', '.');
+                    if (cname.startsWith("[")) {
+                        int b = cname.lastIndexOf('[') + 2;
+                        if (b > 1 && b < cname.length()) {
+                            cname = cname.substring(b);
+                        }
+                    }
+                    int i = cname.lastIndexOf('.');
+                    if (i != -1) {
+                        security.checkPackageAccess(cname.substring(0, i));
+                    }
+                }
+
+                // Beans.instantiate specified to use SCL when loader is null
+                if (loader == null) {
+                    loader = (ClassLoader)
+                        AccessController.doPrivileged(new PrivilegedAction() {
+                            public Object run() {
+                                ClassLoader cl = null;
+                                try {
+                                    cl = ClassLoader.getSystemClassLoader();
+                                } catch (SecurityException ex) { }
+                                return cl;
+                            }
+                        });
+                }
+                Class<?> beanClass = Class.forName(cn, false, loader);
+                try {
+                    return beanClass.getDeclaredConstructor().newInstance();
+                } catch (Exception ex) {
+                    throw new ClassNotFoundException(beanClass + ": " + ex, ex);
+                }
+
+            }
+            return null;
+        }
+    }
 }
diff --git a/src/java.activation/share/classes/module-info.java b/src/java.activation/share/classes/module-info.java
index dca632e..1ba4eb1 100644
--- a/src/java.activation/share/classes/module-info.java
+++ b/src/java.activation/share/classes/module-info.java
@@ -28,8 +28,6 @@
  */
 module java.activation {
     requires public java.datatransfer;
-    // dependence on java.beans.Beans to be eliminated
-    requires java.desktop;
     requires java.logging;
 
     exports javax.activation;
diff --git a/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/util/Which.java b/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/util/Which.java
index 4e52d9c..bb9eeb5 100644
--- a/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/util/Which.java
+++ b/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/util/Which.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
 
     /**
      * Search the specified classloader for the given classname.
-     *
+     * Then give the return value.
      * @param classname the fully qualified name of the class to search for
      * @param loader the classloader to search
      * @return the source location of the resource, or null if it wasn't found
diff --git a/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/util/XmlFactory.java b/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/util/XmlFactory.java
index 2cd48aa..c2cbe15 100644
--- a/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/util/XmlFactory.java
+++ b/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/v2/util/XmlFactory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
diff --git a/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java b/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java
index a2d9bce..4b4f6e5 100644
--- a/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java
+++ b/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java
@@ -450,8 +450,8 @@
      *      in an empty map.
      *
      * @return a new instance of a {@code JAXBContext}
-     * @throws JAXBException
-     *      if an error was encountered while creating the {@code JAXBContext} such as
+     * @throws JAXBException if an error was encountered while creating the
+     *                       {@code JAXBContext} such as
      * <ol>
      *   <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li>
      *   <li>an ambiguity among global elements contained in the contextPath</li>
diff --git a/src/java.xml.bind/share/classes/javax/xml/bind/attachment/package.html b/src/java.xml.bind/share/classes/javax/xml/bind/attachment/package.html
index c452cb9..499643d 100644
--- a/src/java.xml.bind/share/classes/javax/xml/bind/attachment/package.html
+++ b/src/java.xml.bind/share/classes/javax/xml/bind/attachment/package.html
@@ -1,6 +1,6 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 <!--
- Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
         <h2>Package Specification</h2>
 
         <ul>
-            <li><a href="http://java.sun.com/xml/downloads/jaxb.html">JAXB 
+            <li><a href="https://jaxb.java.net/">JAXB
                 Specification</a>
         </ul>
 
@@ -61,7 +61,7 @@
         </ul>
 
         <!-- Put @see and @since tags down here. -->
-        @since 1.6, JAXB 2.0
+        @since JAXB 2.0
     </body>
 </html>
 
diff --git a/src/java.xml.bind/share/classes/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java b/src/java.xml.bind/share/classes/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java
index cef1cf6..78f5232 100644
--- a/src/java.xml.bind/share/classes/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java
+++ b/src/java.xml.bind/share/classes/javax/xml/bind/helpers/AbstractUnmarshallerImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,9 +47,7 @@
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stream.StreamSource;
 import javax.xml.validation.Schema;
-import java.io.File;
-import java.io.Reader;
-import java.net.MalformedURLException;
+import java.io.*;
 import java.net.URL;
 
 /**
@@ -178,16 +176,8 @@
         }
 
         try {
-            // copied from JAXP
-            String path = f.getAbsolutePath();
-            if (File.separatorChar != '/')
-                path = path.replace(File.separatorChar, '/');
-            if (!path.startsWith("/"))
-                path = "/" + path;
-            if (!path.endsWith("/") && f.isDirectory())
-                path = path + "/";
-            return unmarshal(new URL("file", "", path));
-        } catch( MalformedURLException e ) {
+            return unmarshal(new BufferedInputStream(new FileInputStream(f)));
+        } catch( FileNotFoundException e ) {
             throw new IllegalArgumentException(e.getMessage());
         }
     }
diff --git a/src/java.xml.bind/share/classes/javax/xml/bind/helpers/package.html b/src/java.xml.bind/share/classes/javax/xml/bind/helpers/package.html
index 059abed..0258896 100644
--- a/src/java.xml.bind/share/classes/javax/xml/bind/helpers/package.html
+++ b/src/java.xml.bind/share/classes/javax/xml/bind/helpers/package.html
@@ -1,6 +1,6 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 <!--
- Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
         <h2>Package Specification</h2>
 
         <ul>
-            <li><a href="http://java.sun.com/xml/downloads/jaxb.html">JAXB 
+            <li><a href="https://jaxb.java.net/">JAXB
                 Specification</a>
         </ul>
 
@@ -52,7 +52,7 @@
         For overviews, tutorials, examples, guides, and tool documentation, 
         please see:
         <ul>
-            <li>The <a href="http://java.sun.com/xml/jaxb/index.html">JAXB 
+            <li>The <a href="https://jaxb.java.net/">JAXB
             Website</a>
         </ul>
 
diff --git a/src/java.xml.bind/share/classes/javax/xml/bind/package.html b/src/java.xml.bind/share/classes/javax/xml/bind/package.html
index 862e8ef..a9af42b 100644
--- a/src/java.xml.bind/share/classes/javax/xml/bind/package.html
+++ b/src/java.xml.bind/share/classes/javax/xml/bind/package.html
@@ -1,6 +1,6 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 <!--
- Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@
         <h2>Package Specification</h2>
 
         <ul>
-            <li><a href="http://java.sun.com/xml/downloads/jaxb.html">JAXB 
+            <li><a href="https://jaxb.java.net/">JAXB
                 Specification</a>
         </ul>
 
@@ -53,7 +53,7 @@
         For overviews, tutorials, examples, guides, and tool documentation, 
         please see:
         <ul>
-            <li>The <a href="http://java.sun.com/xml/jaxb/index.html">JAXB 
+            <li>The <a href="https://jaxb.java.net/">JAXB
             Website</a>
         </ul>
 
diff --git a/src/java.xml.bind/share/classes/javax/xml/bind/util/package.html b/src/java.xml.bind/share/classes/javax/xml/bind/util/package.html
index 551f4f1..21569c6 100644
--- a/src/java.xml.bind/share/classes/javax/xml/bind/util/package.html
+++ b/src/java.xml.bind/share/classes/javax/xml/bind/util/package.html
@@ -1,6 +1,6 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 <!--
- Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,7 @@
         <h2>Package Specification</h2>
 
         <ul>
-            <li><a href="http://java.sun.com/xml/downloads/jaxb.html">JAXB 
+            <li><a href="https://jaxb.java.net/">JAXB
                 Specification</a>
         </ul>
 
@@ -47,7 +47,7 @@
         For overviews, tutorials, examples, guides, and tool documentation, 
         please see:
         <ul>
-            <li>The <a href="http://java.sun.com/xml/jaxb/index.html">JAXB 
+            <li>The <a href="https://jaxb.java.net/">JAXB
             Website</a>
         </ul>
 
diff --git a/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/encoding/XmlDataContentHandler.java b/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/encoding/XmlDataContentHandler.java
index 3b1d843..9617482 100644
--- a/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/encoding/XmlDataContentHandler.java
+++ b/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/encoding/XmlDataContentHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -139,8 +139,9 @@
     }
 
     private boolean isXml(ContentType ct) {
-        return ct.getSubType().equals("xml") &&
-                    (ct.getPrimaryType().equals("text") || ct.getPrimaryType().equals("application"));
+        final String primaryType = ct.getPrimaryType();
+        return ct.getSubType().equalsIgnoreCase("xml") &&
+                    (primaryType.equalsIgnoreCase("text") || primaryType.equalsIgnoreCase("application"));
     }
 
 }
diff --git a/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/model/RuntimeModeler.java b/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/model/RuntimeModeler.java
index 720caca..87d0857 100644
--- a/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/model/RuntimeModeler.java
+++ b/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/model/RuntimeModeler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,6 @@
 import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.rmi.RemoteException;
 import java.security.AccessController;
 import java.util.HashSet;
 import java.util.Map;
@@ -115,7 +114,7 @@
     public static final String SERVICE              = "Service";
     public static final String PORT                 = "Port";
     public static final Class HOLDER_CLASS = Holder.class;
-    public static final Class<RemoteException> REMOTE_EXCEPTION_CLASS = RemoteException.class;
+    public static final String REMOTE_EXCEPTION_CLASS = "java.rmi.RemoteException";
     public static final Class<RuntimeException> RUNTIME_EXCEPTION_CLASS = RuntimeException.class;
     public static final Class<Exception> EXCEPTION_CLASS = Exception.class;
     public static final String DecapitalizeExceptionBeanProperties = "com.sun.xml.internal.ws.api.model.DecapitalizeExceptionBeanProperties";
@@ -586,7 +585,7 @@
      */
     private boolean isServiceException(Class<?> exception) {
         return EXCEPTION_CLASS.isAssignableFrom(exception) &&
-                !(RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception));
+                !(RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || isRemoteException(exception));
     }
 
     /**
@@ -1169,7 +1168,7 @@
                     if(p == null)
                         reqRpcParams.put(reqRpcParams.size()+10000, param);
                     else
-                        reqRpcParams.put(p.getIndex(), param);
+                        reqRpcParams.put(param.getIndex(), param);
                 }
 
                 if(!param.isIN()){
@@ -1181,7 +1180,7 @@
                     if(p == null)
                         resRpcParams.put(resRpcParams.size()+10000, param);
                     else
-                        resRpcParams.put(p.getIndex(), param);
+                        resRpcParams.put(param.getIndex(), param);
                 }
             }else{
                 javaMethod.addParameter(param);
@@ -1210,7 +1209,7 @@
             //Exclude RuntimeException, RemoteException and Error etc
             if (!EXCEPTION_CLASS.isAssignableFrom(exception))
                 continue;
-            if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception))
+            if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || isRemoteException(exception))
                 continue;
             if (getAnnotation(exception, javax.xml.bind.annotation.XmlTransient.class) != null)
                 continue;
@@ -1646,6 +1645,21 @@
         return null;
     }
 
+    /*
+     * Returns true if an exception is a java.rmi.RemoteException or its subtype.
+     *
+     * @param exception
+     * @return true if an exception is a java.rmi.RemoteException or its subtype,
+     *      false otherwise
+     */
+    private boolean isRemoteException(Class<?> exception) {
+        Class<?> c = exception;
+        while (c != null && !REMOTE_EXCEPTION_CLASS.equals(c.getName())) {
+            c = c.getSuperclass();
+        }
+        return c != null;
+    }
+
     private static Boolean getBooleanSystemProperty(final String prop) {
         return AccessController.doPrivileged(
             new java.security.PrivilegedAction<Boolean>() {
diff --git a/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties b/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties
index 8d2adca..eedc7c2 100644
--- a/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties
+++ b/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties
@@ -26,4 +26,4 @@
 build-id=2.3.0-SNAPSHOT
 build-version=JAX-WS RI 2.3.0-SNAPSHOT
 major-version=2.3.0
-svn-revision=282759e2b822078de9ba78c743ed663541c16ead
+svn-revision=5c2c1fd2f2ab3b5c7cea25f79aa49e54cb84b7cc
diff --git a/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java b/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java
index 18d7fcd..09eaa93 100644
--- a/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java
+++ b/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,20 +26,29 @@
 package com.sun.xml.internal.ws.util.xml;
 
 import com.sun.istack.internal.Nullable;
-import com.sun.org.apache.xml.internal.resolver.Catalog;
-import com.sun.org.apache.xml.internal.resolver.CatalogManager;
-import com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver;
 import com.sun.xml.internal.ws.server.ServerRtException;
 import com.sun.xml.internal.ws.util.ByteArrayBuffer;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-import org.xml.sax.*;
-
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
 import javax.xml.XMLConstants;
+import javax.xml.catalog.CatalogFeatures;
+import javax.xml.catalog.CatalogFeatures.Feature;
+import javax.xml.catalog.CatalogManager;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -58,20 +67,18 @@
 import javax.xml.ws.WebServiceException;
 import javax.xml.xpath.XPathFactory;
 import javax.xml.xpath.XPathFactoryConfigurationException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
 
 /**
  * @author WS Development Team
@@ -282,76 +289,64 @@
     * Gets an EntityResolver using XML catalog
     */
      public static EntityResolver createEntityResolver(@Nullable URL catalogUrl) {
-        // set up a manager
-        CatalogManager manager = new CatalogManager();
-        manager.setIgnoreMissingProperties(true);
-        // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
-        manager.setUseStaticCatalog(false);
-        Catalog catalog = manager.getCatalog();
+        ArrayList<URL> urlsArray = new ArrayList<URL>();
+        EntityResolver er;
+        if (catalogUrl != null) {
+            urlsArray.add(catalogUrl);
+        }
         try {
-            if (catalogUrl != null) {
-                catalog.parseCatalog(catalogUrl);
-            }
-        } catch (IOException e) {
+            er = createCatalogResolver(urlsArray);
+        } catch (Exception e) {
             throw new ServerRtException("server.rt.err",e);
         }
-        return workaroundCatalogResolver(catalog);
+        return er;
     }
 
     /**
      * Gets a default EntityResolver for catalog at META-INF/jaxws-catalog.xml
      */
     public static EntityResolver createDefaultCatalogResolver() {
-
-        // set up a manager
-        CatalogManager manager = new CatalogManager();
-        manager.setIgnoreMissingProperties(true);
-        // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
-        manager.setUseStaticCatalog(false);
-        // parse the catalog
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        Enumeration<URL> catalogEnum;
-        Catalog catalog = manager.getCatalog();
+        EntityResolver er;
         try {
+            /**
+             * Gets a URLs for catalog defined at META-INF/jaxws-catalog.xml
+             */
+            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            Enumeration<URL> catalogEnum;
             if (cl == null) {
                 catalogEnum = ClassLoader.getSystemResources("META-INF/jax-ws-catalog.xml");
             } else {
                 catalogEnum = cl.getResources("META-INF/jax-ws-catalog.xml");
             }
-
-            while(catalogEnum.hasMoreElements()) {
-                URL url = catalogEnum.nextElement();
-                catalog.parseCatalog(url);
-            }
-        } catch (IOException e) {
+            er = createCatalogResolver(Collections.list(catalogEnum));
+        } catch (Exception e) {
             throw new WebServiceException(e);
         }
 
-        return workaroundCatalogResolver(catalog);
+        return er;
     }
 
     /**
-     *  Default CatalogResolver implementation is broken as it depends on CatalogManager.getCatalog() which will always create a new one when
-     *  useStaticCatalog is false.
-     *  This returns a CatalogResolver that uses the catalog passed as parameter.
-     * @param catalog
-     * @return  CatalogResolver
+     * Instantiate catalog resolver using new catalog API (javax.xml.catalog.*)
+     * added in JDK9. Usage of new API removes dependency on internal API
+     * (com.sun.org.apache.xml.internal) for modular runtime.
      */
-    private static CatalogResolver workaroundCatalogResolver(final Catalog catalog) {
-        // set up a manager
-        CatalogManager manager = new CatalogManager() {
-            @Override
-            public Catalog getCatalog() {
-                return catalog;
-            }
-        };
-        manager.setIgnoreMissingProperties(true);
-        // Using static catalog may  result in to sharing of the catalog by multiple apps running in a container
-        manager.setUseStaticCatalog(false);
+    private static EntityResolver createCatalogResolver(ArrayList<URL> urls) throws Exception {
+        // Prepare array of catalog paths
+        String[] paths = urls.stream()
+                             .map(u -> u.toExternalForm())
+                             .toArray(c -> new String[c]);
 
-        return new CatalogResolver(manager);
+        //Create CatalogResolver with new JDK9+ API
+        return (EntityResolver) CatalogManager.catalogResolver(catalogFeatures, paths);
     }
 
+    // Cache CatalogFeatures instance for future usages.
+    // Resolve feature is set to "continue" value for backward compatibility.
+    private static CatalogFeatures catalogFeatures = CatalogFeatures.builder()
+                                                    .with(Feature.RESOLVE, "continue")
+                                                    .build();
+
     /**
      * {@link ErrorHandler} that always treat the error as fatal.
      */
diff --git a/src/java.xml.ws/share/classes/module-info.java b/src/java.xml.ws/share/classes/module-info.java
index cba0cde..09668d4 100644
--- a/src/java.xml.ws/share/classes/module-info.java
+++ b/src/java.xml.ws/share/classes/module-info.java
@@ -35,7 +35,6 @@
     requires java.desktop;
     requires java.logging;
     requires java.management;
-    requires java.rmi;
     requires jdk.httpserver;
 
     uses javax.xml.ws.spi.Provider;
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JCodeModel.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JCodeModel.java
index 521cadb..9bbea7d 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JCodeModel.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JCodeModel.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,6 @@
 import com.sun.codemodel.internal.writer.FileCodeWriter;
 import com.sun.codemodel.internal.writer.ProgressCodeWriter;
 
-
 /**
  * Root of the code DOM.
  *
@@ -80,10 +79,13 @@
 public final class JCodeModel {
 
     /** The packages that this JCodeWriter contains. */
-    private HashMap<String,JPackage> packages = new HashMap<String,JPackage>();
+    private final HashMap<String,JPackage> packages = new HashMap<>();
+
+    /** Java module in {@code module-info.java} file. */
+    private JModule module;
 
     /** All JReferencedClasses are pooled here. */
-    private final HashMap<Class<?>,JReferencedClass> refClasses = new HashMap<Class<?>,JReferencedClass>();
+    private final HashMap<Class<?>,JReferencedClass> refClasses = new HashMap<>();
 
 
     /** Obtains a reference to the special "null" type. */
@@ -121,7 +123,7 @@
     public JCodeModel() {}
 
     /**
-     * Add a package to the list of packages to be generated
+     * Add a package to the list of packages to be generated.
      *
      * @param name
      *        Name of the package. Use "" to indicate the root package.
@@ -137,6 +139,50 @@
         return p;
     }
 
+    /**
+     * Creates and returns Java module to be generated.
+     * @param name The Name of Java module.
+     * @return New Java module.
+     */
+    public JModule _moduleInfo(final String name) {
+        return module = new JModule(name);
+    }
+
+    /**
+     * Returns existing Java module to be generated.
+     * @return Java module or {@code null} if Java module was not created yet.
+     */
+    public JModule _getModuleInfo() {
+        return module;
+    }
+
+    /**
+     * Creates Java module instance and adds existing packages with classes to the Java module info.
+     * Used to initialize and build Java module instance with existing packages content.
+     * @param name The Name of Java module.
+     * @param requires Requires directives to add.
+     * @throws IllegalStateException when Java module instance was not initialized.
+     */
+    public void _prepareModuleInfo(final String name, final String ...requires) {
+        _moduleInfo(name);
+        _updateModuleInfo(requires);
+    }
+
+    /**
+     * Adds existing packages with classes to the Java module info.
+     * Java module instance must exist before calling this method.
+     * Used to update Java module instance with existing packages content after it was prepared on client side.
+     * @param requires Requires directives to add.
+     * @throws IllegalStateException when Java module instance was not initialized.
+     */
+    public void _updateModuleInfo(final String ...requires) {
+        if (module == null) {
+            throw new IllegalStateException("Java module instance was not initialized yet.");
+        }
+        module._exports(packages.values(), false);
+        module._requires(requires);
+    }
+
     public final JPackage rootPackage() {
         return _package("");
     }
@@ -292,8 +338,12 @@
     public void build( CodeWriter source, CodeWriter resource ) throws IOException {
         JPackage[] pkgs = packages.values().toArray(new JPackage[packages.size()]);
         // avoid concurrent modification exception
-        for( JPackage pkg : pkgs )
+        for( JPackage pkg : pkgs ) {
             pkg.build(source,resource);
+        }
+        if (module != null) {
+            module.build(source);
+        }
         source.close();
         resource.close();
     }
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JExportsDirective.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JExportsDirective.java
new file mode 100644
index 0000000..c687f82
--- /dev/null
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JExportsDirective.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.codemodel.internal;
+
+// TODO: Implement "[to ModuleName {, ModuleName}]".
+// Only minimal form of exports directive is needed now so it was not implemented in full form.
+/**
+ * Represents a Java module {@code exports} directive.
+ * For example {@code "exports foo.bar;"}.
+ * @author Tomas Kraus
+ */
+
+public class JExportsDirective extends JModuleDirective {
+
+    /**
+     * Creates an instance of Java module {@code exports} directive.
+     * @param name name of package to be exported in this directive.
+     * @throws IllegalArgumentException if the name argument is {@code null}.
+     */
+    JExportsDirective(final String name) {
+        super(name);
+    }
+
+    /**
+     * Gets the type of this module directive.
+     * @return type of this module directive. Will always return {@code Type.ExportsDirective}.
+     */
+    @Override
+    public Type getType() {
+        return Type.ExportsDirective;
+    }
+
+    /**
+     * Print source code of this module directive.
+     * @param f Java code formatter.
+     * @return provided instance of Java code formatter.
+     */
+    @Override
+    public JFormatter generate(final JFormatter f) {
+        f.p("exports").p(name).p(';').nl();
+        return f;
+    }
+
+}
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JModule.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JModule.java
new file mode 100644
index 0000000..449d054
--- /dev/null
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JModule.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.codemodel.internal;
+
+// Based on modules grammar from http://openjdk.java.net/projects/jigsaw/doc/lang-vm.html
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Represents a Java module.
+ * @author Tomas Kraus
+ */
+public class JModule {
+
+    /** Java module file name. */
+    private static final String FILE_NAME = "module-info.java";
+
+    /** Name of this module. Mandatory value. Shall not be {@code null}. */
+    private final String name;
+
+    /** {@link Set} of Java module directives. */
+    private final Set<JModuleDirective> directives;
+
+    /**
+     * Creates an instance of Java module.
+     * @param name Java module name. Value can not be {@code null}
+     * @param version Java module version.
+     */
+    JModule(final String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("Value of name is null");
+        }
+        this.name = name;
+        this.directives = new HashSet<>();
+    }
+
+    /**
+     * Gets the name of this module.
+     * @return name of this module.
+     */
+    public String name() {
+        return name;
+    }
+
+    /**
+     * Gets module directives set.
+     * jUnit helper method.
+     * @return Module directives set.
+     */
+    Set<JModuleDirective> getDirectives() {
+        return directives;
+    }
+
+    /**
+     * Adds a package to the list of Java module exports.
+     * The package name shall not be {@code null} or empty {@code String}.
+     * @param pkg Java package to be exported.
+     */
+    public void _exports(final JPackage pkg) {
+        directives.add(new JExportsDirective(pkg.name()));
+    }
+
+    /**
+     * Adds packages to the list of Java module exports.
+     * @param pkgs Collection of packages to be added.
+     * @param addEmpty Adds also packages without any classes when {@code true}.
+     */
+    public void _exports(final Collection<JPackage> pkgs, final boolean addEmpty) {
+        for (Iterator<JPackage> i = pkgs.iterator(); i.hasNext();) {
+            final JPackage pkg = i.next();
+            if (addEmpty || pkg.hasClasses()) {
+                _exports(pkg);
+            }
+        }
+    }
+
+    /**
+     * Adds a module to the list of Java module requirements.
+     * The module name shall not be {@code null} or empty {@code String}.
+     * @param name Name of required Java module.
+     * @param isPublic Use {@code public} modifier.
+     * @param isStatic Use {@code static} modifier.
+     */
+    public void _requires(final String name, final boolean isPublic, final boolean isStatic) {
+        directives.add(new JRequiresDirective(name, isPublic, isStatic));
+    }
+
+    /**
+     * Adds a module to the list of Java module requirements without {@code public} and {@code static} modifiers.
+     * The module name shall not be {@code null} or empty {@code String}.
+     * @param name Name of required Java module.
+     */
+    public void _requires(final String name) {
+        directives.add(new JRequiresDirective(name, false, false));
+    }
+
+    /**
+     * Adds all modules to the list of Java module requirements.
+     * The module name shall not be {@code null} or empty {@code String}.
+     * @param names Names of required Java module.
+     * @param isPublic Use {@code public} modifier.
+     * @param isStatic Use {@code static} modifier.
+     */
+    public void _requires(final boolean isPublic, final boolean isStatic, final String ...names) {
+        if (names != null) {
+            for (final String reqName : names) {
+                _requires(reqName, isPublic, isStatic);
+            }
+        }
+    }
+
+    /**
+     * Adds all modules to the list of Java module requirements without {@code public} and {@code static} modifiers.
+     * @param names Names of required Java module.
+     */
+    public void _requires(final String ...names) {
+        _requires(false, false, names);
+    }
+
+    /**
+     * Print source code of Java Module declaration.
+     * @param f Java code formatter.
+     * @return provided instance of Java code formatter.
+     */
+    public JFormatter generate(final JFormatter f) {
+        f.p("module").p(name);
+        f.p('{').nl();
+        if (!directives.isEmpty()) {
+            f.i();
+            for (final JModuleDirective directive : directives) {
+                directive.generate(f);
+            }
+            f.o();
+        }
+        f.p('}').nl();
+        return f;
+    }
+
+    /**
+     * Create {@code module-info.java} source writer.
+     * @return New instance of {@code module-info.java} source writer.
+     */
+    private JFormatter createModuleInfoSourceFileWriter(final CodeWriter src) throws IOException {
+        Writer bw = new BufferedWriter(src.openSource(null, FILE_NAME));
+        return new JFormatter(new PrintWriter(bw));
+    }
+
+    /**
+     * Build {@code module-info.java} source file.
+     * @param src Source code writer.
+     * @throws IOException if there is any problem with writing the file.
+     */
+    void build(final CodeWriter src) throws IOException {
+        final JFormatter f = createModuleInfoSourceFileWriter(src);
+        generate(f);
+        f.close();
+    }
+
+}
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JModuleDirective.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JModuleDirective.java
new file mode 100644
index 0000000..472aa50
--- /dev/null
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JModuleDirective.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.codemodel.internal;
+
+// Currently only exports directive is needed in this model.
+/**
+ * Represents a Java module directive.
+ * For example {@code "exports foo.bar;"} or {@code "requires foo.baz;"}.
+ * @author Tomas Kraus
+ */
+public abstract class JModuleDirective {
+
+    // Only ExportsDirective is implemented.
+    /**
+     * Module directive type. Child class implements {@code getType()} method which returns corresponding value.
+     */
+    public enum Type {
+       /** Directive starting with {@code requires} keyword. */
+       RequiresDirective,
+       /** Directive starting with {@code exports} keyword. */
+       ExportsDirective,
+    }
+
+    /** Name argument of module directive. */
+    protected final String name;
+
+    /**
+     * Creates an instance of Java module directive.
+     * @param name name argument of module directive.
+     * @throws IllegalArgumentException if the name argument is {@code null}.
+     */
+    JModuleDirective(final String name) {
+        if (name == null) {
+            throw new IllegalArgumentException("JModuleDirective name argument is null");
+        }
+        this.name = name;
+    }
+
+    /**
+     * Gets the type of this module directive.
+     * @return type of this module directive. Will never be {@code null}.
+     */
+    public abstract Type getType();
+
+    /**
+     * Print source code of this module directive.
+     * @param f Java code formatter.
+     * @return provided instance of Java code formatter.
+     */
+    public abstract JFormatter generate(final JFormatter f);
+
+    /**
+     * Compares this module directive to the specified object.
+     * @param other The object to compare this {@link JModuleDirective} against.
+     * @return {@code true} if the argument is not {@code null}
+     *         and is a {@link JModuleDirective} object with the same type
+     *         and equal name.
+     */
+    @Override
+    public boolean equals(final Object other) {
+        if (this == other) {
+            return true;
+        }
+        if (other instanceof JModuleDirective) {
+            final JModuleDirective otherDirective = (JModuleDirective)other;
+            return this.getType() == otherDirective.getType() && this.name.equals(otherDirective.name);
+        }
+        return false;
+    }
+
+
+    /**
+     * Returns a hash code for this module directive based on directive type and name.
+     * The hash code for a module directive is computed as <blockquote><pre>
+     * 97 * Integer.hashCode(type_ordinal_value + 1) + name.hashCode()
+     * </pre></blockquote> using {@code int} arithmetic.
+     * @return a hash code value for this object.
+     */
+    @Override
+    public int hashCode() {
+        return 97 * (Integer.hashCode(getType().ordinal() + 1)) + name.hashCode();
+    }
+
+    /**
+     * Gets the name of this module directive.
+     * @return name of this module directive.
+     */
+    public String name() {
+        return name;
+    }
+
+}
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JPackage.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JPackage.java
index 9b9b174..e6b50c0 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JPackage.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JPackage.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -335,6 +335,15 @@
     }
 
     /**
+     * Checks if this package contains any classes.
+     * @return {@code true} if this package contains any classes
+     *         or {@code false} otherwise.
+     */
+    public boolean hasClasses() {
+        return !classes.isEmpty();
+    }
+
+    /**
      * Checks if a given name is already defined as a class/interface
      */
     public boolean isDefined(String classLocalName) {
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JRequiresDirective.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JRequiresDirective.java
new file mode 100644
index 0000000..4bb4ea6
--- /dev/null
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/JRequiresDirective.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.codemodel.internal;
+
+/**
+ * Represents a Java module {@code requires} directive.
+ * For example {@code "requires foo.bar;"} or {@code "requires public foo.baz;"}.
+ * @author Tomas Kraus
+ */
+public class JRequiresDirective extends JModuleDirective {
+
+    /** Public readability modifier. */
+    final boolean isPublic;
+
+    /** Static modifier. */
+    final boolean isStatic;
+
+    /**
+     * Creates an instance of Java module {@code requires} directive.
+     * @param name name of required module or service.
+     * @param isPublic Use {@code public} modifier.
+     * @param isStatic Use {@code static} modifier.
+     * @throws IllegalArgumentException if the name argument is {@code null}.
+     */
+    JRequiresDirective(final String name, final boolean isPublic, final boolean isStatic) {
+        super(name);
+        this.isPublic = isPublic;
+        this.isStatic = isStatic;
+    }
+
+    /**
+     * Gets the type of this module directive.
+     * @return type of this module directive. Will always return {@code Type.RequiresDirective}.
+     */
+    @Override
+    public Type getType() {
+        return Type.RequiresDirective;
+    }
+
+    /**
+     * Print source code of {@code requires} module directive modifiers:
+     * {@code public} and {@code static} keywords for module dependency.
+     * @param f Java code formatter.
+     */
+    protected void generateModifiers(final JFormatter f) {
+        if (isPublic) {
+            f.p("public");
+        }
+        if (isStatic) {
+            f.p("static");
+        }
+    }
+
+    /**
+     * Print source code of this module directive.
+     * @param f Java code formatter.
+     * @return provided instance of Java code formatter.
+     */
+    @Override
+    public JFormatter generate(final JFormatter f) {
+        f.p("requires");
+        generateModifiers(f);
+        f.p(name);
+        f.p(';').nl();
+        return f;
+    }
+
+}
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/FileCodeWriter.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/FileCodeWriter.java
index 702fae0..6dbd9aa 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/FileCodeWriter.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/FileCodeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@
     private final boolean readOnly;
 
     /** Files that shall be marked as read only. */
-    private final Set<File> readonlyFiles = new HashSet<File>();
+    private final Set<File> readonlyFiles = new HashSet<>();
 
     public FileCodeWriter( File target ) throws IOException {
         this(target,false);
@@ -72,13 +72,14 @@
             throw new IOException(target + ": non-existent directory");
     }
 
+    @Override
     public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
         return new FileOutputStream(getFile(pkg,fileName));
     }
 
     protected File getFile(JPackage pkg, String fileName ) throws IOException {
         File dir;
-        if(pkg.isUnnamed())
+        if(pkg == null || pkg.isUnnamed())
             dir = target;
         else
             dir = new File(target, toDirName(pkg));
@@ -97,6 +98,7 @@
         return fn;
     }
 
+    @Override
     public void close() throws IOException {
         // mark files as read-onnly if necessary
         for (File f : readonlyFiles)
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/FilterCodeWriter.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/FilterCodeWriter.java
index ba6f84d..eaf2d80 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/FilterCodeWriter.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/FilterCodeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,14 +44,17 @@
         this.core = core;
     }
 
+    @Override
     public OutputStream openBinary( JPackage pkg, String fileName ) throws IOException {
         return core.openBinary(pkg, fileName);
     }
 
+    @Override
     public Writer openSource( JPackage pkg, String fileName ) throws IOException {
         return core.openSource(pkg, fileName);
     }
 
+    @Override
     public void close() throws IOException {
         core.close();
     }
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/ProgressCodeWriter.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/ProgressCodeWriter.java
index 50b92c7..8a79cc8 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/ProgressCodeWriter.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/ProgressCodeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,18 +51,21 @@
 
     private final PrintStream progress;
 
+    @Override
     public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
         report(pkg, fileName);
         return super.openBinary(pkg,fileName);
     }
 
+    @Override
     public Writer openSource(JPackage pkg, String fileName) throws IOException {
         report(pkg, fileName);
         return super.openSource(pkg,fileName);
     }
 
     private void report(JPackage pkg, String fileName) {
-        if(pkg.isUnnamed()) progress.println(fileName);
+        if(pkg == null || pkg.isUnnamed())
+            progress.println(fileName);
         else
             progress.println(
                 pkg.name().replace('.',File.separatorChar)
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/PrologCodeWriter.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/PrologCodeWriter.java
index b35abc7..f6bf8ce 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/PrologCodeWriter.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/PrologCodeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,6 +62,7 @@
     }
 
 
+    @Override
     public Writer openSource(JPackage pkg, String fileName) throws IOException {
         Writer w = super.openSource(pkg,fileName);
 
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/SingleStreamCodeWriter.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/SingleStreamCodeWriter.java
index b414736..5382865 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/SingleStreamCodeWriter.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/SingleStreamCodeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -55,21 +55,24 @@
         out = new PrintStream(os);
     }
 
+    @Override
     public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
-        String pkgName = pkg.name();
-        if(pkgName.length()!=0)     pkgName += '.';
+        final String name = pkg != null && pkg.name().length() > 0
+                ? pkg.name() + '.' + fileName : fileName;
 
         out.println(
-            "-----------------------------------" + pkgName+fileName +
+            "-----------------------------------" + name +
             "-----------------------------------");
 
         return new FilterOutputStream(out) {
+            @Override
             public void close() {
                 // don't let this stream close
             }
         };
     }
 
+    @Override
     public void close() throws IOException {
         out.close();
     }
diff --git a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/ZipCodeWriter.java b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/ZipCodeWriter.java
index b280f86..54ff30f 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/ZipCodeWriter.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/codemodel/internal/writer/ZipCodeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,6 +49,7 @@
         zip = new ZipOutputStream(target);
         // nullify the close method.
         filter = new FilterOutputStream(zip){
+            @Override
             public void close() {}
         };
     }
@@ -57,10 +58,9 @@
 
     private final OutputStream filter;
 
+    @Override
     public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
-        String name = fileName;
-        if(!pkg.isUnnamed())    name = toDirName(pkg)+name;
-
+        final String name = pkg == null || pkg.isUnnamed() ? fileName : toDirName(pkg)+fileName;
         zip.putNextEntry(new ZipEntry(name));
         return filter;
     }
@@ -70,6 +70,7 @@
         return pkg.name().replace('.','/')+'/';
     }
 
+    @Override
     public void close() throws IOException {
         zip.close();
     }
diff --git a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties
index 77ce848..6a418f5 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties
+++ b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -59,6 +59,7 @@
 \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ If a directory is given, **/*.xjb is searched\n\
 \ \ -d <dir>           :  generated files will go into this directory\n\
 \ \ -p <pkg>           :  specifies the target package\n\
+\ \ -m <name>          :  generate module-info.java with given Java module name\n\
 \ \ -httpproxy <proxy> :  set HTTP/HTTPS proxy. Format is [user[:password]@]proxyHost:proxyPort\n\
 \ \ -httpproxyfile <f> :  Works like -httpproxy but takes the argument in a file to protect password \n\
 \ \ -classpath <arg>   :  specify where to find user class files\n\
@@ -120,6 +121,9 @@
 
 Driver.ILLEGAL_TARGET_VERSION = \
     "{0}" is not a valid target version. "2.0" and "2.1" are supported.
+# Java module name is invalid, {0} - Java module name.
+Driver.INVALID_JAVA_MODULE_NAME = \
+    invalid Java module name: "{0}"
 
 # Not concatenated with any other string (written on a separate line).
 Driver.MISSING_PROXYFILE = \
diff --git a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Messages.java b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Messages.java
index e75dfd8..b4ebd12 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Messages.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Messages.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -79,6 +79,9 @@
     // static final String MISSING_COMPATIBILITY_OPERAND = // 0 args
     //     "Driver.MissingCompatibilityOperand";
 
+    static final String INVALID_JAVA_MODULE_NAME = // 1 arg
+        "Driver.INVALID_JAVA_MODULE_NAME";
+
     static final String MISSING_PROXY = // 0 args
         "Driver.MISSING_PROXY";
 
diff --git a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java
index 4680afd..bce8f27 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,21 @@
 
 package com.sun.tools.internal.xjc;
 
+import com.sun.codemodel.internal.CodeWriter;
+import com.sun.codemodel.internal.JPackage;
+import com.sun.codemodel.internal.JResourceFile;
+import com.sun.codemodel.internal.writer.FileCodeWriter;
+import com.sun.codemodel.internal.writer.PrologCodeWriter;
+import com.sun.istack.internal.tools.DefaultAuthenticator;
+import com.sun.tools.internal.xjc.api.ClassNameAllocator;
+import com.sun.tools.internal.xjc.api.SpecVersion;
+import com.sun.tools.internal.xjc.generator.bean.field.FieldRendererFactory;
+import com.sun.tools.internal.xjc.model.Model;
+import com.sun.tools.internal.xjc.reader.Util;
+import com.sun.xml.internal.bind.api.impl.NameConverter;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -33,8 +48,12 @@
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.nio.charset.Charset;
+import java.nio.charset.IllegalCharsetNameException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.text.SimpleDateFormat;
@@ -43,33 +62,15 @@
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.ServiceLoader;
 import java.util.Set;
-
-import com.sun.codemodel.internal.CodeWriter;
-import com.sun.codemodel.internal.JPackage;
-import com.sun.codemodel.internal.JResourceFile;
-import com.sun.codemodel.internal.writer.FileCodeWriter;
-import com.sun.codemodel.internal.writer.PrologCodeWriter;
-import com.sun.istack.internal.tools.DefaultAuthenticator;
-import com.sun.org.apache.xml.internal.resolver.CatalogManager;
-import com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver;
-import com.sun.tools.internal.xjc.api.ClassNameAllocator;
-import com.sun.tools.internal.xjc.api.SpecVersion;
-import com.sun.tools.internal.xjc.generator.bean.field.FieldRendererFactory;
-import com.sun.tools.internal.xjc.model.Model;
-import com.sun.tools.internal.xjc.reader.Util;
-import com.sun.xml.internal.bind.api.impl.NameConverter;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.charset.Charset;
-import java.nio.charset.IllegalCharsetNameException;
-import java.util.Locale;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
+import javax.xml.catalog.CatalogFeatures;
+import javax.xml.catalog.CatalogFeatures.Feature;
+import javax.xml.catalog.CatalogManager;
 
 /**
  * Global options.
@@ -264,6 +265,11 @@
     private Plugin nameConverterOwner = null;
 
     /**
+     * Java module name in {@code module-info.java}.
+     */
+    private String javaModule = null;
+
+    /**
      * Gets the active {@link FieldRendererFactory} that shall be used to build {@link Model}.
      *
      * @return always non-null.
@@ -464,6 +470,13 @@
                 classpaths.toArray(new URL[classpaths.size()]),parent);
     }
 
+    /**
+     * Gets Java module name option.
+     * @return Java module name option or {@code null} if this option was not set.
+     */
+    public String getModuleName() {
+        return javaModule;
+    }
 
     /**
      * Parses an option {@code args[i]} and return
@@ -509,6 +522,10 @@
             }
             return 2;
         }
+        if (args[i].equals("-m")) {
+            javaModule = requireArgument("-m", args, ++i);
+            return 2;
+        }
         if (args[i].equals("-debug")) {
             debugMode = true;
             verbose = true;
@@ -622,9 +639,7 @@
             return 2;
         }
         if( args[i].equals("-catalog") ) {
-            // use Sun's "XML Entity and URI Resolvers" by Norman Walsh
-            // to resolve external entities.
-            // http://www.sun.com/xml/developers/resolver/
+            // use javax.xml.catalog to resolve external entities.
 
             File catalogFile = new File(requireArgument("-catalog",args,++i));
             try {
@@ -735,7 +750,7 @@
      * and add them as {@link InputSource} to the specified list.
      *
      * @param suffix
-     *      If the given token is a directory name, we do a recusive search
+     *      If the given token is a directory name, we do a recursive search
      *      and find all files that have the given suffix.
      */
     private void addFile(String name, List<InputSource> target, String suffix) throws BadCommandLineException {
@@ -762,16 +777,27 @@
      * Adds a new catalog file.
      */
     public void addCatalog(File catalogFile) throws IOException {
-        if(entityResolver==null) {
-            final CatalogManager staticManager = CatalogManager.getStaticManager();
-            // hack to force initialization so catalog manager system properties take effect
-            staticManager.getVerbosity();
-            staticManager.setIgnoreMissingProperties(true);
-            entityResolver = new CatalogResolver(true);
+        String newUrl = catalogFile.getPath();
+        if (!catalogUrls.contains(newUrl)) {
+            catalogUrls.add(newUrl);
         }
-        ((CatalogResolver)entityResolver).getCatalog().parseCatalog(catalogFile.getPath());
+        try {
+            entityResolver = CatalogManager.catalogResolver(catalogFeatures,
+                                catalogUrls.toArray(new String[0]));
+        } catch (Exception ex) {
+            entityResolver = null;
+        }
     }
 
+    // Since javax.xml.catalog is unmodifiable we need to track catalog
+    // URLs added and create new catalog each time addCatalog is called
+    private final ArrayList<String> catalogUrls = new ArrayList<String>();
+
+    // Cache CatalogFeatures instance for future usages.
+    // Resolve feature is set to "continue" value for backward compatibility.
+    private static CatalogFeatures catalogFeatures = CatalogFeatures.builder()
+                                                    .with(Feature.RESOLVE, "continue")
+                                                    .build();
     /**
      * Parses arguments and fill fields of this object.
      *
diff --git a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/ProgressCodeWriter.java b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/ProgressCodeWriter.java
index 6c96c65..ed74846 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/ProgressCodeWriter.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/ProgressCodeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,23 +52,42 @@
 
     private final XJCListener progress;
 
+    @Override
     public Writer openSource(JPackage pkg, String fileName) throws IOException {
         report(pkg,fileName);
         return super.openSource(pkg, fileName);
     }
 
+    @Override
     public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
         report(pkg,fileName);
         return super.openBinary(pkg,fileName);
     }
 
-    private void report(JPackage pkg, String fileName) {
-        String name = pkg.name().replace('.', File.separatorChar);
-        if(name.length()!=0)    name +=     File.separatorChar;
-        name += fileName;
+    /**
+     * Report progress to {@link XJCListener}.
+     * @param pkg The package of file being written. Value of {@code null} means that file has no package.
+     * @param fileName The file name being written. Value can't be {@code null}.
+     */
+    private void report(final JPackage pkg, final String fileName) {
+        if (fileName == null) {
+            throw new IllegalArgumentException("File name is null");
+        }
+
+        final String pkgName;
+        final String fileNameOut;
+        if (pkg != null && (pkgName = pkg.name().replace('.', File.separatorChar)).length() > 0 ) {
+            final StringBuilder sb = new StringBuilder(fileName.length() + pkgName.length() + 1);
+            sb.append(pkgName);
+            sb.append(File.separatorChar);
+            sb.append(fileName);
+            fileNameOut = sb.toString();
+        } else {
+            fileNameOut = fileName;
+        }
 
         if(progress.isCanceled())
             throw new AbortException();
-        progress.generatedFile(name,current++,totalFileCount);
+        progress.generatedFile(fileNameOut, current++, totalFileCount);
     }
 }
diff --git a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/BeanGenerator.java b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/BeanGenerator.java
index 01cf43a..9d77755 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/BeanGenerator.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/BeanGenerator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -108,6 +108,9 @@
  */
 public final class BeanGenerator implements Outline {
 
+    /** JAXB module name. JAXB dependency is mandatory in generated Java module. */
+    private static final String JAXB_PACKAGE = "java.xml.bind";
+
     /** Simplifies class/interface creation and collision detection. */
     private final CodeModelClassFactory codeModelClassFactory;
     private final ErrorReceiver errorReceiver;
@@ -254,6 +257,10 @@
             getPackageContext(ei._package()).objectFactoryGenerator().populate(ei);
         }
 
+        if (model.options.getModuleName() != null) {
+            codeModel._prepareModuleInfo(model.options.getModuleName(), JAXB_PACKAGE);
+        }
+
         if (model.options.debugMode) {
             generateClassList();
         }
diff --git a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/ObjectFactoryGeneratorImpl.java b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/ObjectFactoryGeneratorImpl.java
index 6ed5b83..8080be1 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/ObjectFactoryGeneratorImpl.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/ObjectFactoryGeneratorImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -229,8 +229,12 @@
 
         m.javadoc()
             .append("Create an instance of ")
-            .append(exposedElementType)
-            .append("}");
+            .append(exposedElementType);
+        m.javadoc().addParam($value)
+            .append("Java instance representing xml element's value.");
+        m.javadoc().addReturn()
+            .append("the new instance of ")
+            .append(exposedElementType);
 
         XmlElementDeclWriter xemw = m.annotate2(XmlElementDeclWriter.class);
         xemw.namespace(namespaceURI).name(localPart);
diff --git a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CBuiltinLeafInfo.java b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CBuiltinLeafInfo.java
index 48ee3c7..8cfae2e 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CBuiltinLeafInfo.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CBuiltinLeafInfo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -219,7 +219,7 @@
      *      do not modify the returned array.
      */
     public final QName[] getTypeNames() {
-        return typeNames;
+        return typeNames.clone();
     }
 
     /**
diff --git a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/Constructor.java b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/Constructor.java
index e68db77..9915799 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/Constructor.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/Constructor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,7 +58,7 @@
 {
     // Since Constructor is typically built when there is no FieldItem
     // nor FieldUse, we need to rely on Strings.
-    public Constructor( String[] _fields ) { this.fields = _fields; }
+    public Constructor( String[] _fields ) { this.fields = _fields.clone(); }
 
     /** array of field names to be initialized. */
     public final String[] fields;
diff --git a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/reader/dtd/bindinfo/BIInterface.java b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/reader/dtd/bindinfo/BIInterface.java
index 7239a85..47db936 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/reader/dtd/bindinfo/BIInterface.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/reader/dtd/bindinfo/BIInterface.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,13 +66,13 @@
      * Gets the names of interfaces/classes that implement
      * this interface.
      */
-    public String[] members() { return members; }
+    public String[] members() { return members.clone(); }
 
 
     private final String[] fields;
 
     /** Gets the names of fields in this interface. */
-    public String[] fields() { return fields; }
+    public String[] fields() { return fields.clone(); }
 
 
     /** Gets the location where this declaration is declared. */
diff --git a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/NGCCRuntimeEx.java b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/NGCCRuntimeEx.java
index 620c0c8..4e600c3 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/NGCCRuntimeEx.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/NGCCRuntimeEx.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -436,19 +436,18 @@
         currentContext = currentContext.previous;
     }
 
-
-
-
-
 //
 //
 // Utility functions
 //
 //
 
-
-    /** Parses UName under the given context. */
-    public UName parseUName( String qname ) throws SAXException {
+    /**
+     * Parses UName under the given context.
+     * @param qname Attribute name.
+     * @return New {@link UName} instance based on attribute name.
+     */
+    public UName parseUName(final String qname ) throws SAXException {
         int idx = qname.indexOf(':');
         if(idx<0) {
             String uri = resolveNamespacePrefix("");
@@ -472,6 +471,91 @@
         }
     }
 
+    /**
+     * Utility function for collapsing the namespaces inside qname declarations
+     * and 'name' attribute values that should contain the qname values
+     *
+     * @param text String where whitespaces should be collapsed
+     * @return String with whitespaces collapsed
+     */
+    public String collapse(String text) {
+        return collapse((CharSequence) text).toString();
+    }
+
+    /**
+     * returns true if the specified char is a white space character.
+     */
+    private final boolean isWhiteSpace(char ch) {
+        // most of the characters are non-control characters.
+        // so check that first to quickly return false for most of the cases.
+        if (ch > 0x20) {
+            return false;
+        }
+
+        // other than we have to do four comparisons.
+        return ch == 0x9 || ch == 0xA || ch == 0xD || ch == 0x20;
+    }
+
+    /**
+     * This is usually the biggest processing bottleneck.
+     *
+     */
+    private CharSequence collapse(CharSequence text) {
+        int len = text.length();
+
+        // most of the texts are already in the collapsed form.
+        // so look for the first whitespace in the hope that we will
+        // never see it.
+        int s = 0;
+        while (s < len) {
+            if (isWhiteSpace(text.charAt(s))) {
+                break;
+            }
+            s++;
+        }
+        if (s == len) // the input happens to be already collapsed.
+        {
+            return text;
+        }
+
+        // we now know that the input contains spaces.
+        // let's sit down and do the collapsing normally.
+        StringBuilder result = new StringBuilder(len /*allocate enough size to avoid re-allocation*/);
+
+        if (s != 0) {
+            for (int i = 0; i < s; i++) {
+                result.append(text.charAt(i));
+            }
+            result.append(' ');
+        }
+
+        boolean inStripMode = true;
+        for (int i = s + 1; i < len; i++) {
+            char ch = text.charAt(i);
+            boolean b = isWhiteSpace(ch);
+            if (inStripMode && b) {
+                continue; // skip this character
+            }
+            inStripMode = b;
+            if (inStripMode) {
+                result.append(' ');
+            } else {
+                result.append(ch);
+            }
+        }
+
+        // remove trailing whitespaces
+        len = result.length();
+        if (len > 0 && result.charAt(len - 1) == ' ') {
+            result.setLength(len - 1);
+        }
+        // whitespaces are already collapsed,
+        // so all we have to do is to remove the last one character
+        // if it's a whitespace.
+
+        return result;
+    }
+
     public boolean parseBoolean(String v) {
         if(v==null) return false;
         v=v.trim();
diff --git a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/attributeDeclBody.java b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/attributeDeclBody.java
index 6f06318..7e75933 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/attributeDeclBody.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/attributeDeclBody.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,20 +25,14 @@
 
 /* this file is generated by RelaxNGCC */
 package com.sun.xml.internal.xsom.impl.parser.state;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.Attributes;
-import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
 
-    import com.sun.xml.internal.xsom.*;
-    import com.sun.xml.internal.xsom.parser.*;
-    import com.sun.xml.internal.xsom.impl.*;
-    import com.sun.xml.internal.xsom.impl.parser.*;
-    import org.xml.sax.Locator;
-    import org.xml.sax.ContentHandler;
-    import org.xml.sax.helpers.*;
-    import java.util.*;
-    import java.math.BigInteger;
+import com.sun.xml.internal.xsom.impl.*;
+import com.sun.xml.internal.xsom.impl.parser.*;
+import com.sun.xml.internal.xsom.parser.*;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
 
 
 
@@ -458,7 +452,7 @@
             break;
         case 11:
             {
-                name = $value;
+                name = $runtime.collapse($value);
                 $_ngcc_current_state = 10;
             }
             break;
diff --git a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/attributeGroupDecl.java b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/attributeGroupDecl.java
index a8dc45f..b2fd963 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/attributeGroupDecl.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/attributeGroupDecl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,20 +25,14 @@
 
 /* this file is generated by RelaxNGCC */
 package com.sun.xml.internal.xsom.impl.parser.state;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.Attributes;
-import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
 
-    import com.sun.xml.internal.xsom.*;
-    import com.sun.xml.internal.xsom.parser.*;
-    import com.sun.xml.internal.xsom.impl.*;
-    import com.sun.xml.internal.xsom.impl.parser.*;
-    import org.xml.sax.Locator;
-    import org.xml.sax.ContentHandler;
-    import org.xml.sax.helpers.*;
-    import java.util.*;
-    import java.math.BigInteger;
+import com.sun.xml.internal.xsom.impl.*;
+import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
+import com.sun.xml.internal.xsom.parser.*;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
 
 
 
@@ -401,7 +395,7 @@
             break;
         case 12:
             {
-                name = $value;
+                name = $runtime.collapse($value);
                 $_ngcc_current_state = 11;
             }
             break;
diff --git a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/complexType.java b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/complexType.java
index 92cafc1..8707d5d 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/complexType.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/complexType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,21 +25,16 @@
 
 /* this file is generated by RelaxNGCC */
 package com.sun.xml.internal.xsom.impl.parser.state;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
+
+import com.sun.xml.internal.xsom.*;
+import com.sun.xml.internal.xsom.impl.*;
+import com.sun.xml.internal.xsom.impl.parser.*;
+import com.sun.xml.internal.xsom.parser.*;
+import java.util.*;
+
 import org.xml.sax.Attributes;
-import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
-
-    import com.sun.xml.internal.xsom.*;
-    import com.sun.xml.internal.xsom.parser.*;
-    import com.sun.xml.internal.xsom.impl.*;
-    import com.sun.xml.internal.xsom.impl.parser.*;
-    import org.xml.sax.Locator;
-    import org.xml.sax.ContentHandler;
-    import org.xml.sax.helpers.*;
-    import java.util.*;
-    import java.math.BigInteger;
-
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
 
 
 class complexType extends NGCCHandler {
@@ -1683,7 +1678,7 @@
             break;
         case 70:
             {
-                name = $value;
+                name = $runtime.collapse($value);
                 $_ngcc_current_state = 69;
             }
             break;
diff --git a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/elementDeclBody.java b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/elementDeclBody.java
index e994ca3..5ccbacc 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/elementDeclBody.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/elementDeclBody.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,21 +25,15 @@
 
 /* this file is generated by RelaxNGCC */
 package com.sun.xml.internal.xsom.impl.parser.state;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
+
+import com.sun.xml.internal.xsom.impl.*;
+import com.sun.xml.internal.xsom.impl.parser.*;
+import com.sun.xml.internal.xsom.parser.*;
+import java.util.*;
+
 import org.xml.sax.Attributes;
-import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
-
-    import com.sun.xml.internal.xsom.*;
-    import com.sun.xml.internal.xsom.parser.*;
-    import com.sun.xml.internal.xsom.impl.*;
-    import com.sun.xml.internal.xsom.impl.parser.*;
-    import org.xml.sax.Locator;
-    import org.xml.sax.ContentHandler;
-    import org.xml.sax.helpers.*;
-    import java.util.*;
-    import java.math.BigInteger;
-
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
 
 
 class elementDeclBody extends NGCCHandler {
@@ -813,7 +807,7 @@
             break;
         case 22:
             {
-                name = $value;
+                name = $runtime.collapse($value);
                 $_ngcc_current_state = 21;
             }
             break;
diff --git a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/group.java b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/group.java
index 298160a..c50550e 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/group.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/group.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,20 +25,14 @@
 
 /* this file is generated by RelaxNGCC */
 package com.sun.xml.internal.xsom.impl.parser.state;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.Attributes;
-import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
 
-    import com.sun.xml.internal.xsom.*;
-    import com.sun.xml.internal.xsom.parser.*;
-    import com.sun.xml.internal.xsom.impl.*;
-    import com.sun.xml.internal.xsom.impl.parser.*;
-    import org.xml.sax.Locator;
-    import org.xml.sax.ContentHandler;
-    import org.xml.sax.helpers.*;
-    import java.util.*;
-    import java.math.BigInteger;
+import com.sun.xml.internal.xsom.impl.*;
+import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
+import com.sun.xml.internal.xsom.parser.*;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
 
 
 
@@ -403,7 +397,7 @@
             break;
         case 9:
             {
-                name = $value;
+                name = $runtime.collapse($value);
                 $_ngcc_current_state = 8;
             }
             break;
diff --git a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/identityConstraint.java b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/identityConstraint.java
index 09f4e0a..fa4578b 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/identityConstraint.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/identityConstraint.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,21 +25,15 @@
 
 /* this file is generated by RelaxNGCC */
 package com.sun.xml.internal.xsom.impl.parser.state;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
+
+import com.sun.xml.internal.xsom.*;
+import com.sun.xml.internal.xsom.impl.*;
+import com.sun.xml.internal.xsom.impl.parser.*;
+import com.sun.xml.internal.xsom.parser.*;
+import java.util.*;
+
 import org.xml.sax.Attributes;
-import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
-
-    import com.sun.xml.internal.xsom.*;
-    import com.sun.xml.internal.xsom.parser.*;
-    import com.sun.xml.internal.xsom.impl.*;
-    import com.sun.xml.internal.xsom.impl.parser.*;
-    import org.xml.sax.Locator;
-    import org.xml.sax.ContentHandler;
-    import org.xml.sax.helpers.*;
-    import java.util.*;
-    import java.math.BigInteger;
-
+import org.xml.sax.SAXException;
 
 
 class identityConstraint extends NGCCHandler {
@@ -471,7 +465,7 @@
         switch($_ngcc_current_state) {
         case 15:
             {
-                name = $value;
+                name = $runtime.collapse($value);
                 $_ngcc_current_state = 14;
             }
             break;
diff --git a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/notation.java b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/notation.java
index bb21d28..a7c2a6a 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/notation.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/notation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,20 +25,15 @@
 
 /* this file is generated by RelaxNGCC */
 package com.sun.xml.internal.xsom.impl.parser.state;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.Attributes;
-import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
 
-    import com.sun.xml.internal.xsom.*;
-    import com.sun.xml.internal.xsom.parser.*;
-    import com.sun.xml.internal.xsom.impl.*;
-    import com.sun.xml.internal.xsom.impl.parser.*;
-    import org.xml.sax.Locator;
-    import org.xml.sax.ContentHandler;
-    import org.xml.sax.helpers.*;
-    import java.util.*;
-    import java.math.BigInteger;
+import com.sun.xml.internal.xsom.*;
+import com.sun.xml.internal.xsom.impl.*;
+import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
+import com.sun.xml.internal.xsom.parser.*;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
 
 
 
@@ -435,7 +430,7 @@
             break;
         case 13:
             {
-                name = $value;
+                name = $runtime.collapse($value);
                 $_ngcc_current_state = 12;
             }
             break;
diff --git a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/qname.java b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/qname.java
index 60e50fe..212472b 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/qname.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/qname.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,23 +25,11 @@
 
 /* this file is generated by RelaxNGCC */
 package com.sun.xml.internal.xsom.impl.parser.state;
+
 import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
 import org.xml.sax.Attributes;
 import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
 
-    import com.sun.xml.internal.xsom.*;
-    import com.sun.xml.internal.xsom.parser.*;
-    import com.sun.xml.internal.xsom.impl.*;
-    import com.sun.xml.internal.xsom.impl.parser.*;
-    import org.xml.sax.Locator;
-    import org.xml.sax.ContentHandler;
-    import org.xml.sax.helpers.*;
-    import java.util.*;
-    import java.math.BigInteger;
-
-
-
 class qname extends NGCCHandler {
     private String qvalue;
     protected final NGCCRuntimeEx $runtime;
@@ -150,7 +138,7 @@
             break;
         case 1:
             {
-                qvalue = $value;
+                qvalue = $runtime.collapse($value);
                 $_ngcc_current_state = 0;
             }
             break;
diff --git a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/simpleType.java b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/simpleType.java
index 6eb065e..ae9629c 100644
--- a/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/simpleType.java
+++ b/src/jdk.xml.bind/share/classes/com/sun/xml/internal/xsom/impl/parser/state/simpleType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,21 +25,16 @@
 
 /* this file is generated by RelaxNGCC */
 package com.sun.xml.internal.xsom.impl.parser.state;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.Attributes;
+
+import com.sun.xml.internal.xsom.*;
+import com.sun.xml.internal.xsom.impl.*;
 import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
+import com.sun.xml.internal.xsom.parser.*;
+import java.util.*;
 
-    import com.sun.xml.internal.xsom.*;
-    import com.sun.xml.internal.xsom.parser.*;
-    import com.sun.xml.internal.xsom.impl.*;
-    import com.sun.xml.internal.xsom.impl.parser.*;
-    import org.xml.sax.Locator;
-    import org.xml.sax.ContentHandler;
-    import org.xml.sax.helpers.*;
-    import java.util.*;
-    import java.math.BigInteger;
-
+import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
 
 
 class simpleType extends NGCCHandler {
@@ -373,7 +368,7 @@
         switch($_ngcc_current_state) {
         case 13:
             {
-                name = $value;
+                name = $runtime.collapse($value);
                 $_ngcc_current_state = 12;
             }
             break;
diff --git a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/TypeModeler.java b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/TypeModeler.java
index a5a0bc2..ca5bb2d 100644
--- a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/TypeModeler.java
+++ b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/TypeModeler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,12 +35,16 @@
 import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.ElementFilter;
 import java.util.Collection;
+import javax.lang.model.element.Element;
 
 /**
  * @author WS Development Team
  */
 final class TypeModeler {
 
+    private static final String REMOTE = "java.rmi.Remote";
+    private static final String REMOTE_EXCEPTION = "java.rmi.RemoteException";
+
     private TypeModeler() {
     }
 
@@ -160,4 +164,29 @@
         return false;
     }
 
+    public static boolean isRemoteException(ProcessingEnvironment env, TypeMirror typeMirror) {
+        Element element = env.getTypeUtils().asElement(typeMirror);
+        if (element.getKind() == ElementKind.CLASS) {
+            TypeElement te = (TypeElement) element;
+            TypeKind tk = typeMirror.getKind();
+            while (tk != TypeKind.NONE && !te.getQualifiedName().contentEquals(REMOTE_EXCEPTION)) {
+                TypeMirror superType = te.getSuperclass();
+                te = (TypeElement) env.getTypeUtils().asElement(superType);
+                tk = superType.getKind();
+            }
+            return tk != TypeKind.NONE;
+        }
+        return false;
+    }
+
+    public static boolean isRemote(/*@NotNull*/ TypeElement typeElement) {
+        for (TypeMirror superType : typeElement.getInterfaces()) {
+            TypeElement name = (TypeElement) ((DeclaredType) superType).asElement();
+            if (name.getQualifiedName().contentEquals(REMOTE)) {
+                return true;
+            }
+            isRemote(name);
+        }
+        return false;
+    }
 }
diff --git a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceAp.java b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceAp.java
index 233f0c3..b7515c6 100644
--- a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceAp.java
+++ b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceAp.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,13 +51,9 @@
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.PrintStream;
-import java.lang.reflect.Method;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Scanner;
 import java.util.Set;
 import java.util.logging.Level;
 
@@ -89,21 +85,20 @@
         "javax.xml.ws.WebServiceProvider",
         "javax.xml.ws.WebServiceRef"
 })
-@SupportedOptions({WebServiceAp.DO_NOT_OVERWRITE, WebServiceAp.IGNORE_NO_WEB_SERVICE_FOUND_WARNING})
+@SupportedOptions({WebServiceAp.DO_NOT_OVERWRITE, WebServiceAp.IGNORE_NO_WEB_SERVICE_FOUND_WARNING, WebServiceAp.VERBOSE})
 public class WebServiceAp extends AbstractProcessor implements ModelBuilder {
 
     private static final Logger LOGGER = Logger.getLogger(WebServiceAp.class);
 
     public static final String DO_NOT_OVERWRITE = "doNotOverWrite";
     public static final String IGNORE_NO_WEB_SERVICE_FOUND_WARNING = "ignoreNoWebServiceFoundWarning";
+    public static final String VERBOSE = "verbose";
 
     private WsgenOptions options;
     protected AnnotationProcessorContext context;
     private File sourceDir;
     private boolean doNotOverWrite;
     private boolean ignoreNoWebServiceFoundWarning = false;
-    private TypeElement remoteElement;
-    private TypeMirror remoteExceptionElement;
     private TypeMirror exceptionElement;
     private TypeMirror runtimeExceptionElement;
     private TypeElement defHolderElement;
@@ -126,8 +121,6 @@
     @Override
     public synchronized void init(ProcessingEnvironment processingEnv) {
         super.init(processingEnv);
-        remoteElement = processingEnv.getElementUtils().getTypeElement(Remote.class.getName());
-        remoteExceptionElement = processingEnv.getElementUtils().getTypeElement(RemoteException.class.getName()).asType();
         exceptionElement = processingEnv.getElementUtils().getTypeElement(Exception.class.getName()).asType();
         runtimeExceptionElement = processingEnv.getElementUtils().getTypeElement(RuntimeException.class.getName()).asType();
         defHolderElement = processingEnv.getElementUtils().getTypeElement(Holder.class.getName());
@@ -135,71 +128,14 @@
             options = new WsgenOptions();
 
             out = new PrintStream(new ByteArrayOutputStream());
-
             doNotOverWrite = getOption(DO_NOT_OVERWRITE);
             ignoreNoWebServiceFoundWarning = getOption(IGNORE_NO_WEB_SERVICE_FOUND_WARNING);
-
-            String classDir = parseArguments();
-            String property = System.getProperty("java.class.path");
-            options.classpath = classDir + File.pathSeparator + (property != null ? property : "");
+            options.verbose = getOption(VERBOSE);
             isCommandLineInvocation = true;
         }
         options.filer = processingEnv.getFiler();
     }
 
-    private String parseArguments() {
-        // let's try to parse JavacOptions
-
-        String classDir = null;
-        try {
-            ClassLoader cl = WebServiceAp.class.getClassLoader();
-            Class javacProcessingEnvironmentClass = Class.forName("com.sun.tools.javac.processing.JavacProcessingEnvironment", false, cl);
-            if (javacProcessingEnvironmentClass.isInstance(processingEnv)) {
-                Method getContextMethod = javacProcessingEnvironmentClass.getDeclaredMethod("getContext");
-                Object tmpContext = getContextMethod.invoke(processingEnv);
-                Class optionsClass = Class.forName("com.sun.tools.javac.util.Options", false, cl);
-                Class contextClass = Class.forName("com.sun.tools.javac.util.Context", false, cl);
-                Method instanceMethod = optionsClass.getDeclaredMethod("instance", new Class[]{contextClass});
-                Object tmpOptions = instanceMethod.invoke(null, tmpContext);
-                if (tmpOptions != null) {
-                    Method getMethod = optionsClass.getDeclaredMethod("get", new Class[]{String.class});
-                    Object result = getMethod.invoke(tmpOptions, "-s"); // todo: we have to check for -d also
-                    if (result != null) {
-                        classDir = (String) result;
-                    }
-                    this.options.verbose = getMethod.invoke(tmpOptions, "-verbose") != null;
-                }
-            }
-        } catch (Exception e) {
-            /// some Error was here - problems with reflection or security
-            processWarning(WebserviceapMessages.WEBSERVICEAP_PARSING_JAVAC_OPTIONS_ERROR());
-            report(e.getMessage());
-        }
-
-        if (classDir == null) { // some error within reflection block
-            String property = System.getProperty("sun.java.command");
-            if (property != null) {
-                Scanner scanner = new Scanner(property);
-                boolean sourceDirNext = false;
-                while (scanner.hasNext()) {
-                    String token = scanner.next();
-                    if (sourceDirNext) {
-                        classDir = token;
-                        sourceDirNext = false;
-                    } else if ("-verbose".equals(token)) {
-                        options.verbose = true;
-                    } else if ("-s".equals(token)) {
-                        sourceDirNext = true;
-                    }
-                }
-            }
-        }
-        if (classDir != null) {
-            sourceDir = new File(classDir);
-        }
-        return classDir;
-    }
-
     private boolean getOption(String key) {
         String value = processingEnv.getOptions().get(key);
         if (value != null) {
@@ -309,14 +245,14 @@
 
     @Override
     public boolean isRemote(TypeElement typeElement) {
-        return processingEnv.getTypeUtils().isSubtype(typeElement.asType(), remoteElement.asType());
+        return TypeModeler.isRemote(typeElement);
     }
 
     @Override
     public boolean isServiceException(TypeMirror typeMirror) {
         return processingEnv.getTypeUtils().isSubtype(typeMirror, exceptionElement)
                 && !processingEnv.getTypeUtils().isSubtype(typeMirror, runtimeExceptionElement)
-                && !processingEnv.getTypeUtils().isSubtype(typeMirror, remoteExceptionElement);
+                && !TypeModeler.isRemoteException(processingEnv, typeMirror);
     }
 
     @Override
diff --git a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceWrapperGenerator.java b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceWrapperGenerator.java
index 99742de..dd37c41 100644
--- a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceWrapperGenerator.java
+++ b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/processor/modeler/annotation/WebServiceWrapperGenerator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -171,11 +171,10 @@
     @SuppressWarnings("CallToThreadDumpStack")
     protected void doPostProcessWebService(WebService webService, TypeElement d) {
         if (cm != null) {
-            File sourceDir = builder.getSourceDir();
-            assert(sourceDir != null);
             WsgenOptions options = builder.getOptions();
+            assert options.filer != null;
             try {
-                CodeWriter cw = new FilerCodeWriter(sourceDir, options);
+                CodeWriter cw = new FilerCodeWriter(options);
                 if(options.verbose)
                     cw = new ProgressCodeWriter(cw, System.out);
                 cm.build(cw);
@@ -248,9 +247,7 @@
         }
         builder.log("requestWrapper: "+requestClassName);
 ///// fix for wsgen CR 6442344
-        File file = new File(DirectoryUtil.getOutputDirectoryFor(requestClassName, builder.getSourceDir()),
-                Names.stripQualifier(requestClassName) + GeneratorConstants.JAVA_SRC_SUFFIX.getValue());
-        builder.getOptions().addGeneratedFile(file);
+        addGeneratedFile(requestClassName);
 //////////
         boolean canOverwriteRequest = builder.canOverWriteClass(requestClassName);
         if (!canOverwriteRequest) {
@@ -282,9 +279,7 @@
                 builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RESPONSE_WRAPPER_BEAN_NAME_NOT_UNIQUE(
                         typeElement.getQualifiedName(), method.toString()));
             }
-            file = new File(DirectoryUtil.getOutputDirectoryFor(responseClassName, builder.getSourceDir()),
-                    Names.stripQualifier(responseClassName) + GeneratorConstants.JAVA_SRC_SUFFIX.getValue());
-            builder.getOptions().addGeneratedFile(file);
+            addGeneratedFile(responseClassName);
         }
         //ArrayList<MemberInfo> reqMembers = new ArrayList<MemberInfo>();
         //ArrayList<MemberInfo> resMembers = new ArrayList<MemberInfo>();
@@ -334,6 +329,12 @@
         return true;
     }
 
+    private void addGeneratedFile(String requestClassName) {
+        File file = new File(DirectoryUtil.getOutputDirectoryFor(requestClassName, builder.getSourceDir()),
+                Names.stripQualifier(requestClassName) + GeneratorConstants.JAVA_SRC_SUFFIX.getValue());
+        builder.getOptions().addGeneratedFile(file);
+    }
+
 //    private List<Annotation> collectJAXBAnnotations(Declaration decl) {
 //        List<Annotation> jaxbAnnotation = new ArrayList<Annotation>();
 //        for(Class jaxbClass : jaxbAnns) {
@@ -471,8 +472,11 @@
             seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
             return false;
         }
-        if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null)
+        if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) {
             return false;
+        }
+
+        addGeneratedFile(className);
 
         //write class comment - JAXWS warning
         JDocComment comment = cls.javadoc();
diff --git a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/resources/wscompile.properties b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/resources/wscompile.properties
index d89ac65..94c7c57 100644
--- a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/resources/wscompile.properties
+++ b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/resources/wscompile.properties
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,7 @@
 \  -J<javacOption>           pass this option to javac\n\
 \  -keep                     keep generated files\n\
 \  -p <pkg>                  specifies the target package\n\
+\  -m <name>                 generate module-info.java with given Java module name\n\
 \  -quiet                    suppress wsimport output\n\
 \  -s <directory>            specify where to place generated source files\n\
 \  -target <version>         generate code as per the given JAXWS spec version\n\
diff --git a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties
index 8d2adca..eedc7c2 100644
--- a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties
+++ b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties
@@ -26,4 +26,4 @@
 build-id=2.3.0-SNAPSHOT
 build-version=JAX-WS RI 2.3.0-SNAPSHOT
 major-version=2.3.0
-svn-revision=282759e2b822078de9ba78c743ed663541c16ead
+svn-revision=5c2c1fd2f2ab3b5c7cea25f79aa49e54cb84b7cc
diff --git a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/FilerCodeWriter.java b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/FilerCodeWriter.java
index ce2690d..10705de 100644
--- a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/FilerCodeWriter.java
+++ b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/FilerCodeWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,12 @@
 
 package com.sun.tools.internal.ws.wscompile;
 
+import com.sun.codemodel.internal.CodeWriter;
 import com.sun.codemodel.internal.JPackage;
 
 import javax.annotation.processing.Filer;
-import java.io.File;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.Writer;
 
 /**
@@ -37,18 +38,22 @@
  *
  * @author WS Development Team
  */
-public class FilerCodeWriter extends WSCodeWriter {
+public class FilerCodeWriter extends CodeWriter {
 
     /** The Filer used to create files. */
     private final Filer filer;
 
     private Writer w;
 
-    public FilerCodeWriter(File outDir, Options options) throws IOException {
-        super(outDir, options);
+    public FilerCodeWriter(Options options) throws IOException {
         this.filer = options.filer;
     }
 
+    @Override
+    public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
+        throw new UnsupportedOperationException("Not supported.");
+    }
+
     public Writer openSource(JPackage pkg, String fileName) throws IOException {
         String tmp = fileName.substring(0, fileName.length()-5);
         if (pkg.name() != null && ! "".equals(pkg.name())) {
@@ -61,7 +66,6 @@
 
 
     public void close() throws IOException {
-        super.close();
         if (w != null)
             w.close();
         w = null;
diff --git a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsgenTool.java b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsgenTool.java
index ebbaa2c..4f29dc6 100644
--- a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsgenTool.java
+++ b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsgenTool.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 package com.sun.tools.internal.ws.wscompile;
 
 import com.oracle.webservices.internal.api.databinding.WSDLResolver;
-import com.sun.istack.internal.tools.ParallelWorldClassLoader;
 import com.sun.tools.internal.ws.ToolVersion;
 import com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAp;
 import com.sun.tools.internal.ws.processor.modeler.wsdl.ConsoleErrorReporter;
@@ -54,11 +53,9 @@
 import javax.tools.JavaFileObject;
 import javax.tools.StandardJavaFileManager;
 import javax.tools.ToolProvider;
-import javax.xml.bind.annotation.XmlSeeAlso;
 import javax.xml.namespace.QName;
 import javax.xml.transform.Result;
 import javax.xml.transform.stream.StreamResult;
-import javax.xml.ws.EndpointReference;
 import javax.xml.ws.Holder;
 import java.io.BufferedOutputStream;
 import java.io.File;
@@ -137,18 +134,6 @@
 
     private final Container container;
 
-    /*
-     * To take care of JDK6-JDK6u3, where 2.1 API classes are not there
-     */
-    private static boolean useBootClasspath(Class clazz) {
-        try {
-            ParallelWorldClassLoader.toJarUrl(clazz.getResource('/' + clazz.getName().replace('.', '/') + ".class"));
-            return true;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
     /**
      *
      * @param endpoint
@@ -159,11 +144,12 @@
     public boolean buildModel(String endpoint, Listener listener) throws BadCommandLineException {
         final ErrorReceiverFilter errReceiver = new ErrorReceiverFilter(listener);
 
-        boolean bootCP = useBootClasspath(EndpointReference.class) || useBootClasspath(XmlSeeAlso.class);
-        List<String> args = new ArrayList<String>(6 + (bootCP ? 1 : 0) + (options.nocompile ? 1 : 0)
+        List<String> args = new ArrayList<String>(6 + (options.nocompile ? 1 : 0)
                 + (options.encoding != null ? 2 : 0));
+
         args.add("--add-modules");
         args.add("java.xml.ws");
+
         args.add("-d");
         args.add(options.destDir.getAbsolutePath());
         args.add("-classpath");
@@ -177,13 +163,6 @@
             args.add("-encoding");
             args.add(options.encoding);
         }
-        if (bootCP) {
-            args.add(new StringBuilder()
-                    .append("-Xbootclasspath/p:")
-                    .append(JavaCompilerHelper.getJarFile(EndpointReference.class))
-                    .append(File.pathSeparator)
-                    .append(JavaCompilerHelper.getJarFile(XmlSeeAlso.class)).toString());
-        }
         if (options.javacOptions != null) {
             args.addAll(options.getJavacOptions(args, listener));
         }
diff --git a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportOptions.java b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportOptions.java
index 6816f63..5327830 100644
--- a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportOptions.java
+++ b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportOptions.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -133,6 +133,11 @@
     public boolean useBaseResourceAndURLToLoadWSDL = false;
 
     /**
+     * Java module name in {@code module-info.java}.
+     */
+    private String javaModule = null;
+
+    /**
      * JAXB's {@link SchemaCompiler} to be used for handling the schema portion.
      * This object is also configured through options.
      */
@@ -219,6 +224,14 @@
     }
 
     /**
+     * Gets Java module name option.
+     * @return Java module name option or {@code null} if this option was not set.
+     */
+    public String getModuleName() {
+        return javaModule;
+    }
+
+     /**
      * Parses arguments and fill fields of this object.
      *
      * @exception BadCommandLineException
@@ -294,6 +307,9 @@
         } else if (args[i].equals("-p")) {
             defaultPackage = requireArgument("-p", args, ++i);
             return 2;
+        } else if (args[i].equals("-m")) {
+            javaModule = requireArgument("-m", args, ++i);
+            return 2;
         } else if (args[i].equals("-catalog")) {
             String catalog = requireArgument("-catalog", args, ++i);
             try {
diff --git a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportTool.java b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportTool.java
index a1b1854..3768118 100644
--- a/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportTool.java
+++ b/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/wscompile/WsimportTool.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,13 +47,10 @@
 import com.sun.tools.internal.xjc.util.NullStream;
 import com.sun.xml.internal.ws.api.server.Container;
 import com.sun.xml.internal.ws.util.ServiceFinder;
-import com.sun.istack.internal.tools.ParallelWorldClassLoader;
 import org.xml.sax.EntityResolver;
 import org.xml.sax.SAXParseException;
 
-import javax.xml.bind.JAXBPermission;
 import javax.xml.stream.*;
-import javax.xml.ws.EndpointContext;
 import java.io.*;
 import java.util.*;
 import java.text.MessageFormat;
@@ -66,6 +63,9 @@
  * @author Vivek Pandey
  */
 public class WsimportTool {
+    /** JAXWS module name. JAXWS dependency is mandatory in generated Java module. */
+    private static final String JAXWS_MODULE = "java.xml.ws";
+
     private static final String WSIMPORT = "wsimport";
     private final PrintStream out;
     private final Container container;
@@ -476,9 +476,13 @@
             }
         }
 
+        if (options.getModuleName() != null) {
+            options.getCodeModel()._prepareModuleInfo(options.getModuleName(), JAXWS_MODULE);
+        }
+
         CodeWriter cw;
         if (options.filer != null) {
-            cw = new FilerCodeWriter(options.sourceDir, options);
+            cw = new FilerCodeWriter(options);
         } else {
             cw = new WSCodeWriter(options.sourceDir, options);
         }
@@ -499,18 +503,6 @@
         this.options.entityResolver = resolver;
     }
 
-    /*
-     * To take care of JDK6-JDK6u3, where 2.1 API classes are not there
-     */
-    private static boolean useBootClasspath(Class clazz) {
-        try {
-            ParallelWorldClassLoader.toJarUrl(clazz.getResource('/'+clazz.getName().replace('.','/')+".class"));
-            return true;
-        } catch(Exception e) {
-            return false;
-        }
-    }
-
     protected boolean compileGeneratedClasses(ErrorReceiver receiver, WsimportListener listener){
         List<String> sourceFiles = new ArrayList<String>();
 
@@ -523,21 +515,15 @@
         if (sourceFiles.size() > 0) {
             String classDir = options.destDir.getAbsolutePath();
             String classpathString = createClasspathString();
-            boolean bootCP = useBootClasspath(EndpointContext.class) || useBootClasspath(JAXBPermission.class);
             List<String> args = new ArrayList<String>();
+
             args.add("--add-modules");
             args.add("java.xml.ws");
+
             args.add("-d");
             args.add(classDir);
             args.add("-classpath");
             args.add(classpathString);
-            //javac is not working in osgi as the url starts with a bundle
-            if (bootCP) {
-                args.add("-Xbootclasspath/p:"
-                        + JavaCompilerHelper.getJarFile(EndpointContext.class)
-                        + File.pathSeparator
-                        + JavaCompilerHelper.getJarFile(JAXBPermission.class));
-            }
 
             if (options.debug) {
                 args.add("-g");