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

JAXB generated TDML is not reproducible #1142

Open
stevedlawrence opened this issue Dec 6, 2024 · 1 comment
Open

JAXB generated TDML is not reproducible #1142

stevedlawrence opened this issue Dec 6, 2024 · 1 comment

Comments

@stevedlawrence
Copy link
Member

Steps to reproduce:

sbt clean resources xjc
cp -R debugger/target/scala-2.12/src_managed_cxf/ /tmp
sbt clean resources xjc
diff -rq debugger/target/scala-2.12/src_managed_cxf/ /tmp/src_managed_cxf

Repeat lines 3 and 4 until it shows a diff.

So far I've been able to pretty easily reproduce this on Java 8 (OpenJDK Runtime Environment (Temurin)(build 1.8.0_432-b06)) and less likely but still reproducible on Java 11 (OpenJDK Runtime Environment Temurin-11.0.25+9 (build 11.0.25+9)) and so far not at all on Java 21. Not sure if this is a Java version issue, or some versions just make it more/less likely for some reason.

An example of a diff usually start with something like this:

diff -Naur debugger/target/scala-2.12/src_managed_cxf/org/apache/daffodil/tdml/DFDLBaseType.java /tmp/src_managed_cxf/org/apache/daffodil/tdml/DFDLBaseType.java
--- debugger/target/scala-2.12/src_managed_cxf/org/apache/daffodil/tdml/DFDLBaseType.java	2024-12-06 10:09:30.318167823 -0500
+++ /tmp/src_managed_cxf/org/apache/daffodil/tdml/DFDLBaseType.java	2024-12-06 10:09:16.896018288 -0500
@@ -24,10 +24,10 @@
  *     <extension base="{http://www.ogf.org/dfdl/dfdl-1.0/}DFDLType">
  *       <sequence>
  *       </sequence>
- *       <attGroup ref="{http://www.ogf.org/dfdl/dfdl-1.0/}MarkupAG"/>
- *       <attGroup ref="{http://www.ogf.org/dfdl/dfdl-1.0/}CommonAG"/>
  *       <attGroup ref="{http://www.ogf.org/dfdl/dfdl-1.0/}AlignmentAG"/>
  *       <attGroup ref="{http://www.ogf.org/dfdl/dfdl-1.0/}BaseAG"/>
+ *       <attGroup ref="{http://www.ogf.org/dfdl/dfdl-1.0/}MarkupAG"/>
+ *       <attGroup ref="{http://www.ogf.org/dfdl/dfdl-1.0/}CommonAG"/>
  *       <anyAttribute processContents='lax' namespace='urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:int urn:ogf:dfdl:2013:imp:daffodil.apache.org:2018:ext http://www.w3.org/XML/1998/namespace http://www.ibm.com/xmlns/dfdl/testData'/>
  *     </extension>
  *   </complexContent>
@@ -52,6 +52,36 @@
...

It's always related to attribute groups.

It looks like however xjc outputs attribute groups, it outputs their generated comments, members, and methods in a random order, instead of the order they are defined in the schema. This doesn't technically affect anything since the the order of attribute groups and their members/functions don't matter, but it does mean the compiled .class files have members/methods in a different order, which leads to non-reproducibility.

@stevedlawrence
Copy link
Member Author

Looks like someone else ran into this recently: https://bugs.eclipse.org/bugs/show_bug.cgi?id=583485

So unlikely we are doing something wrong, but unfortunately there may not be an easy workaround. Maybe there's a linter or something that we can post process the generated xjc files to sort the methods and members?

Another option, it might be the case that all the incorrectly generated classes are related to objects that represent embedded schemas (DFDLChoiceType, DFDLElementTYpe, DFDLGroupType, SimpleType, etc). We probably don't need those objects at all. If we JAXB sources could treat the contents of <tdml:defineSchema> as an opaque blob of XML, then that might avoid the issue by just not generating things like DFDLChoiceType. We potentially have the issue with TDML related objects, but maybe it uses attributeGroups in a way that leads to deterministic output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant