Skip to content

Fix PROPERTY_QSET indexing for types with several multi-name properties - #120

Merged
pjfanning merged 2 commits into
apache:trunkfrom
pjfanning:property-qset-index
Sep 15, 2026
Merged

pjfanning merged 2 commits into
apache:trunkfrom
pjfanning:property-qset-index

Conversation

@pjfanning

Copy link
Copy Markdown
Member

Supersedes #119 by @dwarven-cleric, keeping their commit and adding a regression test.

Bug

In SchemaTypeCodePrinter.printStaticFields the index counter 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 assigned setSetIndex(0), and the generated impl class referenced PROPERTY_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 index out of the loop (the one-line change from #119).

Test

PropertyQSetIndexTest compiles an inline schema with two substitution groups referenced from one complex type, captures the generated sources with an in-memory Filer, and asserts that getHeadAArray uses PROPERTY_QSET[0] and getHeadBArray uses PROPERTY_QSET[1]. Verified the test fails on trunk without the fix and passes with it.

🤖 Generated with Claude Code

dwarven-cleric and others added 2 commits September 15, 2026 22:08
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>
@pjfanning
pjfanning merged commit 77682fc into apache:trunk Sep 15, 2026
2 checks passed
@pjfanning
pjfanning deleted the property-qset-index branch September 15, 2026 21:19
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

Successfully merging this pull request may close these issues.

2 participants