Fix PROPERTY_QSET indexing for types with several multi-name properties - #120
Merged
Merged
Conversation
While this iterator is within the loop, all generated references to PROPERTY_QSET[] will point to index 0 instead of being incremented.
Since 5.2.1 the per-property index in printStaticFields was reset on every loop iteration, so every property with multiple accepted names referenced PROPERTY_QSET[0]. The test compiles a type with two substitution-group properties and checks each accessor uses its own slot. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #119 by @dwarven-cleric, keeping their commit and adding a regression test.
Bug
In
SchemaTypeCodePrinter.printStaticFieldstheindexcounter was declared inside the per-property loop, so it reset to zero on every iteration. Every property with more than one accepted QName (typically a substitution group head) was assignedsetSetIndex(0), and the generated impl class referencedPROPERTY_QSET[0]for all of them. When a type has two or more such properties, the second and later accessors silently matched the first property's element names.This is a regression from the XMLBEANS-644 change (December 2023). It shipped in 5.2.1, 5.3.0, 5.4.0 and 5.4.1. Before that, the index came from a map whose size supplied the next slot, which was correct.
Fix
Hoist
indexout of the loop (the one-line change from #119).Test
PropertyQSetIndexTestcompiles an inline schema with two substitution groups referenced from one complex type, captures the generated sources with an in-memoryFiler, and asserts thatgetHeadAArrayusesPROPERTY_QSET[0]andgetHeadBArrayusesPROPERTY_QSET[1]. Verified the test fails on trunk without the fix and passes with it.🤖 Generated with Claude Code