JDK-8046817 : JDK 8 schemagen tool does not generate xsd files for enum types
  • Type: Bug
  • Component: xml
  • Sub-Component: jaxb
  • Affected Version: 8u5
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_oracle_6.0
  • CPU: generic
  • Submitted: 2014-06-13
  • Updated: 2015-09-29
  • Resolved: 2015-01-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9 Other
8u45Fixed 9 b49Fixed openjdk7uFixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
The following source file "BookCategoryType.java" was stripped down from the xjc generated source out of "books.xsd".

import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlEnumValue;
import javax.xml.bind.annotation.XmlType;

@XmlType(name = "bookCategoryType")
public enum BookCategoryType {


    private final String value;
    BookCategoryType(String v) {
        value = v;

When running the JDK 8 schemagen tool using the following command:
schemagen BookCategoryType.java

no "schema1.xsd" file is generated.

The schemagen tool of JDK 7 generates this file as expected.

The JDK 8 version used is:
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)

on a Oracle Linux Server.
which fix caused this regression ?

Please, push the fix to 8u-CPU WS first (It would be 8u51) We have nightly for 8u-dev with the fix. No issues with the nightly. SQE OK to take the fix to CPSU15_02

The following fix for SchemaGenerator solves the problem: diff -r d35ad0854f68 src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/ap/SchemaGenerator.java --- a/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/ap/SchemaGenerator.java Fri Sep 12 17:20:37 2014 +0200 +++ b/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/ap/SchemaGenerator.java Sun Sep 14 15:31:15 2014 +0400 @@ -135,7 +135,8 @@ private void filterClass(List<Reference> classes, Collection<? extends Element> elements) { for (Element element : elements) { - if (element.getKind().equals(ElementKind.CLASS)) { + if (element.getKind().equals(ElementKind.CLASS) || element.getKind().equals(ElementKind.INTERFACE) || + element.getKind().equals(ElementKind.ENUM)) { classes.add(new Reference((TypeElement) element, processingEnv)); filterClass(classes, ElementFilter.typesIn(element.getEnclosedElements())); }