You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by wl...@apache.org on 2022/10/20 16:18:01 UTC
[datasketches-memory] branch multiReleaseRework updated: start of java17
This is an automated email from the ASF dual-hosted git repository.
wlauer pushed a commit to branch multiReleaseRework
in repository https://gitbox.apache.org/repos/asf/datasketches-memory.git
The following commit(s) were added to refs/heads/multiReleaseRework by this push:
new 803d547 start of java17
803d547 is described below
commit 803d5474a3aad5d33bc5a21ef02e50dfb7926ee9
Author: Will Lauer <wl...@yahooinc.com>
AuthorDate: Thu Oct 20 11:17:56 2022 -0500
start of java17
---
src/main/java17/module-info.java | 22 ++++++++++
.../memory/internal/impl/MemoryCleaner.java | 51 ++++++++++++++++++++++
.../datasketches/memory/java17-placeholder.java | 26 +++++++++++
3 files changed, 99 insertions(+)
diff --git a/src/main/java17/module-info.java b/src/main/java17/module-info.java
new file mode 100644
index 0000000..e439fa8
--- /dev/null
+++ b/src/main/java17/module-info.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+module org.apache.datasketches.memory {
+
+ exports org.apache.datasketches.memory;
+}
diff --git a/src/main/java17/org/apache/datasketches/memory/internal/impl/MemoryCleaner.java b/src/main/java17/org/apache/datasketches/memory/internal/impl/MemoryCleaner.java
new file mode 100644
index 0000000..6ebb697
--- /dev/null
+++ b/src/main/java17/org/apache/datasketches/memory/internal/impl/MemoryCleaner.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.datasketches.memory.internal.impl;
+
+import java.lang.ref.Cleaner;
+
+/**
+ * Extracts a version-dependent reference to the `jdk.internal.ref.Cleaner` into
+ * a standalone class. The package name for Cleaner has changed in
+ * later versions. The appropriate class will be loaded by the class loader
+ * depending on the Java version that is used.
+ * For more information, see: https://openjdk.java.net/jeps/238
+ */
+public class MemoryCleaner {
+ private static final Cleaner cleaner = Cleaner.create();
+ private final Cleaner.Cleanable cleanable;
+
+ /**
+ * Creates a new `jdk.internal.ref.Cleaner`.
+ * @param referent the object to be cleaned
+ * @param deallocator - the cleanup code to be run when the cleaner is invoked.
+ * return MemoryCleaner
+ */
+ public MemoryCleaner(final Object referent, final Runnable deallocator) {
+ cleanable = cleaner.register(referent, deallocator);
+ }
+
+ /**
+ * Runs this cleaner, if it has not been run before.
+ */
+ public void clean() {
+ cleanable.clean();
+ }
+}
diff --git a/src/main/java17/org/apache/datasketches/memory/java17-placeholder.java b/src/main/java17/org/apache/datasketches/memory/java17-placeholder.java
new file mode 100644
index 0000000..7e0e427
--- /dev/null
+++ b/src/main/java17/org/apache/datasketches/memory/java17-placeholder.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.datasketches.memory;
+
+/**
+ * Inaccessible placeholder class to ensure the multi-release jar for java11 includes this package.
+ */
+class Placeholder17 {
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org