Issue #583: drop reflection from XChartPanelSaveTargetTest#1010
Merged
Conversation
The test reflected on XChartPanel$SuffixSaveFilter via Class.forName with a string literal, so a rename would surface as a runtime ClassNotFoundException rather than a compile error. This was also inconsistent within the file: resolveSaveTarget and suffixOf are already package-private and called directly by the same test. The constructor was already public; only the nested class was private. Relaxing it to package-private lets the test construct the filter directly, matching the idiom used elsewhere for test seams. No behavior change. Full xchart suite green (146 tests). Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Follow-up to the #583 Save As work. No behavior change — test cleanup only.
Problem
XChartPanelSaveTargetTestreachedXChartPanel.SuffixSaveFilterreflectively:Two things wrong with that:
ClassNotFoundExceptioninstead of at compile time.resolveSaveTargetandsuffixOfare already package-private statics and the test calls them directly; only the filter was reached reflectively.The constructor was already
public— only the nested class wasprivate, sosetAccessiblewasn't even the thing unblocking it.Change
Relax
SuffixSaveFilterto package-private and construct it directly:This matches the established idiom in the codebase —
internal/chartparthas ~86 package-private members serving as test seams, and tests there read them directly (e.g.RegressionTestIssue577asserts onlegend.xOffset).SuffixSaveFilterstays invisible to library users; it was already nested insideXChartPanelwith no public exposure.Also drops the now-unneeded
throws Exceptionfrom the five test methods and thejava.lang.reflect.Constructorimport.Verification
Full
xchartsuite green (146 tests);XChartPanelSaveTargetTestitself runs 5/5. With this and #1009, no test in the tree uses reflection.🤖 Generated with Claude Code