Skip to content

Fix #4864: Correct toString() output in ReflectionRecordDeclaration#4879

Merged
jlerbsc merged 1 commit intojavaparser:masterfrom
ChenduanZhang:bugfix/reflectionrecord-tostring
Oct 22, 2025
Merged

Fix #4864: Correct toString() output in ReflectionRecordDeclaration#4879
jlerbsc merged 1 commit intojavaparser:masterfrom
ChenduanZhang:bugfix/reflectionrecord-tostring

Conversation

@ChenduanZhang
Copy link
Copy Markdown
Contributor

Fixes

Fixes #4864

Test

  • Added a new test case testToStringShouldUseCorrectClassName() in ReflectionRecordDeclarationTest

Details

  • Use getClass().getSimpleName() to update toString() to print "ReflectionRecordDeclaration" instead of "ReflectionClassDeclaration"

(ReflectionRecordDeclaration) typeSolver.solveType("box.Box");

String result = decl.toString();
System.out.println("toString() output = " + result);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not good practice.

Copy link
Copy Markdown
Contributor Author

@ChenduanZhang ChenduanZhang Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I will remove the System.out.println() and keep only the assertion.

@jlerbsc
Copy link
Copy Markdown
Collaborator

jlerbsc commented Oct 19, 2025

Please squash your commits for better readability.

@ChenduanZhang ChenduanZhang force-pushed the bugfix/reflectionrecord-tostring branch from 02810fb to c73eab8 Compare October 20, 2025 02:58
@ChenduanZhang ChenduanZhang reopened this Oct 20, 2025
@ChenduanZhang
Copy link
Copy Markdown
Contributor Author

Please squash your commits for better readability.

Done — squashed commits into one for better readability.

@jlerbsc
Copy link
Copy Markdown
Collaborator

jlerbsc commented Oct 20, 2025

Why do you close and reopen the PR? This generates alerts, which are annoying.

@jlerbsc
Copy link
Copy Markdown
Collaborator

jlerbsc commented Oct 20, 2025

Could this change inspire other similar changes (for example, in the ReflectionClassDeclaration class)?
Please make a separate commit for the other improvements.

@ChenduanZhang
Copy link
Copy Markdown
Contributor Author

Sorry, I accidentally closed the PR — that was unintentional.
I’m happy to look into your suggestion about similar changes.

@ChenduanZhang
Copy link
Copy Markdown
Contributor Author

Done — updated all classes in reflectionmodel with the same toString() style and pushed a separate commit

@jlerbsc
Copy link
Copy Markdown
Collaborator

jlerbsc commented Oct 22, 2025

Have you squashed your commits?

@ChenduanZhang
Copy link
Copy Markdown
Contributor Author

Yes, I’ve squashed the commits. All other similar updates have been into the new commit:
refactor(reflectionmodel): use getClass().getSimpleName() in toString() methods.
Should I also squash the previous commit for ReflectionRecordDeclaration and the new commit for a cleaner history?

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.341%. Comparing base (9852c2b) to head (1a4011b).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##              master     #4879       +/-   ##
===============================================
+ Coverage     58.333%   58.341%   +0.007%     
- Complexity      2535      2538        +3     
===============================================
  Files            677       677               
  Lines          39041     39041               
  Branches        7089      7089               
===============================================
+ Hits           22774     22777        +3     
+ Misses         13368     13365        -3     
  Partials        2899      2899               
Flag Coverage Δ
AlsoSlowTests 58.341% <100.000%> (+0.007%) ⬆️
javaparser-core 58.341% <100.000%> (+0.007%) ⬆️
javaparser-symbol-solver 58.341% <100.000%> (+0.007%) ⬆️
jdk-10 57.905% <83.333%> (+0.007%) ⬆️
jdk-11 57.904% <83.333%> (+0.010%) ⬆️
jdk-12 57.904% <83.333%> (+0.007%) ⬆️
jdk-13 57.902% <83.333%> (+0.005%) ⬆️
jdk-14 58.142% <83.333%> (+0.007%) ⬆️
jdk-15 58.142% <83.333%> (+0.007%) ⬆️
jdk-16 58.117% <83.333%> (+0.010%) ⬆️
jdk-17 58.271% <100.000%> (+0.007%) ⬆️
jdk-18 58.271% <100.000%> (+0.007%) ⬆️
jdk-8 57.905% <83.333%> (+0.007%) ⬆️
jdk-9 57.903% <83.333%> (+0.010%) ⬆️
macos-latest 58.333% <100.000%> (+0.007%) ⬆️
ubuntu-latest 58.328% <100.000%> (+0.007%) ⬆️
windows-latest 58.323% <100.000%> (+0.007%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...er/reflectionmodel/ReflectionClassDeclaration.java 74.820% <100.000%> (ø)
...eflectionmodel/ReflectionInterfaceDeclaration.java 51.879% <100.000%> (+0.751%) ⬆️
...r/reflectionmodel/ReflectionMethodDeclaration.java 75.000% <100.000%> (ø)
...eflectionmodel/ReflectionParameterDeclaration.java 45.833% <100.000%> (+4.166%) ⬆️
...r/reflectionmodel/ReflectionRecordDeclaration.java 32.298% <100.000%> (ø)
...olver/reflectionmodel/ReflectionTypeParameter.java 65.789% <100.000%> (+2.631%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 184b05a...1a4011b. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jlerbsc
Copy link
Copy Markdown
Collaborator

jlerbsc commented Oct 22, 2025

Is the ticket finished for you?

@ChenduanZhang
Copy link
Copy Markdown
Contributor Author

I just noticed that one of the checks failed, so I added a test for this issue. If all the tests pass this time, I’ll squash the commits and it’ll be finished.

@ChenduanZhang ChenduanZhang force-pushed the bugfix/reflectionrecord-tostring branch from 40bbf19 to 4a292c3 Compare October 22, 2025 13:14
fix: correct toString() output in ReflectionRecordDeclaration and add corresponding test case

refactor(reflectionmodel): use getClass().getSimpleName() in toString() methods

test: add test for issue4864
@ChenduanZhang ChenduanZhang force-pushed the bugfix/reflectionrecord-tostring branch from ce2c57c to 1a4011b Compare October 22, 2025 13:26
@ChenduanZhang
Copy link
Copy Markdown
Contributor Author

I’ve finished the updates and squashed the commits for a clean history.

@jlerbsc jlerbsc merged commit 4722430 into javaparser:master Oct 22, 2025
35 checks passed
@jlerbsc jlerbsc added this to the next release milestone Oct 22, 2025
@jlerbsc jlerbsc added the PR: Fixed A PR that offers a fix or correction label Oct 22, 2025
@jlerbsc
Copy link
Copy Markdown
Collaborator

jlerbsc commented Oct 22, 2025

Thank you for this contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Fixed A PR that offers a fix or correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Incorrect toString in ReflectionRecordDeclaration

2 participants