RFR: 8355369: Remove setAccessible usage for setting final fields in java.util.concurrent

Chen Liang liach at openjdk.org
Wed Apr 23 14:56:47 UTC 2025


On Wed, 23 Apr 2025 14:06:27 GMT, Chen Liang <liach at openjdk.org> wrote:

>> This Pull Request replaces the uses of Field + setAccessible to modify final fields in java.util.concurrent with Unsafe.
>
> Seems these are used mainly for cloning: is it possible for us to just use `readResolve` to resolve an alternative object?

> @liach Not sure I understand, could you elaborate a bit?

I mean that we call the setters in `readObject` methods. If we can instead call `readResolve` to provide safely constructed objects from constructors, that may be better, but since we are looking at marshalling guess we will not touch serialization.

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

PR Comment: https://git.openjdk.org/jdk/pull/24821#issuecomment-2824591150


More information about the core-libs-dev mailing list