[ https://issues.apache.org/jira/browse/SPARK-24421?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16531235#comment-16531235 ]
Andrew Korzhuev edited comment on SPARK-24421 at 7/3/18 11:44 AM: ------------------------------------------------------------------ If I understand this correctly, then the only deprecated JDK9+ API Spark is using is `sun.misc.Cleaner` (while `sun.misc.Unsafe` is still accessible) in `[common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java|https://github.com/andrusha/spark/commit/7da06d3c725169f9764225f5a29886eb56bee191#diff-c7483c7efce631c783676f014ba2b0ed]`, which is fixable in the following way: {code:java} @@ -22,7 +22,7 @@ import java.lang.reflect.Method; import java.nio.ByteBuffer; -import sun.misc.Cleaner; +import java.lang.ref.Cleaner; import sun.misc.Unsafe; public final class Platform { @@ -169,7 +169,8 @@ public static ByteBuffer allocateDirectBuffer(int size) { cleanerField.setAccessible(true); long memory = allocateMemory(size); ByteBuffer buffer = (ByteBuffer) constructor.newInstance(memory, size); - Cleaner cleaner = Cleaner.create(buffer, () -> freeMemory(memory)); + Cleaner cleaner = Cleaner.create(); + cleaner.register(buffer, () -> freeMemory(memory)); cleanerField.set(buffer, cleaner); return buffer; {code} [https://github.com/andrusha/spark/commit/7da06d3c725169f9764225f5a29886eb56bee191#diff-c7483c7efce631c783676f014ba2b0ed] was (Author: akorzhuev): If I understand this correctly, then the only deprecated JDK9+ API Spark is using is `sun.misc.Cleaner` (while `sun.misc.Unsafe` is still accessible) in `[common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java|https://github.com/andrusha/spark/commit/7da06d3c725169f9764225f5a29886eb56bee191#diff-c7483c7efce631c783676f014ba2b0ed]`, which is fixable in the following way: {code:java} @@ -22,7 +22,7 @@ import java.lang.reflect.Method; import java.nio.ByteBuffer; -import sun.misc.Cleaner; +import java.lang.ref.Cleaner; import sun.misc.Unsafe; public final class Platform { @@ -169,7 +169,8 @@ public static ByteBuffer allocateDirectBuffer(int size) { cleanerField.setAccessible(true); long memory = allocateMemory(size); ByteBuffer buffer = (ByteBuffer) constructor.newInstance(memory, size); - Cleaner cleaner = Cleaner.create(buffer, () -> freeMemory(memory)); + Cleaner cleaner = Cleaner.create(); + cleaner.register(buffer, () -> freeMemory(memory)); cleanerField.set(buffer, cleaner); return buffer; {code} [https://github.com/andrusha/spark/commit/7da06d3c725169f9764225f5a29886eb56bee191#diff-c7483c7efce631c783676f014ba2b0ed] > sun.misc.Unsafe in JDK9+ > ------------------------ > > Key: SPARK-24421 > URL: https://issues.apache.org/jira/browse/SPARK-24421 > Project: Spark > Issue Type: Sub-task > Components: Build > Affects Versions: 2.3.0 > Reporter: DB Tsai > Priority: Major > > Many internal APIs such as unsafe are encapsulated in JDK9+, see > http://openjdk.java.net/jeps/260 for detail. > To use Unsafe, we need to add *jdk.unsupported* to our code’s module > declaration: > {code:java} > module java9unsafe { > requires jdk.unsupported; > } > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org