azagrebin opened a new pull request #11160: [FLINK-15094] Use Unsafe to instantiate and construct DirectByteBuffer URL: https://github.com/apache/flink/pull/11160 ## What is the purpose of the change If we use reflection to create a DirectByteBuffer to wrap unsafe native memory allocations, it causes illegal access warnings in Java9+. This PR changes this to use Unsafe to instantiate a DirectByteBuffer. The address and capacity fields are set by direct unsafe memory operations. Other fields are set by calling ByteBuffer#clear at the end. Unsafe operations skips the illegal access verification and do not result in warnings. The same approach is used to get the address field. This solution still relies on Unsafe which is about to be removed in future Java releases. If it is removed and we still do not want to contribute to direct memory by allocating native managed memory, we will have to find an alternative solution, like e.g. writing a custom native allocator and use JNI API to instantiate the wrapping DirectByteBuffer (NewDirectByteBuffer in C). ## Verifying this change unit tests
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
