JDK8 not working with JDK8 (WS client)
I have a very simple (existing) web service that I would like to generate a web service client against using JDK8.
I'm using a pure JDK8 tool chain meaning I use the wsimport tool from my JDK8 dir.
Now to the problem: The Java source code generated by the wsimport tool in JDK8 is not JDK8 Javadoc compliant. As you may be aware the Javadoc tool has become a lot more strict in JDK8.
Consider the following simple schema:
<xs:schema version="1.0" targetNamespace="http://mavenwsserver.ws.mytest.org/">
<xs:element name="operation" type="tns:operation"/>
<xs:element name="operationResponse" type="tns:operationResponse"/>
<xs:complexType name="operation">
<xs:sequence>
<xs:element name="person" type="tns:person" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="person">
<xs:sequence>
<xs:element name="firstName" type="xs:string" minOccurs="0"/>
<xs:element name="lastName" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="operationResponse">
<xs:sequence>
<xs:element name="return" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
For this the wsimport tool will generate Java code as follows:
package org.mytest.ws.mavenwsclient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for person complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="person">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="firstName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="lastName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "person", propOrder = {
"firstName",
"lastName"
})
public class Person {
protected String firstName;
protected String lastName;
/**
* Gets the value of the firstName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getFirstName() {
return firstName;
}
/**
* Sets the value of the firstName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setFirstName(String value) {
this.firstName = value;
}
/**
* Gets the value of the lastName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getLastName() {
return lastName;
}
/**
* Sets the value of the lastName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setLastName(String value) {
this.lastName = value;
}
}
The problem is the generated comments for this class. While this type of comments would be accepted by the Javadoc compiler in JDK7 it no longer works in JDK8. (the end > must be replaced by >
in order for it to be correct in JDK8). The result of these invalid comments is that the build fails.
I know I can turn off doclint in JDK8 but I wonder if I'm doing something wrong here. It's just pure JDK8 tools. Nothing fancy. These tools are supposed to work together right? and have been thoroughly tested with each other before being released by Oracle? So I'm assuming I'm doing something wrong. Like what?
Thanks.
STEPS TO REPRODUCE
Link to WSDL (includes schema)
Download this file to somewhere on your harddrive.
I use a wsimport
command line like this:
mkdir D:JavaDevHGMavenWSClienttargetgenerated-sourcesjaxws-wsimport
"C:Program FilesJavajdk1.8.0_05binwsimport" -keep ^
-s D:JavaDevHGMavenWSClienttargetgenerated-sourcesjaxws-wsimport ^
D:/JavaDevHG/MavenWSClient/src/main/wsdl/myWSDL.xml
Now run javadoc
on the generated sources:
"C:Program FilesJavajdk1.8.0_05binjavadoc" ^
-sourcepath D:JavaDevHGMavenWSClienttargetgenerated-sourcesjaxws-wsimport ^
-subpackages org
You'll see something like this:
Loading source files for package org.mytest.ws.mavenwsserver...
Constructing Javadoc information...
Standard Doclet version 1.8.0_05
Building tree for all the packages and classes...
Generating .orgmytestwsmavenwsserverHelloWorldWebService.html...
...
...
Generating .orgmytestwsmavenwsserverPerson.html...
......targetgenerated-sourcesjaxws-wsimportorgmytestwsmavenwsserverPerson.java:15: error: bad use of '>'
* <complexType name="person">
^
......targetgenerated-sourcesjaxws-wsimportorgmytestwsmavenwsserverPerson.java:16: error: bad use of '>'
* <complexContent>
...
... ^
Note that Javadoc tool also produces a bunch of WARNINGs. I can live with that. It's the ERRORs that make the build fail.
I could only confirm your findings. Since the setup required to reproduce this is minimal, with no loose ends, the only reasonable conclusion so far is that this is a bug in the wsimport
tool packaged with the OpenJDK 8. This tool has simply not been updated to reflect the new restrictions imposed by the javadoc
tool of the same JDK package.
上一篇: 使用JDK8生成报告时出错
下一篇: JDK8不支持JDK8(WS客户端)