On Sat, 15 Mar 2025 23:51:36 GMT, John R Rose <jr...@openjdk.org> wrote:

> I'm surprised to see `@ForceInline` in the offset query functions in 
> `Unsafe`. Those are not on any fast path I'm aware of. What use case does 
> this annotation address? If none, consider deleting; it will be a future 
> maintenance puzzle. Or at least document in a comment why a slow path 
> function needs such an annotation.

Looks like it was added as part of JDK-8149159 in JDK 9 as part of work to 
improve the argument checking. We have touched this area a few times (for 
deprecations and warnings mostly) but we missed it.

Part of me wonders if the additional checks in Unsafe are really needed. The 
first use of offset methods will print a warning to say they are going to be 
removed in the future. If someone is really determined to hack on a SV then 
they will just exploit layout and bypass the check. We don't have any deterrent 
(aside from the first) warning for the more likely case of someone using the 
offsets to modify a static final.

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

PR Comment: https://git.openjdk.org/jdk/pull/23972#issuecomment-2727248346

Reply via email to