RFR: 8327786: Add fluent setAccessible()

Chen Liang liach at openjdk.org
Mon Mar 11 23:49:14 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)

For your information, [the proposal has been rejected](https://bugs.openjdk.org/browse/JDK-8327786?focusedId=14656208&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14656208):

> Suppressing access control checks with setAccessible(true) is not something for most developers and not something to be encouraged. Using method invocation chaining with setAccessible doesn't seem worth doing

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

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


More information about the core-libs-dev mailing list