Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CXFXJC-47: XJC DefaultValue plugin uses JAXBElement that does not have a default constructor #150

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion dv-test/src/test/resources/schemas/configuration/foo.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,21 @@
<xs:sequence>
<xs:element minOccurs="0" name="redemptionNumber" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:complexType>

<xs:element name="vehicle" type="tns:vehicle"/>
<xs:complexType name="vehicle" abstract="true"/>

<xs:complexType name="car">
<xs:complexContent>
<xs:extension base="tns:vehicle"/>
</xs:complexContent>
</xs:complexType>
<xs:element name="car" type="tns:car" substitutionGroup="tns:vehicle"/>

<xs:complexType name="trip">
<xs:sequence>
<xs:element ref="tns:vehicle"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
14 changes: 13 additions & 1 deletion dv/src/main/java/org/apache/cxf/xjc/dv/DefaultValuePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -73,6 +76,15 @@
public class DefaultValuePlugin {

private static final Logger LOG = Logger.getLogger(DefaultValuePlugin.class.getName()); //NOPMD

// Known JAXB / JAXWS classes that do not have default constructors.
private static final Set<String> KNOWN_NO_DV_CLASSES = new HashSet<>(
Arrays.asList(
"jakarta.xml.ws.wsaddressing.W3CEndpointReference",
"jakarta.xml.bind.JAXBElement"
)
);

private boolean complexTypes;
private boolean active;

Expand Down Expand Up @@ -204,7 +216,7 @@ public boolean run(Outline outline, Options opt, ErrorHandler errorHandler) {
String varName = f.getPropertyInfo().getName(false);
JFieldVar var = co.implClass.fields().get(varName);
final JType rawType = f.getRawType();
if (var != null && !"jakarta.xml.ws.wsaddressing.W3CEndpointReference".equals(rawType.fullName())) {
if (var != null && !KNOWN_NO_DV_CLASSES.contains(rawType.erasure().fullName())) {
if (rawType instanceof JClass) {
final JClass jclazz = (JClass) rawType;
if (!jclazz.isAbstract() && !jclazz.isInterface()) {
Expand Down