RFR: 8327786: Add fluent setAccessible()

Chen Liang liach at openjdk.org
Mon Mar 11 23:05:22 UTC 2024


On Thu, 25 Jan 2024 21:35:45 GMT, Sergey <duke at openjdk.org> wrote:

> The feature allows to extract a private field value in a single expression, like so:
> 
> object.getClass().getDeclaredField().setAccessible().get(object)

First, usually to propose a patch to core libraries, we usually submit an issue or suggest an enhancement to https://bugs.java.com, or ask at `core-libs-dev at openjdk.org`.

A field that has been "set accessible" is supposed to be reused, as future `get` calls will bypass accessibility checks too. So adding a builder-style alias isn't that useful, especially that reflection Executable objects have no other setters, and the exceptions thrown by each method in the chain should be handled separately.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17578#issuecomment-1965852745


More information about the core-libs-dev mailing list