You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2020/12/03 16:26:19 UTC

[incubator-datasketches-memory] branch JKD11Compatibility created (now 029d8f4)

This is an automated email from the ASF dual-hosted git repository.

leerho pushed a change to branch JKD11Compatibility
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-memory.git.


      at 029d8f4  interim mods for JDK11

This branch includes the following new commits:

     new 029d8f4  interim mods for JDK11

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org


[incubator-datasketches-memory] 01/01: interim mods for JDK11

Posted by le...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

leerho pushed a commit to branch JKD11Compatibility
in repository https://gitbox.apache.org/repos/asf/incubator-datasketches-memory.git

commit 029d8f45fc039ab06854e34c3e9c30b6b93c1c8c
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Thu Dec 3 08:25:49 2020 -0800

    interim mods for JDK11
---
 .../java/org/apache/datasketches/memory/AllocateDirect.java | 13 +++++++------
 .../org/apache/datasketches/memory/AllocateDirectMap.java   |  3 ++-
 .../java/org/apache/datasketches/memory/UnsafeUtilTest.java | 13 +++++++++----
 3 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/apache/datasketches/memory/AllocateDirect.java b/src/main/java/org/apache/datasketches/memory/AllocateDirect.java
index e699e1f..423c074 100644
--- a/src/main/java/org/apache/datasketches/memory/AllocateDirect.java
+++ b/src/main/java/org/apache/datasketches/memory/AllocateDirect.java
@@ -24,7 +24,8 @@ import static org.apache.datasketches.memory.UnsafeUtil.unsafe;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import sun.misc.Cleaner;
+import sun.misc.Cleaner;         //JDK 8
+//import jdk.internal.ref.Cleaner;   //JDK 9+
 
 /**
  * Provides access to direct (native) memory.
@@ -34,9 +35,9 @@ import sun.misc.Cleaner;
  */
 final class AllocateDirect implements AutoCloseable {
   private static final Logger LOG = LoggerFactory.getLogger(AllocateDirect.class);
-
+  
   private final Deallocator deallocator;
-  private final Cleaner cleaner; //TODO-JDK9 import jdk.internal.ref.Cleaner;
+  private final Cleaner cleaner;
   private final long nativeBaseOffset;
 
   /**
@@ -60,14 +61,14 @@ final class AllocateDirect implements AutoCloseable {
       NioBits.unreserveMemory(allocationSize, capacityBytes);
       throw err;
     }
-    if (pageAligned && ((nativeAddress % pageSize) != 0)) {
+    if (pageAligned && nativeAddress % pageSize != 0) {
       //Round up to page boundary
       nativeBaseOffset = (nativeAddress & ~(pageSize - 1L)) + pageSize;
     } else {
       nativeBaseOffset = nativeAddress;
     }
     deallocator = new Deallocator(nativeAddress, allocationSize, capacityBytes);
-    cleaner = Cleaner.create(this, deallocator);
+      cleaner = Cleaner.create(this, deallocator);
   }
 
   @Override
@@ -112,7 +113,7 @@ final class AllocateDirect implements AutoCloseable {
       this.nativeAddress = nativeAddress;
       this.allocationSize = allocationSize;
       this.capacity = capacity;
-      assert (nativeAddress != 0);
+      assert nativeAddress != 0;
     }
 
     StepBoolean getValid() {
diff --git a/src/main/java/org/apache/datasketches/memory/AllocateDirectMap.java b/src/main/java/org/apache/datasketches/memory/AllocateDirectMap.java
index 41cdf46..a7f6d8c 100644
--- a/src/main/java/org/apache/datasketches/memory/AllocateDirectMap.java
+++ b/src/main/java/org/apache/datasketches/memory/AllocateDirectMap.java
@@ -33,7 +33,8 @@ import java.nio.channels.FileChannel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import sun.misc.Cleaner; //TODO-JDK9 jdk.internal.ref.Cleaner;
+import sun.misc.Cleaner;         //JDK 8
+//import jdk.internal.ref.Cleaner;   //JDK 9+
 import sun.nio.ch.FileChannelImpl;
 
 /**
diff --git a/src/test/java/org/apache/datasketches/memory/UnsafeUtilTest.java b/src/test/java/org/apache/datasketches/memory/UnsafeUtilTest.java
index 5a5aaeb..e571d59 100644
--- a/src/test/java/org/apache/datasketches/memory/UnsafeUtilTest.java
+++ b/src/test/java/org/apache/datasketches/memory/UnsafeUtilTest.java
@@ -54,6 +54,11 @@ public class UnsafeUtilTest {
   }
 
   @Test
+  public void checkJDK_MAJOR() {
+    println(UnsafeUtil.JDK_MAJOR);
+  }
+
+  @Test
   public void checkJdkString() {
     String jdkVer;
     int[] p = new int[2];
@@ -63,7 +68,7 @@ public class UnsafeUtilTest {
       jdkVer = good1_8Strings[i];
       p = UnsafeUtil.parseJavaVersion(jdkVer);
       UnsafeUtil.checkJavaVersion(jdkVer, p[0], p[1]);
-      int jdkMajor = (p[0] == 1) ? p[1] : p[0]; //model the actual JDK_MAJOR
+      int jdkMajor = p[0] == 1 ? p[1] : p[0]; //model the actual JDK_MAJOR
       if (p[0] == 1) { assertTrue(jdkMajor == p[1]); }
       if (p[0] > 1 ) { assertTrue(jdkMajor == p[0]); }
     }
@@ -156,10 +161,10 @@ public class UnsafeUtilTest {
   }
 
   /**
-   * @param s String to print
+   * @param o String to print
    */
-  static void println(final String s) {
-    //System.out.println(s);
+  static void println(final Object o) {
+    //System.out.println(o.toString());
   }
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org