This is an automated email from the ASF dual-hosted git repository. dongjoon pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new b5f96fa5fb5 [SPARK-42369][CORE] Fix constructor for java.nio.DirectByteBuffer b5f96fa5fb5 is described below commit b5f96fa5fb5ca7daa497b6dfd25e738c4f479aec Author: Ludovic Henry <g...@ludovic.dev> AuthorDate: Tue Feb 7 07:45:12 2023 -0800 [SPARK-42369][CORE] Fix constructor for java.nio.DirectByteBuffer ### What changes were proposed in this pull request? In the latest JDK, the constructor `DirectByteBuffer(long, int)` was replaced with `DirectByteBuffer(long, long)`. We just want to support both by probing for the legacy one first and falling back to the newer one second. This change is completely transparent for the end-user, and makes sure Spark works transparently on the latest JDK as well. ### Why are the changes needed? It's required to support the latest versions of the JDK. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? It was built and ran locally against the newest JDK. Closes #39909 from luhenry/patch-2. Authored-by: Ludovic Henry <g...@ludovic.dev> Signed-off-by: Dongjoon Hyun <dongj...@apache.org> --- .../unsafe/src/main/java/org/apache/spark/unsafe/Platform.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java b/common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java index 12867627379..4dd51991ba4 100644 --- a/common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java +++ b/common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java @@ -68,7 +68,14 @@ public final class Platform { } try { Class<?> cls = Class.forName("java.nio.DirectByteBuffer"); - Constructor<?> constructor = cls.getDeclaredConstructor(Long.TYPE, Integer.TYPE); + Constructor<?> constructor; + try { + constructor = cls.getDeclaredConstructor(Long.TYPE, Integer.TYPE); + } catch (NoSuchMethodException e) { + // DirectByteBuffer(long,int) was removed in + // https://github.com/openjdk/jdk/commit/a56598f5a534cc9223367e7faa8433ea38661db9 + constructor = cls.getDeclaredConstructor(Long.TYPE, Long.TYPE); + } Field cleanerField = cls.getDeclaredField("cleaner"); try { constructor.setAccessible(true); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org