Skip to content

Conversation

@iwauo
Copy link

@iwauo iwauo commented Oct 22, 2025

Description

The ToStringBuilder.reflectionToString() implementation previously threw an exception when access to a field was prohibited by JPMS. This patch adds defensive handling so that, when reflective access is not permitted, the method falls back to invoking the target object's native toString().
Additionally, the change is implemented to work on JVMs that do not support JPMS (JDK 8).


  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request.
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

@iwauo
Copy link
Author

iwauo commented Oct 23, 2025

I made a minor code change to refactor. Verified on JDK 8, 11, and 21.

@iwauo
Copy link
Author

iwauo commented Oct 30, 2025

Hi @garydgregory , could you please take a look at this PR and let me know your thoughts? I'd appreciate any feedback you have.
Please let me explain our context. I am a programmer working for a consulting company, and we have some clients who are planning to migrate their legacy systems to the latest JDK due to the EOL of older JDKs or middlewares they depend on. However, most of those systems depend on this library, and the ReflectionToString class is used for logging or other features. As a result, this issue is becoming a critical issue for those projects.
Of course, --add-opens is a solution to this problem. However, some clients refuse to set those flags for security reasons, although I understand that the main goal of the JPMS is improving modularity, not security. I believe that there must be many other projects that have the same issue."

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.

1 participant