The modifiers in core reflection and just modeled using the bits of an int. For methods and constructors, there are collisions on the reuse of modifier bits on different kinds of constructs. Printing misleading information is avoid by masking out the modfiers using information from the Modifer class.
While Field and Parameter don't currently have such collisions, they may under Valhalla and adding defensive screenings now would add robustness. ------------- Commit messages: - JDK-8373125: Add defensive screening of modifiers for Field and Parameter toString() results Changes: https://git.openjdk.org/jdk/pull/28672/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28672&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8373125 Stats: 52 lines in 3 files changed: 35 ins; 0 del; 17 mod Patch: https://git.openjdk.org/jdk/pull/28672.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/28672/head:pull/28672 PR: https://git.openjdk.org/jdk/pull/28672
