On Fri, 14 Nov 2025 22:05:47 GMT, Chen Liang <[email protected]> wrote:
>> Alan Bateman has updated the pull request with a new target base due to a >> merge or a rebase. The pull request now contains 59 commits: >> >> - Merge branch 'master' into JDK-8353835 >> - Cleanup >> - More cleanup of Field.set API docs, including some restructure from Alex >> - Cleanup >> - Merge branch 'master' into JDK-8353835 >> - Update mutateFinals/modules test to exercise exports and opens cases >> - Update Field.set spec to better align with setAccessible for public final >> field in public class in exported package >> - Fix typo in java man page >> - Add method to test if package exported >> - Remove dup end body tag >> - ... and 49 more: https://git.openjdk.org/jdk/compare/9eaa364a...7693e8fa > > src/java.base/share/classes/java/lang/reflect/Field.java line 1621: > >> 1619: private String notAccessibleToCallerMessage(Class<?> caller, >> boolean unreflect) { >> 1620: String exportOrOpen = Modifier.isPublic(modifiers) >> 1621: && Modifier.isPublic(clazz.getModifiers()) ? "exports" >> : "open"; > > Suggestion: > > && Modifier.isPublic(clazz.getModifiers()) ? "export" : > "open"; With InaccessibleObjectException we put the (contextual) keyword in double quotes so that the exception message has `"exports" $P` or `"opens" $P`, and hopefully guide the developer to the module declaration. For this IllegalAccessException case then it should probably be the same so that the message has `"exports" $P to module $M`, in which case it should be "opens" rather than "open". ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25115#discussion_r2529713811
