On Thu, 26 Jun 2025 05:42:24 GMT, ExE Boss <d...@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.
>
> I noticed that the native implementation of 
> `Unsafe​::array⁠(BaseOffset​/IndexScale)` refers to the non‑existent class 
> `java.lang.InvalidClassException` instead of 
> `java.lang.IllegalArgumentException` (which results in 
> `java.lang.NoClassDefFoundError` being thrown):
> https://github.com/openjdk/jdk/blob/1ca008fd02496dc33e2707c102560cae1690fba5/src/hotspot/share/prims/unsafe.cpp#L587-L594

I have added test cases to verify the current behaviors of Atomic field 
updaters and Unsafe memory address calculation methods, including untouched 
ones for arrays pointed out by @ExE-Boss. All of these are currently exposed 
through public APIs.

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

PR Comment: https://git.openjdk.org/jdk/pull/25945#issuecomment-3033199829

Reply via email to