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 af536459501 [SPARK-44237][CORE] Simplify DirectByteBuffer constructor
lookup logic
af536459501 is described below
commit af5364595015acaed7e0499a70d2d40fddc1a400
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Wed Jun 28 22:54:18 2023 -0700
[SPARK-44237][CORE] Simplify DirectByteBuffer constructor lookup logic
### What changes were proposed in this pull request?
This PR aims to simplify `DirectByteBuffer` constructor lookup logic.
### Why are the changes needed?
`try-catch` statement is not needed because we know version number already.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Pass the CIs.
Closes #41780 from dongjoon-hyun/SPARK-44237.
Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
---
.../src/main/java/org/apache/spark/unsafe/Platform.java | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
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 4dd51991ba4..a91ea2ee6b5 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,14 +68,9 @@ public final class Platform {
}
try {
Class<?> cls = Class.forName("java.nio.DirectByteBuffer");
- 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);
- }
+ Constructor<?> constructor = (majorVersion < 21) ?
+ cls.getDeclaredConstructor(Long.TYPE, Integer.TYPE) :
+ cls.getDeclaredConstructor(Long.TYPE, Long.TYPE);
Field cleanerField = cls.getDeclaredField("cleaner");
try {
constructor.setAccessible(true);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]