Skip to content

Skip VarHandle init when unaligned access is supported (#16664)#16676

Merged
normanmaurer merged 1 commit into
5.0from
skip5
Apr 21, 2026
Merged

Skip VarHandle init when unaligned access is supported (#16664)#16676
normanmaurer merged 1 commit into
5.0from
skip5

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

initializeVarHandle(). This made VarHandle code reachable even when
Unsafe is available,
causing Truffle/Polyglot native-image builds to fail with
MethodHandle.linkToStatic blocklist violations (#16607).
Restoring the original Unsafe guard fixes #16607, but also kills

Use isUnaligned() as the guard instead. On platforms where unaligned
access is known (x86, modern ARM), Unsafe already handles multi-byte
access fine, so VarHandle
isn't needed and VarHandleFactory stays unreachable.
On platforms where UNALIGNED is unknown (exactly the case #16207
targets), VarHandle still gets initialized and works as before.

Fixes #16607.

Tested with the reporter's project
(https://github.com/adamdickmeiss/vertx-graalvm-native-image-log4j):

  • Before: === Found 4 compilation blocklist violations === BUILD
    FAILURE
  • After: No violations, BUILD SUCCESS

Co-authored-by: Chris Vest christianvest_hansen@apple.com

`initializeVarHandle()`. This made VarHandle code reachable even when
Unsafe is available,
causing Truffle/Polyglot native-image builds to fail with
`MethodHandle.linkToStatic` blocklist violations (#16607).
Restoring the original Unsafe guard fixes #16607, but also kills

Use `isUnaligned()` as the guard instead. On platforms where unaligned
access is known (x86, modern ARM), Unsafe already handles multi-byte
access fine, so VarHandle
   isn't needed and VarHandleFactory stays unreachable.
On platforms where UNALIGNED is unknown (exactly the case #16207
targets), VarHandle still gets initialized and works as before.

Fixes #16607.

Tested with the reporter's project
(https://github.com/adamdickmeiss/vertx-graalvm-native-image-log4j):
- Before: `=== Found 4 compilation blocklist violations ===` BUILD
FAILURE
- After: No violations, BUILD SUCCESS

Co-authored-by: Chris Vest <christianvest_hansen@apple.com>
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Apr 21, 2026
@normanmaurer normanmaurer merged commit d88be5f into 5.0 Apr 21, 2026
19 of 23 checks passed
@normanmaurer normanmaurer deleted the skip5 branch April 21, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants