8164479: Update JAX-WS RI integration to latest version (2.3.0-SNAPSHOT)

Reviewed-by: alanb, joehw, lancea, mchung
This commit is contained in:
Roman Grigoriadi 2016-11-15 23:43:38 +03:00 committed by Aleksei Efimov
parent 32f54b25b5
commit 2f39e1bd30
54 changed files with 1151 additions and 483 deletions

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,10 @@
package javax.activation; package javax.activation;
import java.io.*; 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 * The CommandInfo class is used by CommandMap implementations to
@ -84,8 +87,15 @@ public class CommandInfo {
/** /**
* Return the instantiated JavaBean component. * Return the instantiated JavaBean component.
* <p> * <p>
* Begin by instantiating the component with * If {@code java.beans.Beans} is visible then it's
* {@code Beans.instantiate()}. * {@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> * <p>
* If the bean implements the {@code javax.activation.CommandObject} * If the bean implements the {@code javax.activation.CommandObject}
* interface, call its {@code setCommandContext} method. * interface, call its {@code setCommandContext} method.
@ -102,7 +112,7 @@ public class CommandInfo {
* this method will check if it implements the * this method will check if it implements the
* java.io.Externalizable interface. If it does, the bean's * java.io.Externalizable interface. If it does, the bean's
* readExternal method will be called if an InputStream * 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 * @param dh The DataHandler that describes the data to be
* passed to the command. * passed to the command.
@ -116,7 +126,7 @@ public class CommandInfo {
Object new_bean = null; Object new_bean = null;
// try to instantiate the bean // 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 we got one and it is a CommandObject
if (new_bean != null) { if (new_bean != null) {
@ -135,4 +145,86 @@ public class CommandInfo {
return new_bean; 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;
}
}
} }

View file

@ -28,8 +28,6 @@
*/ */
module java.activation { module java.activation {
requires public java.datatransfer; requires public java.datatransfer;
// dependence on java.beans.Beans to be eliminated
requires java.desktop;
requires java.logging; requires java.logging;
exports javax.activation; exports javax.activation;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -41,7 +41,7 @@ public class Which {
/** /**
* Search the specified classloader for the given classname. * 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 classname the fully qualified name of the class to search for
* @param loader the classloader to search * @param loader the classloader to search
* @return the source location of the resource, or null if it wasn't found * @return the source location of the resource, or null if it wasn't found

View file

@ -450,8 +450,8 @@ public abstract class JAXBContext {
* in an empty map. * in an empty map.
* *
* @return a new instance of a {@code JAXBContext} * @return a new instance of a {@code JAXBContext}
* @throws JAXBException * @throws JAXBException if an error was encountered while creating the
* if an error was encountered while creating the {@code JAXBContext} such as * {@code JAXBContext} such as
* <ol> * <ol>
* <li>failure to locate either ObjectFactory.class or jaxb.index in the packages</li> * <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> * <li>an ambiguity among global elements contained in the contextPath</li>

View file

@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!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. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it This code is free software; you can redistribute it and/or modify it
@ -47,7 +47,7 @@
<h2>Package Specification</h2> <h2>Package Specification</h2>
<ul> <ul>
<li><a href="http://java.sun.com/xml/downloads/jaxb.html">JAXB <li><a href="https://jaxb.java.net/">JAXB
Specification</a> Specification</a>
</ul> </ul>
@ -61,7 +61,7 @@
</ul> </ul>
<!-- Put @see and @since tags down here. --> <!-- Put @see and @since tags down here. -->
@since 1.6, JAXB 2.0 @since JAXB 2.0
</body> </body>
</html> </html>

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,9 +47,7 @@ import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource; import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema; import javax.xml.validation.Schema;
import java.io.File; import java.io.*;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
/** /**
@ -178,16 +176,8 @@ public abstract class AbstractUnmarshallerImpl implements Unmarshaller
} }
try { try {
// copied from JAXP return unmarshal(new BufferedInputStream(new FileInputStream(f)));
String path = f.getAbsolutePath(); } catch( FileNotFoundException e ) {
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 ) {
throw new IllegalArgumentException(e.getMessage()); throw new IllegalArgumentException(e.getMessage());
} }
} }

View file

@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!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. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it This code is free software; you can redistribute it and/or modify it
@ -43,7 +43,7 @@
<h2>Package Specification</h2> <h2>Package Specification</h2>
<ul> <ul>
<li><a href="http://java.sun.com/xml/downloads/jaxb.html">JAXB <li><a href="https://jaxb.java.net/">JAXB
Specification</a> Specification</a>
</ul> </ul>
@ -52,7 +52,7 @@
For overviews, tutorials, examples, guides, and tool documentation, For overviews, tutorials, examples, guides, and tool documentation,
please see: please see:
<ul> <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> Website</a>
</ul> </ul>

View file

@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!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. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it This code is free software; you can redistribute it and/or modify it
@ -44,7 +44,7 @@
<h2>Package Specification</h2> <h2>Package Specification</h2>
<ul> <ul>
<li><a href="http://java.sun.com/xml/downloads/jaxb.html">JAXB <li><a href="https://jaxb.java.net/">JAXB
Specification</a> Specification</a>
</ul> </ul>
@ -53,7 +53,7 @@
For overviews, tutorials, examples, guides, and tool documentation, For overviews, tutorials, examples, guides, and tool documentation,
please see: please see:
<ul> <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> Website</a>
</ul> </ul>

View file

@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!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. DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it This code is free software; you can redistribute it and/or modify it
@ -38,7 +38,7 @@
<h2>Package Specification</h2> <h2>Package Specification</h2>
<ul> <ul>
<li><a href="http://java.sun.com/xml/downloads/jaxb.html">JAXB <li><a href="https://jaxb.java.net/">JAXB
Specification</a> Specification</a>
</ul> </ul>
@ -47,7 +47,7 @@
For overviews, tutorials, examples, guides, and tool documentation, For overviews, tutorials, examples, guides, and tool documentation,
please see: please see:
<ul> <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> Website</a>
</ul> </ul>

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -139,8 +139,9 @@ public class XmlDataContentHandler implements DataContentHandler {
} }
private boolean isXml(ContentType ct) { private boolean isXml(ContentType ct) {
return ct.getSubType().equals("xml") && final String primaryType = ct.getPrimaryType();
(ct.getPrimaryType().equals("text") || ct.getPrimaryType().equals("application")); return ct.getSubType().equalsIgnoreCase("xml") &&
(primaryType.equalsIgnoreCase("text") || primaryType.equalsIgnoreCase("application"));
} }
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -66,7 +66,6 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType; import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.rmi.RemoteException;
import java.security.AccessController; import java.security.AccessController;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
@ -115,7 +114,7 @@ public class RuntimeModeler {
public static final String SERVICE = "Service"; public static final String SERVICE = "Service";
public static final String PORT = "Port"; public static final String PORT = "Port";
public static final Class HOLDER_CLASS = Holder.class; 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<RuntimeException> RUNTIME_EXCEPTION_CLASS = RuntimeException.class;
public static final Class<Exception> EXCEPTION_CLASS = Exception.class; public static final Class<Exception> EXCEPTION_CLASS = Exception.class;
public static final String DecapitalizeExceptionBeanProperties = "com.sun.xml.internal.ws.api.model.DecapitalizeExceptionBeanProperties"; public static final String DecapitalizeExceptionBeanProperties = "com.sun.xml.internal.ws.api.model.DecapitalizeExceptionBeanProperties";
@ -586,7 +585,7 @@ public class RuntimeModeler {
*/ */
private boolean isServiceException(Class<?> exception) { private boolean isServiceException(Class<?> exception) {
return EXCEPTION_CLASS.isAssignableFrom(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 @@ public class RuntimeModeler {
if(p == null) if(p == null)
reqRpcParams.put(reqRpcParams.size()+10000, param); reqRpcParams.put(reqRpcParams.size()+10000, param);
else else
reqRpcParams.put(p.getIndex(), param); reqRpcParams.put(param.getIndex(), param);
} }
if(!param.isIN()){ if(!param.isIN()){
@ -1181,7 +1180,7 @@ public class RuntimeModeler {
if(p == null) if(p == null)
resRpcParams.put(resRpcParams.size()+10000, param); resRpcParams.put(resRpcParams.size()+10000, param);
else else
resRpcParams.put(p.getIndex(), param); resRpcParams.put(param.getIndex(), param);
} }
}else{ }else{
javaMethod.addParameter(param); javaMethod.addParameter(param);
@ -1210,7 +1209,7 @@ public class RuntimeModeler {
//Exclude RuntimeException, RemoteException and Error etc //Exclude RuntimeException, RemoteException and Error etc
if (!EXCEPTION_CLASS.isAssignableFrom(exception)) if (!EXCEPTION_CLASS.isAssignableFrom(exception))
continue; continue;
if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || REMOTE_EXCEPTION_CLASS.isAssignableFrom(exception)) if (RUNTIME_EXCEPTION_CLASS.isAssignableFrom(exception) || isRemoteException(exception))
continue; continue;
if (getAnnotation(exception, javax.xml.bind.annotation.XmlTransient.class) != null) if (getAnnotation(exception, javax.xml.bind.annotation.XmlTransient.class) != null)
continue; continue;
@ -1646,6 +1645,21 @@ public class RuntimeModeler {
return null; 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) { private static Boolean getBooleanSystemProperty(final String prop) {
return AccessController.doPrivileged( return AccessController.doPrivileged(
new java.security.PrivilegedAction<Boolean>() { new java.security.PrivilegedAction<Boolean>() {

View file

@ -26,4 +26,4 @@
build-id=2.3.0-SNAPSHOT build-id=2.3.0-SNAPSHOT
build-version=JAX-WS RI 2.3.0-SNAPSHOT build-version=JAX-WS RI 2.3.0-SNAPSHOT
major-version=2.3.0 major-version=2.3.0
svn-revision=282759e2b822078de9ba78c743ed663541c16ead svn-revision=5c2c1fd2f2ab3b5c7cea25f79aa49e54cb84b7cc

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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; package com.sun.xml.internal.ws.util.xml;
import com.sun.istack.internal.Nullable; 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.server.ServerRtException;
import com.sun.xml.internal.ws.util.ByteArrayBuffer; import com.sun.xml.internal.ws.util.ByteArrayBuffer;
import org.w3c.dom.Attr; import java.io.IOException;
import org.w3c.dom.Element; import java.io.InputStream;
import org.w3c.dom.EntityReference; import java.io.OutputStreamWriter;
import org.w3c.dom.Node; import java.io.Writer;
import org.w3c.dom.NodeList; import java.lang.reflect.Method;
import org.w3c.dom.Text; import java.net.URL;
import org.xml.sax.*; 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.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.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
@ -58,20 +67,18 @@ import javax.xml.validation.SchemaFactory;
import javax.xml.ws.WebServiceException; import javax.xml.ws.WebServiceException;
import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactory;
import javax.xml.xpath.XPathFactoryConfigurationException; import javax.xml.xpath.XPathFactoryConfigurationException;
import java.io.IOException; import org.w3c.dom.Attr;
import java.io.InputStream; import org.w3c.dom.Element;
import java.io.OutputStreamWriter; import org.w3c.dom.EntityReference;
import java.io.Writer; import org.w3c.dom.Node;
import java.net.URL; import org.w3c.dom.NodeList;
import java.security.AccessController; import org.w3c.dom.Text;
import java.security.PrivilegedAction; import org.xml.sax.EntityResolver;
import java.util.ArrayList; import org.xml.sax.ErrorHandler;
import java.util.Enumeration; import org.xml.sax.InputSource;
import java.util.Iterator; import org.xml.sax.SAXException;
import java.util.List; import org.xml.sax.SAXParseException;
import java.util.StringTokenizer; import org.xml.sax.XMLReader;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* @author WS Development Team * @author WS Development Team
@ -282,76 +289,64 @@ public class XmlUtil {
* Gets an EntityResolver using XML catalog * Gets an EntityResolver using XML catalog
*/ */
public static EntityResolver createEntityResolver(@Nullable URL catalogUrl) { public static EntityResolver createEntityResolver(@Nullable URL catalogUrl) {
// set up a manager ArrayList<URL> urlsArray = new ArrayList<URL>();
CatalogManager manager = new CatalogManager(); EntityResolver er;
manager.setIgnoreMissingProperties(true); if (catalogUrl != null) {
// Using static catalog may result in to sharing of the catalog by multiple apps running in a container urlsArray.add(catalogUrl);
manager.setUseStaticCatalog(false); }
Catalog catalog = manager.getCatalog();
try { try {
if (catalogUrl != null) { er = createCatalogResolver(urlsArray);
catalog.parseCatalog(catalogUrl); } catch (Exception e) {
}
} catch (IOException e) {
throw new ServerRtException("server.rt.err",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 * Gets a default EntityResolver for catalog at META-INF/jaxws-catalog.xml
*/ */
public static EntityResolver createDefaultCatalogResolver() { public static EntityResolver createDefaultCatalogResolver() {
EntityResolver er;
// 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();
try { try {
/**
* Gets a URLs for catalog defined at META-INF/jaxws-catalog.xml
*/
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Enumeration<URL> catalogEnum;
if (cl == null) { if (cl == null) {
catalogEnum = ClassLoader.getSystemResources("META-INF/jax-ws-catalog.xml"); catalogEnum = ClassLoader.getSystemResources("META-INF/jax-ws-catalog.xml");
} else { } else {
catalogEnum = cl.getResources("META-INF/jax-ws-catalog.xml"); catalogEnum = cl.getResources("META-INF/jax-ws-catalog.xml");
} }
er = createCatalogResolver(Collections.list(catalogEnum));
while(catalogEnum.hasMoreElements()) { } catch (Exception e) {
URL url = catalogEnum.nextElement();
catalog.parseCatalog(url);
}
} catch (IOException e) {
throw new WebServiceException(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 * Instantiate catalog resolver using new catalog API (javax.xml.catalog.*)
* useStaticCatalog is false. * added in JDK9. Usage of new API removes dependency on internal API
* This returns a CatalogResolver that uses the catalog passed as parameter. * (com.sun.org.apache.xml.internal) for modular runtime.
* @param catalog
* @return CatalogResolver
*/ */
private static CatalogResolver workaroundCatalogResolver(final Catalog catalog) { private static EntityResolver createCatalogResolver(ArrayList<URL> urls) throws Exception {
// set up a manager // Prepare array of catalog paths
CatalogManager manager = new CatalogManager() { String[] paths = urls.stream()
@Override .map(u -> u.toExternalForm())
public Catalog getCatalog() { .toArray(c -> new String[c]);
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);
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. * {@link ErrorHandler} that always treat the error as fatal.
*/ */

View file

@ -35,7 +35,6 @@ module java.xml.ws {
requires java.desktop; requires java.desktop;
requires java.logging; requires java.logging;
requires java.management; requires java.management;
requires java.rmi;
requires jdk.httpserver; requires jdk.httpserver;
uses javax.xml.ws.spi.Provider; uses javax.xml.ws.spi.Provider;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -39,7 +39,6 @@ import java.util.Map;
import com.sun.codemodel.internal.writer.FileCodeWriter; import com.sun.codemodel.internal.writer.FileCodeWriter;
import com.sun.codemodel.internal.writer.ProgressCodeWriter; import com.sun.codemodel.internal.writer.ProgressCodeWriter;
/** /**
* Root of the code DOM. * Root of the code DOM.
* *
@ -80,10 +79,13 @@ import com.sun.codemodel.internal.writer.ProgressCodeWriter;
public final class JCodeModel { public final class JCodeModel {
/** The packages that this JCodeWriter contains. */ /** 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. */ /** 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. */ /** Obtains a reference to the special "null" type. */
@ -121,7 +123,7 @@ public final class JCodeModel {
public JCodeModel() {} 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 * @param name
* Name of the package. Use "" to indicate the root package. * Name of the package. Use "" to indicate the root package.
@ -137,6 +139,50 @@ public final class JCodeModel {
return p; 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() { public final JPackage rootPackage() {
return _package(""); return _package("");
} }
@ -292,8 +338,12 @@ public final class JCodeModel {
public void build( CodeWriter source, CodeWriter resource ) throws IOException { public void build( CodeWriter source, CodeWriter resource ) throws IOException {
JPackage[] pkgs = packages.values().toArray(new JPackage[packages.size()]); JPackage[] pkgs = packages.values().toArray(new JPackage[packages.size()]);
// avoid concurrent modification exception // avoid concurrent modification exception
for( JPackage pkg : pkgs ) for( JPackage pkg : pkgs ) {
pkg.build(source,resource); pkg.build(source,resource);
}
if (module != null) {
module.build(source);
}
source.close(); source.close();
resource.close(); resource.close();
} }

View file

@ -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;
}
}

View file

@ -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();
}
}

View file

@ -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;
}
}

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -334,6 +334,15 @@ public final class JPackage implements JDeclaration, JGenerable, JClassContainer
return classes.values().iterator(); return classes.values().iterator();
} }
/**
* 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 * Checks if a given name is already defined as a class/interface
*/ */

View file

@ -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;
}
}

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -50,7 +50,7 @@ public class FileCodeWriter extends CodeWriter {
private final boolean readOnly; private final boolean readOnly;
/** Files that shall be marked as read only. */ /** 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 { public FileCodeWriter( File target ) throws IOException {
this(target,false); this(target,false);
@ -72,13 +72,14 @@ public class FileCodeWriter extends CodeWriter {
throw new IOException(target + ": non-existent directory"); throw new IOException(target + ": non-existent directory");
} }
@Override
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
return new FileOutputStream(getFile(pkg,fileName)); return new FileOutputStream(getFile(pkg,fileName));
} }
protected File getFile(JPackage pkg, String fileName ) throws IOException { protected File getFile(JPackage pkg, String fileName ) throws IOException {
File dir; File dir;
if(pkg.isUnnamed()) if(pkg == null || pkg.isUnnamed())
dir = target; dir = target;
else else
dir = new File(target, toDirName(pkg)); dir = new File(target, toDirName(pkg));
@ -97,6 +98,7 @@ public class FileCodeWriter extends CodeWriter {
return fn; return fn;
} }
@Override
public void close() throws IOException { public void close() throws IOException {
// mark files as read-onnly if necessary // mark files as read-onnly if necessary
for (File f : readonlyFiles) for (File f : readonlyFiles)

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -44,14 +44,17 @@ public class FilterCodeWriter extends CodeWriter {
this.core = core; this.core = core;
} }
@Override
public OutputStream openBinary( JPackage pkg, String fileName ) throws IOException { public OutputStream openBinary( JPackage pkg, String fileName ) throws IOException {
return core.openBinary(pkg, fileName); return core.openBinary(pkg, fileName);
} }
@Override
public Writer openSource( JPackage pkg, String fileName ) throws IOException { public Writer openSource( JPackage pkg, String fileName ) throws IOException {
return core.openSource(pkg, fileName); return core.openSource(pkg, fileName);
} }
@Override
public void close() throws IOException { public void close() throws IOException {
core.close(); core.close();
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -51,18 +51,21 @@ public class ProgressCodeWriter extends FilterCodeWriter {
private final PrintStream progress; private final PrintStream progress;
@Override
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
report(pkg, fileName); report(pkg, fileName);
return super.openBinary(pkg,fileName); return super.openBinary(pkg,fileName);
} }
@Override
public Writer openSource(JPackage pkg, String fileName) throws IOException { public Writer openSource(JPackage pkg, String fileName) throws IOException {
report(pkg, fileName); report(pkg, fileName);
return super.openSource(pkg,fileName); return super.openSource(pkg,fileName);
} }
private void report(JPackage pkg, String fileName) { private void report(JPackage pkg, String fileName) {
if(pkg.isUnnamed()) progress.println(fileName); if(pkg == null || pkg.isUnnamed())
progress.println(fileName);
else else
progress.println( progress.println(
pkg.name().replace('.',File.separatorChar) pkg.name().replace('.',File.separatorChar)

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -62,6 +62,7 @@ public class PrologCodeWriter extends FilterCodeWriter {
} }
@Override
public Writer openSource(JPackage pkg, String fileName) throws IOException { public Writer openSource(JPackage pkg, String fileName) throws IOException {
Writer w = super.openSource(pkg,fileName); Writer w = super.openSource(pkg,fileName);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -55,21 +55,24 @@ public class SingleStreamCodeWriter extends CodeWriter {
out = new PrintStream(os); out = new PrintStream(os);
} }
@Override
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
String pkgName = pkg.name(); final String name = pkg != null && pkg.name().length() > 0
if(pkgName.length()!=0) pkgName += '.'; ? pkg.name() + '.' + fileName : fileName;
out.println( out.println(
"-----------------------------------" + pkgName+fileName + "-----------------------------------" + name +
"-----------------------------------"); "-----------------------------------");
return new FilterOutputStream(out) { return new FilterOutputStream(out) {
@Override
public void close() { public void close() {
// don't let this stream close // don't let this stream close
} }
}; };
} }
@Override
public void close() throws IOException { public void close() throws IOException {
out.close(); out.close();
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -49,6 +49,7 @@ public class ZipCodeWriter extends CodeWriter {
zip = new ZipOutputStream(target); zip = new ZipOutputStream(target);
// nullify the close method. // nullify the close method.
filter = new FilterOutputStream(zip){ filter = new FilterOutputStream(zip){
@Override
public void close() {} public void close() {}
}; };
} }
@ -57,10 +58,9 @@ public class ZipCodeWriter extends CodeWriter {
private final OutputStream filter; private final OutputStream filter;
@Override
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
String name = fileName; final String name = pkg == null || pkg.isUnnamed() ? fileName : toDirName(pkg)+fileName;
if(!pkg.isUnnamed()) name = toDirName(pkg)+name;
zip.putNextEntry(new ZipEntry(name)); zip.putNextEntry(new ZipEntry(name));
return filter; return filter;
} }
@ -70,6 +70,7 @@ public class ZipCodeWriter extends CodeWriter {
return pkg.name().replace('.','/')+'/'; return pkg.name().replace('.','/')+'/';
} }
@Override
public void close() throws IOException { public void close() throws IOException {
zip.close(); zip.close();
} }

View file

@ -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. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -59,6 +59,7 @@ Options:\n\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ If a directory is given, **/*.xjb is searched\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ If a directory is given, **/*.xjb is searched\n\
\ \ -d <dir> : generated files will go into this directory\n\ \ \ -d <dir> : generated files will go into this directory\n\
\ \ -p <pkg> : specifies the target package\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\ \ \ -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\ \ \ -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\ \ \ -classpath <arg> : specify where to find user class files\n\
@ -120,6 +121,9 @@ Driver.MissingProxyPort = \
Driver.ILLEGAL_TARGET_VERSION = \ Driver.ILLEGAL_TARGET_VERSION = \
"{0}" is not a valid target version. "2.0" and "2.1" are supported. "{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). # Not concatenated with any other string (written on a separate line).
Driver.MISSING_PROXYFILE = \ Driver.MISSING_PROXYFILE = \

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -79,6 +79,9 @@ public class Messages
// static final String MISSING_COMPATIBILITY_OPERAND = // 0 args // static final String MISSING_COMPATIBILITY_OPERAND = // 0 args
// "Driver.MissingCompatibilityOperand"; // "Driver.MissingCompatibilityOperand";
static final String INVALID_JAVA_MODULE_NAME = // 1 arg
"Driver.INVALID_JAVA_MODULE_NAME";
static final String MISSING_PROXY = // 0 args static final String MISSING_PROXY = // 0 args
"Driver.MISSING_PROXY"; "Driver.MISSING_PROXY";

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,21 @@
package com.sun.tools.internal.xjc; 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.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -33,8 +48,12 @@ import java.io.InputStreamReader;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -43,33 +62,15 @@ import java.util.Date;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import java.util.Set; 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.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.xml.sax.EntityResolver; import javax.xml.catalog.CatalogFeatures;
import org.xml.sax.InputSource; import javax.xml.catalog.CatalogFeatures.Feature;
import javax.xml.catalog.CatalogManager;
/** /**
* Global options. * Global options.
@ -263,6 +264,11 @@ public class Options
*/ */
private Plugin nameConverterOwner = null; 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}. * Gets the active {@link FieldRendererFactory} that shall be used to build {@link Model}.
* *
@ -464,6 +470,13 @@ public class Options
classpaths.toArray(new URL[classpaths.size()]),parent); 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 * Parses an option {@code args[i]} and return
@ -509,6 +522,10 @@ public class Options
} }
return 2; return 2;
} }
if (args[i].equals("-m")) {
javaModule = requireArgument("-m", args, ++i);
return 2;
}
if (args[i].equals("-debug")) { if (args[i].equals("-debug")) {
debugMode = true; debugMode = true;
verbose = true; verbose = true;
@ -622,9 +639,7 @@ public class Options
return 2; return 2;
} }
if( args[i].equals("-catalog") ) { if( args[i].equals("-catalog") ) {
// use Sun's "XML Entity and URI Resolvers" by Norman Walsh // use javax.xml.catalog to resolve external entities.
// to resolve external entities.
// http://www.sun.com/xml/developers/resolver/
File catalogFile = new File(requireArgument("-catalog",args,++i)); File catalogFile = new File(requireArgument("-catalog",args,++i));
try { try {
@ -735,7 +750,7 @@ public class Options
* and add them as {@link InputSource} to the specified list. * and add them as {@link InputSource} to the specified list.
* *
* @param suffix * @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. * and find all files that have the given suffix.
*/ */
private void addFile(String name, List<InputSource> target, String suffix) throws BadCommandLineException { private void addFile(String name, List<InputSource> target, String suffix) throws BadCommandLineException {
@ -762,16 +777,27 @@ public class Options
* Adds a new catalog file. * Adds a new catalog file.
*/ */
public void addCatalog(File catalogFile) throws IOException { public void addCatalog(File catalogFile) throws IOException {
if(entityResolver==null) { String newUrl = catalogFile.getPath();
final CatalogManager staticManager = CatalogManager.getStaticManager(); if (!catalogUrls.contains(newUrl)) {
// hack to force initialization so catalog manager system properties take effect catalogUrls.add(newUrl);
staticManager.getVerbosity(); }
staticManager.setIgnoreMissingProperties(true); try {
entityResolver = new CatalogResolver(true); entityResolver = CatalogManager.catalogResolver(catalogFeatures,
catalogUrls.toArray(new String[0]));
} catch (Exception ex) {
entityResolver = null;
} }
((CatalogResolver)entityResolver).getCatalog().parseCatalog(catalogFile.getPath());
} }
// 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. * Parses arguments and fill fields of this object.
* *

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -52,23 +52,42 @@ final class ProgressCodeWriter extends FilterCodeWriter {
private final XJCListener progress; private final XJCListener progress;
@Override
public Writer openSource(JPackage pkg, String fileName) throws IOException { public Writer openSource(JPackage pkg, String fileName) throws IOException {
report(pkg,fileName); report(pkg,fileName);
return super.openSource(pkg, fileName); return super.openSource(pkg, fileName);
} }
@Override
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException { public OutputStream openBinary(JPackage pkg, String fileName) throws IOException {
report(pkg,fileName); report(pkg,fileName);
return super.openBinary(pkg,fileName); return super.openBinary(pkg,fileName);
} }
private void report(JPackage pkg, String fileName) { /**
String name = pkg.name().replace('.', File.separatorChar); * Report progress to {@link XJCListener}.
if(name.length()!=0) name += File.separatorChar; * @param pkg The package of file being written. Value of {@code null} means that file has no package.
name += fileName; * @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()) if(progress.isCanceled())
throw new AbortException(); throw new AbortException();
progress.generatedFile(name,current++,totalFileCount); progress.generatedFile(fileNameOut, current++, totalFileCount);
} }
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -108,6 +108,9 @@ import com.sun.tools.internal.xjc.model.CReferencePropertyInfo;
*/ */
public final class BeanGenerator implements Outline { 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. */ /** Simplifies class/interface creation and collision detection. */
private final CodeModelClassFactory codeModelClassFactory; private final CodeModelClassFactory codeModelClassFactory;
private final ErrorReceiver errorReceiver; private final ErrorReceiver errorReceiver;
@ -254,6 +257,10 @@ public final class BeanGenerator implements Outline {
getPackageContext(ei._package()).objectFactoryGenerator().populate(ei); getPackageContext(ei._package()).objectFactoryGenerator().populate(ei);
} }
if (model.options.getModuleName() != null) {
codeModel._prepareModuleInfo(model.options.getModuleName(), JAXB_PACKAGE);
}
if (model.options.debugMode) { if (model.options.debugMode) {
generateClassList(); generateClassList();
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -229,8 +229,12 @@ abstract class ObjectFactoryGeneratorImpl extends ObjectFactoryGenerator {
m.javadoc() m.javadoc()
.append("Create an instance of ") .append("Create an instance of ")
.append(exposedElementType) .append(exposedElementType);
.append("}"); 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); XmlElementDeclWriter xemw = m.annotate2(XmlElementDeclWriter.class);
xemw.namespace(namespaceURI).name(localPart); xemw.namespace(namespaceURI).name(localPart);

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -219,7 +219,7 @@ public abstract class CBuiltinLeafInfo implements CNonElement, BuiltinLeafInfo<N
* do not modify the returned array. * do not modify the returned array.
*/ */
public final QName[] getTypeNames() { public final QName[] getTypeNames() {
return typeNames; return typeNames.clone();
} }
/** /**

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -58,7 +58,7 @@ public class Constructor
{ {
// Since Constructor is typically built when there is no FieldItem // Since Constructor is typically built when there is no FieldItem
// nor FieldUse, we need to rely on Strings. // 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. */ /** array of field names to be initialized. */
public final String[] fields; public final String[] fields;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -66,13 +66,13 @@ public final class BIInterface
* Gets the names of interfaces/classes that implement * Gets the names of interfaces/classes that implement
* this interface. * this interface.
*/ */
public String[] members() { return members; } public String[] members() { return members.clone(); }
private final String[] fields; private final String[] fields;
/** Gets the names of fields in this interface. */ /** 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. */ /** Gets the location where this declaration is declared. */

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -436,19 +436,18 @@ public class NGCCRuntimeEx extends NGCCRuntime implements PatcherManager {
currentContext = currentContext.previous; currentContext = currentContext.previous;
} }
// //
// //
// Utility functions // Utility functions
// //
// //
/**
/** Parses UName under the given context. */ * Parses UName under the given context.
public UName parseUName( String qname ) throws SAXException { * @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(':'); int idx = qname.indexOf(':');
if(idx<0) { if(idx<0) {
String uri = resolveNamespacePrefix(""); String uri = resolveNamespacePrefix("");
@ -472,6 +471,91 @@ public class NGCCRuntimeEx extends NGCCRuntime implements PatcherManager {
} }
} }
/**
* 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) { public boolean parseBoolean(String v) {
if(v==null) return false; if(v==null) return false;
v=v.trim(); v=v.trim();

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,20 +25,14 @@
/* this file is generated by RelaxNGCC */ /* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state; 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.impl.*;
import com.sun.xml.internal.xsom.parser.*; import com.sun.xml.internal.xsom.impl.parser.*;
import com.sun.xml.internal.xsom.impl.*; import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator; import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler; import org.xml.sax.Locator;
import org.xml.sax.helpers.*; import org.xml.sax.SAXException;
import java.util.*;
import java.math.BigInteger;
@ -458,7 +452,7 @@ class attributeDeclBody extends NGCCHandler {
break; break;
case 11: case 11:
{ {
name = $value; name = $runtime.collapse($value);
$_ngcc_current_state = 10; $_ngcc_current_state = 10;
} }
break; break;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,20 +25,14 @@
/* this file is generated by RelaxNGCC */ /* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state; 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.impl.*;
import com.sun.xml.internal.xsom.parser.*; import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.impl.*; import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator; import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler; import org.xml.sax.Locator;
import org.xml.sax.helpers.*; import org.xml.sax.SAXException;
import java.util.*;
import java.math.BigInteger;
@ -401,7 +395,7 @@ class attributeGroupDecl extends NGCCHandler {
break; break;
case 12: case 12:
{ {
name = $value; name = $runtime.collapse($value);
$_ngcc_current_state = 11; $_ngcc_current_state = 11;
} }
break; break;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,21 +25,16 @@
/* this file is generated by RelaxNGCC */ /* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state; 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 org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx; import org.xml.sax.Locator;
import org.xml.sax.SAXException;
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 complexType extends NGCCHandler { class complexType extends NGCCHandler {
@ -1683,7 +1678,7 @@ class complexType extends NGCCHandler {
break; break;
case 70: case 70:
{ {
name = $value; name = $runtime.collapse($value);
$_ngcc_current_state = 69; $_ngcc_current_state = 69;
} }
break; break;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,21 +25,15 @@
/* this file is generated by RelaxNGCC */ /* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state; 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 org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx; import org.xml.sax.Locator;
import org.xml.sax.SAXException;
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 elementDeclBody extends NGCCHandler { class elementDeclBody extends NGCCHandler {
@ -813,7 +807,7 @@ class elementDeclBody extends NGCCHandler {
break; break;
case 22: case 22:
{ {
name = $value; name = $runtime.collapse($value);
$_ngcc_current_state = 21; $_ngcc_current_state = 21;
} }
break; break;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,20 +25,14 @@
/* this file is generated by RelaxNGCC */ /* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state; 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.impl.*;
import com.sun.xml.internal.xsom.parser.*; import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.impl.*; import com.sun.xml.internal.xsom.parser.*;
import com.sun.xml.internal.xsom.impl.parser.*;
import org.xml.sax.Locator; import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler; import org.xml.sax.Locator;
import org.xml.sax.helpers.*; import org.xml.sax.SAXException;
import java.util.*;
import java.math.BigInteger;
@ -403,7 +397,7 @@ class group extends NGCCHandler {
break; break;
case 9: case 9:
{ {
name = $value; name = $runtime.collapse($value);
$_ngcc_current_state = 8; $_ngcc_current_state = 8;
} }
break; break;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,21 +25,15 @@
/* this file is generated by RelaxNGCC */ /* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state; 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 org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx; import org.xml.sax.SAXException;
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 identityConstraint extends NGCCHandler { class identityConstraint extends NGCCHandler {
@ -471,7 +465,7 @@ class identityConstraint extends NGCCHandler {
switch($_ngcc_current_state) { switch($_ngcc_current_state) {
case 15: case 15:
{ {
name = $value; name = $runtime.collapse($value);
$_ngcc_current_state = 14; $_ngcc_current_state = 14;
} }
break; break;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,20 +25,15 @@
/* this file is generated by RelaxNGCC */ /* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state; 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.*;
import com.sun.xml.internal.xsom.parser.*; import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.*; import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx;
import com.sun.xml.internal.xsom.impl.parser.*; import com.sun.xml.internal.xsom.parser.*;
import org.xml.sax.Locator;
import org.xml.sax.ContentHandler; import org.xml.sax.Attributes;
import org.xml.sax.helpers.*; import org.xml.sax.Locator;
import java.util.*; import org.xml.sax.SAXException;
import java.math.BigInteger;
@ -435,7 +430,7 @@ class notation extends NGCCHandler {
break; break;
case 13: case 13:
{ {
name = $value; name = $runtime.collapse($value);
$_ngcc_current_state = 12; $_ngcc_current_state = 12;
} }
break; break;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,23 +25,11 @@
/* this file is generated by RelaxNGCC */ /* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state; package com.sun.xml.internal.xsom.impl.parser.state;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx; 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 { class qname extends NGCCHandler {
private String qvalue; private String qvalue;
protected final NGCCRuntimeEx $runtime; protected final NGCCRuntimeEx $runtime;
@ -150,7 +138,7 @@ class qname extends NGCCHandler {
break; break;
case 1: case 1:
{ {
qvalue = $value; qvalue = $runtime.collapse($value);
$_ngcc_current_state = 0; $_ngcc_current_state = 0;
} }
break; break;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,21 +25,16 @@
/* this file is generated by RelaxNGCC */ /* this file is generated by RelaxNGCC */
package com.sun.xml.internal.xsom.impl.parser.state; 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 org.xml.sax.Attributes; import com.sun.xml.internal.xsom.impl.*;
import com.sun.xml.internal.xsom.impl.parser.NGCCRuntimeEx; 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 org.xml.sax.Attributes;
import com.sun.xml.internal.xsom.parser.*; import org.xml.sax.Locator;
import com.sun.xml.internal.xsom.impl.*; import org.xml.sax.SAXException;
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 simpleType extends NGCCHandler { class simpleType extends NGCCHandler {
@ -373,7 +368,7 @@ class simpleType extends NGCCHandler {
switch($_ngcc_current_state) { switch($_ngcc_current_state) {
case 13: case 13:
{ {
name = $value; name = $runtime.collapse($value);
$_ngcc_current_state = 12; $_ngcc_current_state = 12;
} }
break; break;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -35,12 +35,16 @@ import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementFilter; import javax.lang.model.util.ElementFilter;
import java.util.Collection; import java.util.Collection;
import javax.lang.model.element.Element;
/** /**
* @author WS Development Team * @author WS Development Team
*/ */
final class TypeModeler { final class TypeModeler {
private static final String REMOTE = "java.rmi.Remote";
private static final String REMOTE_EXCEPTION = "java.rmi.RemoteException";
private TypeModeler() { private TypeModeler() {
} }
@ -160,4 +164,29 @@ final class TypeModeler {
return false; 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;
}
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -51,13 +51,9 @@ import javax.xml.ws.WebServiceProvider;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.reflect.Method;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Scanner;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
@ -89,21 +85,20 @@ import java.util.logging.Level;
"javax.xml.ws.WebServiceProvider", "javax.xml.ws.WebServiceProvider",
"javax.xml.ws.WebServiceRef" "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 { public class WebServiceAp extends AbstractProcessor implements ModelBuilder {
private static final Logger LOGGER = Logger.getLogger(WebServiceAp.class); private static final Logger LOGGER = Logger.getLogger(WebServiceAp.class);
public static final String DO_NOT_OVERWRITE = "doNotOverWrite"; public static final String DO_NOT_OVERWRITE = "doNotOverWrite";
public static final String IGNORE_NO_WEB_SERVICE_FOUND_WARNING = "ignoreNoWebServiceFoundWarning"; public static final String IGNORE_NO_WEB_SERVICE_FOUND_WARNING = "ignoreNoWebServiceFoundWarning";
public static final String VERBOSE = "verbose";
private WsgenOptions options; private WsgenOptions options;
protected AnnotationProcessorContext context; protected AnnotationProcessorContext context;
private File sourceDir; private File sourceDir;
private boolean doNotOverWrite; private boolean doNotOverWrite;
private boolean ignoreNoWebServiceFoundWarning = false; private boolean ignoreNoWebServiceFoundWarning = false;
private TypeElement remoteElement;
private TypeMirror remoteExceptionElement;
private TypeMirror exceptionElement; private TypeMirror exceptionElement;
private TypeMirror runtimeExceptionElement; private TypeMirror runtimeExceptionElement;
private TypeElement defHolderElement; private TypeElement defHolderElement;
@ -126,8 +121,6 @@ public class WebServiceAp extends AbstractProcessor implements ModelBuilder {
@Override @Override
public synchronized void init(ProcessingEnvironment processingEnv) { public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(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(); exceptionElement = processingEnv.getElementUtils().getTypeElement(Exception.class.getName()).asType();
runtimeExceptionElement = processingEnv.getElementUtils().getTypeElement(RuntimeException.class.getName()).asType(); runtimeExceptionElement = processingEnv.getElementUtils().getTypeElement(RuntimeException.class.getName()).asType();
defHolderElement = processingEnv.getElementUtils().getTypeElement(Holder.class.getName()); defHolderElement = processingEnv.getElementUtils().getTypeElement(Holder.class.getName());
@ -135,71 +128,14 @@ public class WebServiceAp extends AbstractProcessor implements ModelBuilder {
options = new WsgenOptions(); options = new WsgenOptions();
out = new PrintStream(new ByteArrayOutputStream()); out = new PrintStream(new ByteArrayOutputStream());
doNotOverWrite = getOption(DO_NOT_OVERWRITE); doNotOverWrite = getOption(DO_NOT_OVERWRITE);
ignoreNoWebServiceFoundWarning = getOption(IGNORE_NO_WEB_SERVICE_FOUND_WARNING); ignoreNoWebServiceFoundWarning = getOption(IGNORE_NO_WEB_SERVICE_FOUND_WARNING);
options.verbose = getOption(VERBOSE);
String classDir = parseArguments();
String property = System.getProperty("java.class.path");
options.classpath = classDir + File.pathSeparator + (property != null ? property : "");
isCommandLineInvocation = true; isCommandLineInvocation = true;
} }
options.filer = processingEnv.getFiler(); 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) { private boolean getOption(String key) {
String value = processingEnv.getOptions().get(key); String value = processingEnv.getOptions().get(key);
if (value != null) { if (value != null) {
@ -309,14 +245,14 @@ public class WebServiceAp extends AbstractProcessor implements ModelBuilder {
@Override @Override
public boolean isRemote(TypeElement typeElement) { public boolean isRemote(TypeElement typeElement) {
return processingEnv.getTypeUtils().isSubtype(typeElement.asType(), remoteElement.asType()); return TypeModeler.isRemote(typeElement);
} }
@Override @Override
public boolean isServiceException(TypeMirror typeMirror) { public boolean isServiceException(TypeMirror typeMirror) {
return processingEnv.getTypeUtils().isSubtype(typeMirror, exceptionElement) return processingEnv.getTypeUtils().isSubtype(typeMirror, exceptionElement)
&& !processingEnv.getTypeUtils().isSubtype(typeMirror, runtimeExceptionElement) && !processingEnv.getTypeUtils().isSubtype(typeMirror, runtimeExceptionElement)
&& !processingEnv.getTypeUtils().isSubtype(typeMirror, remoteExceptionElement); && !TypeModeler.isRemoteException(processingEnv, typeMirror);
} }
@Override @Override

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -171,11 +171,10 @@ public class WebServiceWrapperGenerator extends WebServiceVisitor {
@SuppressWarnings("CallToThreadDumpStack") @SuppressWarnings("CallToThreadDumpStack")
protected void doPostProcessWebService(WebService webService, TypeElement d) { protected void doPostProcessWebService(WebService webService, TypeElement d) {
if (cm != null) { if (cm != null) {
File sourceDir = builder.getSourceDir();
assert(sourceDir != null);
WsgenOptions options = builder.getOptions(); WsgenOptions options = builder.getOptions();
assert options.filer != null;
try { try {
CodeWriter cw = new FilerCodeWriter(sourceDir, options); CodeWriter cw = new FilerCodeWriter(options);
if(options.verbose) if(options.verbose)
cw = new ProgressCodeWriter(cw, System.out); cw = new ProgressCodeWriter(cw, System.out);
cm.build(cw); cm.build(cw);
@ -248,9 +247,7 @@ public class WebServiceWrapperGenerator extends WebServiceVisitor {
} }
builder.log("requestWrapper: "+requestClassName); builder.log("requestWrapper: "+requestClassName);
///// fix for wsgen CR 6442344 ///// fix for wsgen CR 6442344
File file = new File(DirectoryUtil.getOutputDirectoryFor(requestClassName, builder.getSourceDir()), addGeneratedFile(requestClassName);
Names.stripQualifier(requestClassName) + GeneratorConstants.JAVA_SRC_SUFFIX.getValue());
builder.getOptions().addGeneratedFile(file);
////////// //////////
boolean canOverwriteRequest = builder.canOverWriteClass(requestClassName); boolean canOverwriteRequest = builder.canOverWriteClass(requestClassName);
if (!canOverwriteRequest) { if (!canOverwriteRequest) {
@ -282,9 +279,7 @@ public class WebServiceWrapperGenerator extends WebServiceVisitor {
builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RESPONSE_WRAPPER_BEAN_NAME_NOT_UNIQUE( builder.processError(WebserviceapMessages.WEBSERVICEAP_METHOD_RESPONSE_WRAPPER_BEAN_NAME_NOT_UNIQUE(
typeElement.getQualifiedName(), method.toString())); typeElement.getQualifiedName(), method.toString()));
} }
file = new File(DirectoryUtil.getOutputDirectoryFor(responseClassName, builder.getSourceDir()), addGeneratedFile(responseClassName);
Names.stripQualifier(responseClassName) + GeneratorConstants.JAVA_SRC_SUFFIX.getValue());
builder.getOptions().addGeneratedFile(file);
} }
//ArrayList<MemberInfo> reqMembers = new ArrayList<MemberInfo>(); //ArrayList<MemberInfo> reqMembers = new ArrayList<MemberInfo>();
//ArrayList<MemberInfo> resMembers = new ArrayList<MemberInfo>(); //ArrayList<MemberInfo> resMembers = new ArrayList<MemberInfo>();
@ -334,6 +329,12 @@ public class WebServiceWrapperGenerator extends WebServiceVisitor {
return true; 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) { // private List<Annotation> collectJAXBAnnotations(Declaration decl) {
// List<Annotation> jaxbAnnotation = new ArrayList<Annotation>(); // List<Annotation> jaxbAnnotation = new ArrayList<Annotation>();
// for(Class jaxbClass : jaxbAnns) { // for(Class jaxbClass : jaxbAnns) {
@ -471,8 +472,11 @@ public class WebServiceWrapperGenerator extends WebServiceVisitor {
seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder); seiContext.addExceptionBeanEntry(thrownDecl.getQualifiedName(), faultInfo, builder);
return false; return false;
} }
if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) if (seiContext.getExceptionBeanName(thrownDecl.getQualifiedName()) != null) {
return false; return false;
}
addGeneratedFile(className);
//write class comment - JAXWS warning //write class comment - JAXWS warning
JDocComment comment = cls.javadoc(); JDocComment comment = cls.javadoc();

View file

@ -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. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -47,6 +47,7 @@ wsimport.help=\nUsage: {0} [options] <WSDL_URI>\n\n\
\ -J<javacOption> pass this option to javac\n\ \ -J<javacOption> pass this option to javac\n\
\ -keep keep generated files\n\ \ -keep keep generated files\n\
\ -p <pkg> specifies the target package\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\ \ -quiet suppress wsimport output\n\
\ -s <directory> specify where to place generated source files\n\ \ -s <directory> specify where to place generated source files\n\
\ -target <version> generate code as per the given JAXWS spec version\n\ \ -target <version> generate code as per the given JAXWS spec version\n\

View file

@ -26,4 +26,4 @@
build-id=2.3.0-SNAPSHOT build-id=2.3.0-SNAPSHOT
build-version=JAX-WS RI 2.3.0-SNAPSHOT build-version=JAX-WS RI 2.3.0-SNAPSHOT
major-version=2.3.0 major-version=2.3.0
svn-revision=282759e2b822078de9ba78c743ed663541c16ead svn-revision=5c2c1fd2f2ab3b5c7cea25f79aa49e54cb84b7cc

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,11 +25,12 @@
package com.sun.tools.internal.ws.wscompile; package com.sun.tools.internal.ws.wscompile;
import com.sun.codemodel.internal.CodeWriter;
import com.sun.codemodel.internal.JPackage; import com.sun.codemodel.internal.JPackage;
import javax.annotation.processing.Filer; import javax.annotation.processing.Filer;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer; import java.io.Writer;
/** /**
@ -37,18 +38,22 @@ import java.io.Writer;
* *
* @author WS Development Team * @author WS Development Team
*/ */
public class FilerCodeWriter extends WSCodeWriter { public class FilerCodeWriter extends CodeWriter {
/** The Filer used to create files. */ /** The Filer used to create files. */
private final Filer filer; private final Filer filer;
private Writer w; private Writer w;
public FilerCodeWriter(File outDir, Options options) throws IOException { public FilerCodeWriter(Options options) throws IOException {
super(outDir, options);
this.filer = options.filer; 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 { public Writer openSource(JPackage pkg, String fileName) throws IOException {
String tmp = fileName.substring(0, fileName.length()-5); String tmp = fileName.substring(0, fileName.length()-5);
if (pkg.name() != null && ! "".equals(pkg.name())) { if (pkg.name() != null && ! "".equals(pkg.name())) {
@ -61,7 +66,6 @@ public class FilerCodeWriter extends WSCodeWriter {
public void close() throws IOException { public void close() throws IOException {
super.close();
if (w != null) if (w != null)
w.close(); w.close();
w = null; w = null;

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,6 @@
package com.sun.tools.internal.ws.wscompile; package com.sun.tools.internal.ws.wscompile;
import com.oracle.webservices.internal.api.databinding.WSDLResolver; 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.ToolVersion;
import com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAp; import com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAp;
import com.sun.tools.internal.ws.processor.modeler.wsdl.ConsoleErrorReporter; import com.sun.tools.internal.ws.processor.modeler.wsdl.ConsoleErrorReporter;
@ -54,11 +53,9 @@ import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject; import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager; import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider; import javax.tools.ToolProvider;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import javax.xml.transform.Result; import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.ws.EndpointReference;
import javax.xml.ws.Holder; import javax.xml.ws.Holder;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
@ -137,18 +134,6 @@ public class WsgenTool {
private final Container container; 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 * @param endpoint
@ -159,11 +144,12 @@ public class WsgenTool {
public boolean buildModel(String endpoint, Listener listener) throws BadCommandLineException { public boolean buildModel(String endpoint, Listener listener) throws BadCommandLineException {
final ErrorReceiverFilter errReceiver = new ErrorReceiverFilter(listener); final ErrorReceiverFilter errReceiver = new ErrorReceiverFilter(listener);
boolean bootCP = useBootClasspath(EndpointReference.class) || useBootClasspath(XmlSeeAlso.class); List<String> args = new ArrayList<String>(6 + (options.nocompile ? 1 : 0)
List<String> args = new ArrayList<String>(6 + (bootCP ? 1 : 0) + (options.nocompile ? 1 : 0)
+ (options.encoding != null ? 2 : 0)); + (options.encoding != null ? 2 : 0));
args.add("--add-modules"); args.add("--add-modules");
args.add("java.xml.ws"); args.add("java.xml.ws");
args.add("-d"); args.add("-d");
args.add(options.destDir.getAbsolutePath()); args.add(options.destDir.getAbsolutePath());
args.add("-classpath"); args.add("-classpath");
@ -177,13 +163,6 @@ public class WsgenTool {
args.add("-encoding"); args.add("-encoding");
args.add(options.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) { if (options.javacOptions != null) {
args.addAll(options.getJavacOptions(args, listener)); args.addAll(options.getJavacOptions(args, listener));
} }

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -132,6 +132,11 @@ public class WsimportOptions extends Options {
*/ */
public boolean useBaseResourceAndURLToLoadWSDL = false; 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. * JAXB's {@link SchemaCompiler} to be used for handling the schema portion.
* This object is also configured through options. * This object is also configured through options.
@ -219,6 +224,14 @@ public class WsimportOptions extends Options {
} }
/** /**
* 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. * Parses arguments and fill fields of this object.
* *
* @exception BadCommandLineException * @exception BadCommandLineException
@ -294,6 +307,9 @@ public class WsimportOptions extends Options {
} else if (args[i].equals("-p")) { } else if (args[i].equals("-p")) {
defaultPackage = requireArgument("-p", args, ++i); defaultPackage = requireArgument("-p", args, ++i);
return 2; return 2;
} else if (args[i].equals("-m")) {
javaModule = requireArgument("-m", args, ++i);
return 2;
} else if (args[i].equals("-catalog")) { } else if (args[i].equals("-catalog")) {
String catalog = requireArgument("-catalog", args, ++i); String catalog = requireArgument("-catalog", args, ++i);
try { try {

View file

@ -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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,13 +47,10 @@ import com.sun.tools.internal.ws.wsdl.parser.WSDLInternalizationLogic;
import com.sun.tools.internal.xjc.util.NullStream; import com.sun.tools.internal.xjc.util.NullStream;
import com.sun.xml.internal.ws.api.server.Container; import com.sun.xml.internal.ws.api.server.Container;
import com.sun.xml.internal.ws.util.ServiceFinder; import com.sun.xml.internal.ws.util.ServiceFinder;
import com.sun.istack.internal.tools.ParallelWorldClassLoader;
import org.xml.sax.EntityResolver; import org.xml.sax.EntityResolver;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
import javax.xml.bind.JAXBPermission;
import javax.xml.stream.*; import javax.xml.stream.*;
import javax.xml.ws.EndpointContext;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import java.text.MessageFormat; import java.text.MessageFormat;
@ -66,6 +63,9 @@ import org.xml.sax.SAXException;
* @author Vivek Pandey * @author Vivek Pandey
*/ */
public class WsimportTool { 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 static final String WSIMPORT = "wsimport";
private final PrintStream out; private final PrintStream out;
private final Container container; private final Container container;
@ -476,9 +476,13 @@ public class WsimportTool {
} }
} }
if (options.getModuleName() != null) {
options.getCodeModel()._prepareModuleInfo(options.getModuleName(), JAXWS_MODULE);
}
CodeWriter cw; CodeWriter cw;
if (options.filer != null) { if (options.filer != null) {
cw = new FilerCodeWriter(options.sourceDir, options); cw = new FilerCodeWriter(options);
} else { } else {
cw = new WSCodeWriter(options.sourceDir, options); cw = new WSCodeWriter(options.sourceDir, options);
} }
@ -499,18 +503,6 @@ public class WsimportTool {
this.options.entityResolver = resolver; 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){ protected boolean compileGeneratedClasses(ErrorReceiver receiver, WsimportListener listener){
List<String> sourceFiles = new ArrayList<String>(); List<String> sourceFiles = new ArrayList<String>();
@ -523,21 +515,15 @@ public class WsimportTool {
if (sourceFiles.size() > 0) { if (sourceFiles.size() > 0) {
String classDir = options.destDir.getAbsolutePath(); String classDir = options.destDir.getAbsolutePath();
String classpathString = createClasspathString(); String classpathString = createClasspathString();
boolean bootCP = useBootClasspath(EndpointContext.class) || useBootClasspath(JAXBPermission.class);
List<String> args = new ArrayList<String>(); List<String> args = new ArrayList<String>();
args.add("--add-modules"); args.add("--add-modules");
args.add("java.xml.ws"); args.add("java.xml.ws");
args.add("-d"); args.add("-d");
args.add(classDir); args.add(classDir);
args.add("-classpath"); args.add("-classpath");
args.add(classpathString); 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) { if (options.debug) {
args.add("-g"); args.add("-g");