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

Per Minborg pminborg at openjdk.org
Wed Apr 23 10:46:40 UTC 2025


On Wed, 23 Apr 2025 10:10:54 GMT, Viktor Klang <vklang at openjdk.org> wrote:

> This Pull Request replaces the uses of Field + setAccessible to modify final fields in java.util.concurrent with Unsafe.

src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java line 534:

> 532:         U.putReference(
> 533:             this,
> 534:             U.objectFieldOffset(ConcurrentSkipListSet.class, "m"),

Would it make sense to compute the offset once and for all and put it in a `static final long` field?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24821#discussion_r2055774428


More information about the core-libs-dev mailing list