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

Copyable plugin does not preserve order of generated code blocks in copyTo() #23

Open
henning-meinhardt opened this issue Apr 22, 2024 · 5 comments

Comments

@henning-meinhardt
Copy link

Hi,

i'm using your JAXB plugins in generating Java source code from XSD files. I have the following XJC options in place:
-Xannotate -Xfluent-api -Xcopyable and have the following versions around:
org.patrodyne.jvnet:hisrc-basicjaxb-plugins:2.2.1, org.patrodyne.jvnet:hisrc-hyperjaxb-annox-plugin:2.2.1

Unfortunately the Copyable plugin generates code that does not preserve the order of generated code blocks when it comes to generating the copyTo method. This makes my build non-reproducible for the same inputs.

From a quick look into the Copyable plugin class I can see that method protected JMethod generateCopyTo$copyTo() collects the Members to iterate over in a HashMap: Map<FieldOutline, FieldAccessorEx> sourceFieldAccessorMap = new HashMap<>();
After that is just goes through that map and generates the code blocks. I assume that using a LinkedHashMap rather than HashMap should solve the problem.

Kind regards
Henning

@henning-meinhardt
Copy link
Author

The problem seemed to appear just recently when updating the JAXB plugins from 2.1 line to 2.2.
Looking at the sources back in 2.1, there was another approach than a HashMap:
final FieldOutline[] declaredFields = FieldOutlineUtils.filter(classOutline.getDeclaredFields(), getIgnoring());

Kind regards
Henning

@patrodyne
Copy link
Owner

Thank you for the suggestion. See dd0c969.

@patrodyne
Copy link
Owner

And see 65ff7eb

@henning-meinhardt
Copy link
Author

Hi @patrodyne , that was super fast. Do you already have an ETA for the next official release?

Kind regards
Henning

@patrodyne
Copy link
Owner

You're welcome. I release periodically but I prefer not to estimate ETAs. 😉
ETA

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

2 participants