LWJGL / lwjgl3

LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan, bgfx), audio (OpenAL, Opus), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR, OpenXR) applications.
https://www.lwjgl.org
BSD 3-Clause "New" or "Revised" License
4.67k stars 628 forks source link

When will Unsafe be removed? #962

Open bowbahdoe opened 3 months ago

bowbahdoe commented 3 months ago

Question

I've been digging in to OpenAL and noticed some usages of sun.misc.Unsafe + a requires jdk.unsupported in the module-info.

Given that Unsafe will be removed at some point, what are the current plans for moving away from it? Are there particular upcoming APIs (like the foreign memory api? MultiReleaseMemCopy is where i found one of the usages.) that are being waited on?

ws909 commented 3 months ago

Duplicates:

bowbahdoe commented 3 months ago

Its only a duplicate if java.lang.foreign does hit all of the requirements needed to remove unsafe

TheMrMilchmann commented 2 months ago

LWJGL 3 supports Java 8 and that won't change before a new major version. Thus, just the release of the new FFI in Java 22 is not enough to replace Unsafe. Further, migrating to the new FFI is a significant undertaking and will probably not happen before value/primitive classes (or whatever they end up being called) are available.

Sure, Unsafe is being removed, but slowly. If this happens before value types are made available, this will be revisited, but that's unlikely. (I would actually be surprised if unsafe removed in the next four years.)