fix: derive a valid package for shallow export model URIs in ExportGeneratorX#1281
Open
joaodinissf wants to merge 1 commit into
Open
fix: derive a valid package for shallow export model URIs in ExportGeneratorX#1281joaodinissf wants to merge 1 commit into
joaodinissf wants to merge 1 commit into
Conversation
0f6cf8b to
5b9f831
Compare
5b9f831 to
bfc4e37
Compare
b096715 to
d0a7d5f
Compare
5938031 to
4ee1c4e
Compare
adcaf41 to
58aff88
Compare
58aff88 to
f3f4e1a
Compare
…neratorX ExportGeneratorX.getPrefix derives the target package from raw URI segment arithmetic and misbehaves on every short URI shape: 1 segment (e.g. ParseHelper's __synthetic0.export) crashes with IndexOutOfBoundsException (subList(-1, 0)); 2 segments emit the literal segment "resource"; project-root URIs emit the raw project name (uncompilable generated code when the project is not named like a Java package); source-folder-root URIs emit an empty package, producing leading-dot qualified names. Keep the derivation for URIs with five or more segments byte for byte (segments between position 3 and the file) and make every shorter shape fall back to the project name when it already is a valid Java package name (SourceVersion.isName) or "generated" otherwise. No existing test ever failed on this: the builder participant catches the exception per resource and logs it (the long-standing "Error during compilation of '....export'" noise in master test runs), and export tests never assert generated output. ExportGeneratorXTest pins the full shape table with synthetic resource URIs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ANGM7L3BaEGfGUmPVKRt4
f3f4e1a to
793edf0
Compare
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.
Summary
ExportGeneratorX.getPrefixderives the target package from raw URI segment arithmetic and misbehaves on every short URI shape:__synthetic0.export):subList(-1, 0)→IndexOutOfBoundsException.resourceas the package.platform:/resource/<project>/<file>.export): emits the raw project name — uncompilable generated code when the project is not named like a Java package (e.g.My-Project).<project>/src/<file>.export): emits an empty package, producing leading-dot qualified names (.naming.…).The derived value feeds both the generated
packagedeclaration and the output file path via the six accessor methods (ExportedNamesProvider, ResourceDescriptionManager/Strategy/Constants, FingerprintComputer, FragmentProvider).The fix is confined to that one method:
src-gennesting andsrc/main/java.SourceVersion.isName, byte-identical to previous behavior for the project-root shape), orgeneratedotherwise.No existing test ever failed on this: the builder participant catches the exception per resource and logs it — the long-standing
ERROR … Error during compilation of '….export'noise in every master test run — and the export tests assert validation/scoping, never generated output (that structural gap is addressed separately by #1459). The newExportGeneratorXTestpins the shape table with synthetic resource URIs; no fixture files needed.Verification
mvn -T 3C clean verify checkstyle:check pmd:check pmd:cpd-check spotbugs:check→ BUILD SUCCESS, 0 test failures, including the newExportGeneratorXTest(runs in CI viaExportTestSuite→AllTests).IndexOutOfBoundsException: fromIndex = -1for the single-segment URI and wrong/leading-dot packages for the short shapes — while the behavior-preservation tests (nested derivations, valid project-name fallback) pass on both master and this branch.🤖 Generated with Claude Code