On Thu, 3 Jul 2025 18:41:27 GMT, Chen Liang <li...@openjdk.org> wrote:
>> Unsafe throws IAE for misusing static vs instance fields, and it's revealed >> that AtomicXxxFieldUpdaters are using this mechanism to reject static >> fields. This is not a good practice, but we can at least document this so we >> don't accidentally introduce problems. > > Chen Liang has updated the pull request incrementally with one additional > commit since the last revision: > > Test to verify observed internal unsafe behaviors test/jdk/jdk/internal/misc/Unsafe/AddressComputationContractTest.java line 91: > 89: assertDoesNotThrow(() -> > getUnsafe().arrayBaseOffset(int[].class)); > 90: assertThrows(NullPointerException.class, () -> > getUnsafe().arrayBaseOffset(null)); > 91: // Caused by VM trying to throw java.lang.InvalidClassException > (there's one in java.io instead) Note that the one in `java.io` is also a checked exception (extends `java.io.ObjectStreamException` which extends `java.io.IOException`). ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/25945#discussion_r2188513237