LuciferYang commented on code in PR #43675:
URL: https://github.com/apache/spark/pull/43675#discussion_r1383348575


##########
core/src/main/scala/org/apache/spark/storage/StorageUtils.scala:
##########
@@ -197,13 +195,18 @@ private[spark] class StorageStatus(
 /** Helper methods for storage-related objects. */
 private[spark] object StorageUtils extends Logging {
 
-  private val bufferCleaner: DirectBuffer => Unit = {
-    val cleanerMethod =
-      Utils.classForName("sun.misc.Unsafe").getMethod("invokeCleaner", 
classOf[ByteBuffer])
-    val unsafeField = classOf[Unsafe].getDeclaredField("theUnsafe")
-    unsafeField.setAccessible(true)
-    val unsafe = unsafeField.get(null).asInstanceOf[Unsafe]
-    buffer: DirectBuffer => cleanerMethod.invoke(unsafe, buffer)
+  private val bufferCleaner: ByteBuffer => Unit = {
+    val cleanerClass = Utils.classForName("jdk.internal.ref.Cleaner")
+    val directBufferClass = Utils.classForName("sun.nio.ch.DirectBuffer")

Review Comment:
   I think this class can also be `java.nio.DirectByteBuffer` due to 
`MappedByteBuffer` has only two subclasses: `java.nio.DirectByteBuffer` and 
`java.nio.DirectByteBufferR`, and `java.nio.DirectByteBufferR` also inherits 
from `java.nio.DirectByteBuffer`. which one is better?
   
   
   
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to