1. jaxb
  2. JAXB-929

DOMForest.getOneDocument() should only return documents from "rootDocuments" Set and not from "core" Map


    • Type: Bug Bug
    • Status: In Progress
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: not determined, JWSDP1.1 (JAXB1.0), JWSDP1.2 (JAXB1.0.1), JWSDP1.3 (JAXB1.0.2), JWSDP1.4 (JAXB1.0.3), JWSDP1.5 (JAXB1.0.4), JWSDP1.6 (JAXB1.0.5), 2.0 FCS, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.1, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.1.5, 2.1.6, 2.1.7, 2.1.8, 2.1.9, 2.1.10, 2.1.11, 2.1.12, 2.1.13, 2.1.14, 2.2, 2.2.1, 2.2.2, 2.2.3, 2.2.3u1, 2.2.3u2, 2.2.4, 2.2.4u1, 2.2.4u2, 2.2.5, 2.2.6, 2.2.7, 2.3
    • Fix Version/s: None
    • Component/s: xjc
    • Labels:
    • Environment:

      Ant Builder, Windows


      JAXB fails to generate correct schema 100% of the time because it sometimes fails to interpret the bindings file that we specify. Given an identical startup environment (including input files and build sequence), the output of our JAXB generated java-source code is not consistent from one run to the next.

      We debugged the problem using the JAXB source code and we determined that getOneDocument() inside com.sun.tools.xjc.reader.internalizer.DOMForest sometimes returns a document that is not specified as a root document but that is instead referenced by a root document. Such indirectly specified document is an xsd:include in our root documents, and we deliberately decided not to specify a target namespace for it as part of our design. As a result of this document not having a target namespace, Internalizer.move() fails to correctly bind the globalBindings file to the schema forest by arbitrarily choosing a document from the forest. Whenever JAXB tries to look for the global bindings at a later point in time, the schema cannot be found in the forest.

      Whenever getOneDocument() returns an object that can be found in the rootDocuments Set of DOMForest, the global bindings file is correctly attached, and JAXB generates java source code correctly as expected. Whenever getOneDocument() returns an object not in rootDocuments but that is part of the core Map of DOMForest, the bindings file is not correctly attached, and the java source code is not correctly generated. In the current code, the document selected is not predictable because getOneDocument() iterates over a HashSet, which does not specify iteration order by design, thus explaining why the generator is not consistent in its failures. That is, in some runs a root schema is chosen, and in other runs a non-root schema is chosen.

      We suggest changing line 225 of DOMForest.java inside getOneDocument() from

      for (Document dom : core.values())

      { . . . }


      for (String k : rootDocuments)

      { Document dom = core.get(k); . . . }


        Eugenio De Hoyos (IBM) created issue -
        Eugenio De Hoyos (IBM) made changes -
        Field Original Value New Value
        Attachment JAXB-929 - 4 test cases.zip [ 51579 ]
        Iaroslav Savytskyi made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Martin Grebac made changes -
        Affects Version/s 2.2.4-4 [ 16055 ]
        Martin Grebac made changes -
        Affects Version/s 2.2.4-3 [ 15931 ]


          • Assignee:
            Iaroslav Savytskyi
            Eugenio De Hoyos (IBM)
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: