# HG changeset patch # User robm # Date 1459288907 -3600 # Node ID 43833fcf47017b75fa33ee16491c320f0a53362a # Parent 0a82e8a2c2265d334d8818a26b064e3046dc6976# Parent bd88174c3095b4c26d0e9b5d27727f975d995945 Merge diff -r 0a82e8a2c226 -r 43833fcf4701 src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CTypeRef.java --- a/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CTypeRef.java Tue Mar 29 13:26:58 2016 -0700 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CTypeRef.java Tue Mar 29 23:01:47 2016 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -100,10 +100,15 @@ */ private static QName resolveSimpleTypeName(XSType declType) { QName name = BGMBuilder.getName(declType); - if (name != null && !XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(name.getNamespaceURI())) - return resolveSimpleTypeName(declType.getBaseType()); - else - return name; + QName result = null; + if (name != null && !XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(name.getNamespaceURI())) { + result = resolveSimpleTypeName(declType.getBaseType()); + } else { + if ( !"anySimpleType".equals(declType.getName()) ) { + result = name; + } + } + return result; } public CTypeRef(CNonElement type, QName elementName, QName typeName, boolean nillable, XmlString defaultValue) { diff -r 0a82e8a2c226 -r 43833fcf4701 src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java Tue Mar 29 13:26:58 2016 -0700 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/schemagen/XmlSchemaGenerator.java Tue Mar 29 23:01:47 2016 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,6 +110,7 @@ import com.sun.xml.internal.txw2.output.ResultFactory; import com.sun.xml.internal.txw2.output.XmlSerializer; import java.util.Collection; +import java.util.HashSet; import org.xml.sax.SAXParseException; /** @@ -436,7 +437,7 @@ if(logger.isLoggable(Level.FINE)) { // debug logging to see what's going on. - logger.log(Level.FINE,"Wrigin XML Schema for "+toString(),new StackRecorder()); + logger.log(Level.FINE,"Writing XML Schema for "+toString(),new StackRecorder()); } // make it fool-proof @@ -465,6 +466,8 @@ systemIds.put(n,output.getSystemId()); } } + //Clear the namespace specific set with already written classes + n.resetWritten(); } // then write'em all @@ -542,6 +545,11 @@ */ private boolean useMimeNs; + /** + * Container for already processed classes + */ + private final Set written = new HashSet(); + public Namespace(String uri) { this.uri = uri; assert !XmlSchemaGenerator.this.namespaces.containsKey(uri); @@ -549,6 +557,13 @@ } /** + * Clear out the set of already processed classes for this namespace + */ + void resetWritten() { + written.clear(); + } + + /** * Process the given PropertyInfo looking for references to namespaces that * are foreign to the given namespace. Any foreign namespace references * found are added to the given namespaces dependency list and an <import> @@ -853,6 +868,10 @@ * @param parent the writer of the parent element into which the type will be defined */ private void writeClass(ClassInfo c, TypeHost parent) { + if (written.contains(c)) { // to avoid cycles let's check if we haven't already processed the class + return; + } + written.add(c); // special handling for value properties if (containsValueProp(c)) { if (c.getProperties().size() == 1) {